- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathPy2.py
More file actions
Latest commit
47 lines (42 loc) · 1.35 KB
/
Copy pathPy2.py
File metadata and controls
47 lines (42 loc) · 1.35 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
importtime
NUM_RECORDS=50*1000*444
classPyMemTrade():
def__init__(self, tradeId, clientId, venueId, instrumentCode, price, quantity, side):
self.tradeId=tradeId
self.clientId=clientId
self.venueId=venueId
self.instrumentCode=instrumentCode
self.price=price
self.quantity=quantity
self.side=side
definitTrades(trades):
foriinrange(0, NUM_RECORDS):
trades[i].tradeId=i
trades[i].clientId=1
trades[i].venueId=123
trades[i].instrumentCode=321
trades[i].price=i
trades[i].quantity=i
if (i%2==0):
trades[i].side='B'
else:
trades[i].side='S'
defperfRun(runNum, trades):
start=time.time() *1000
initTrades(trades)
buyCost=0
sellCost=0
foriinrange(0, NUM_RECORDS):
if (trades[i].side=='B'):
buyCost+=trades[i].price*trades[i].quantity
else:
sellCost+=trades[i].price*trades[i].quantity
end=time.time() *1000
duration=end-start
print(str(runNum) +" - duration "+str(int(duration)) +"ms\n")
#print(runNum, " - duration ", duration, "ms\n") This prints weird on Pypy
print("buyCost = ", buyCost, " sellCost = ", sellCost, "\n")
if__name__=='__main__':
trades= [PyMemTrade(0,0,0,0,0,0,'0') foriinrange(NUM_RECORDS)]
foriinrange (0, 5):
perfRun(i, trades)