-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (32 loc) · 1.08 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from MatchingEngine import MatchingEngine
from Transaction import Transaction
from TradedEngine import TradedEngine
import time
import uuid
import csv
import os
import matplotlib as mpl
from plotting import Plotting
"""
Initial testing for matching engine
Loops over values in dataset, if valid performs matching algorithm on it
Continues until dataset is finished
"""
dataSource = "Resources/MSFT1/"
fileToOpen = dataSource + "MSFTBook.csv"
if __name__ == "__main__":
engine = MatchingEngine()
plot = Plotting()
with open(fileToOpen, newline = "") as csvfile:
spamreader = csv.reader(csvfile, delimiter = ",", quotechar= "|")
startTime = time.time()
for row in spamreader:
row = list(row)
if row[1] == "1":
transaction = Transaction(fromCSV = row)
engine.addToBook(transaction)
matched = engine.priceTimePriority()
while matched:
plot.add(time.time() - startTime, transaction.price)
matched = engine.priceTimePriority()
plot.plot()