Skip to content

Commit 8f38030

Browse files
committed
Formatting
1 parent cdaead2 commit 8f38030

File tree

1 file changed

+49
-58
lines changed

1 file changed

+49
-58
lines changed

demo/demo.py

Lines changed: 49 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def demo_02(trader: shift.Trader):
2424
:return:
2525
"""
2626

27-
aapl_limit_buy = shift.Order(shift.Order.Type.LIMIT_BUY, "AAPL", 10, 10.00)
28-
trader.submit_order(aapl_limit_buy)
27+
aapl_lb = shift.Order(shift.Order.Type.LIMIT_BUY, "AAPL", 10, 10.00)
28+
trader.submit_order(aapl_lb)
2929

30-
xom_limit_buy = shift.Order(shift.Order.Type.LIMIT_BUY, "XOM", 10, 10.00)
31-
trader.submit_order(xom_limit_buy)
30+
xom_lb = shift.Order(shift.Order.Type.LIMIT_BUY, "XOM", 10, 10.00)
31+
trader.submit_order(xom_lb)
3232

3333
return
3434

@@ -42,21 +42,15 @@ def demo_03(trader: shift.Trader):
4242

4343
print("AAPL:")
4444
print(" Price\t\tSize\t Dest\t\tTime")
45-
for order in trader.get_order_book("AAPL", shift.OrderBookType.LOCAL_BID):
46-
print(
47-
"%7.2f\t\t%4d\t%6s\t\t%19s"
48-
% (order.price, order.size, order.destination, order.time)
49-
)
45+
for o in trader.get_order_book("AAPL", shift.OrderBookType.LOCAL_BID):
46+
print("%7.2f\t\t%4d\t%6s\t\t%19s" % (o.price, o.size, o.destination, o.time))
5047

5148
print()
5249

5350
print("XOM:")
5451
print(" Price\t\tSize\t Dest\t\tTime")
55-
for order in trader.get_order_book("XOM", shift.OrderBookType.LOCAL_BID):
56-
print(
57-
"%7.2f\t\t%4d\t%6s\t\t%19s"
58-
% (order.price, order.size, order.destination, order.time)
59-
)
52+
for o in trader.get_order_book("XOM", shift.OrderBookType.LOCAL_BID):
53+
print("%7.2f\t\t%4d\t%6s\t\t%19s" % (o.price, o.size, o.destination, o.time))
6054

6155

6256
def demo_04(trader: shift.Trader):
@@ -69,18 +63,18 @@ def demo_04(trader: shift.Trader):
6963
print(
7064
"Symbol\t\t\t\tType\t Price\t\tSize\tExecuted\tID\t\t\t\t\t\t\t\t\t\t\t\t\t\t Status\t\tTimestamp"
7165
)
72-
for order in trader.get_waiting_list():
66+
for o in trader.get_waiting_list():
7367
print(
7468
"%6s\t%16s\t%7.2f\t\t%4d\t\t%4d\t%36s\t%23s\t\t%26s"
7569
% (
76-
order.symbol,
77-
order.type,
78-
order.price,
79-
order.size,
80-
order.executed_size,
81-
order.id,
82-
order.status,
83-
order.timestamp,
70+
o.symbol,
71+
o.type,
72+
o.price,
73+
o.size,
74+
o.executed_size,
75+
o.id,
76+
o.status,
77+
o.timestamp,
8478
)
8579
)
8680

@@ -97,18 +91,18 @@ def demo_05(trader: shift.Trader):
9791
print(
9892
"Symbol\t\t\t\tType\t Price\t\tSize\tExecuted\tID\t\t\t\t\t\t\t\t\t\t\t\t\t\t Status\t\tTimestamp"
9993
)
100-
for order in trader.get_waiting_list():
94+
for o in trader.get_waiting_list():
10195
print(
10296
"%6s\t%16s\t%7.2f\t\t%4d\t\t%4d\t%36s\t%23s\t\t%26s"
10397
% (
104-
order.symbol,
105-
order.type,
106-
order.price,
107-
order.size,
108-
order.executed_size,
109-
order.id,
110-
order.status,
111-
order.timestamp,
98+
o.symbol,
99+
o.type,
100+
o.price,
101+
o.size,
102+
o.executed_size,
103+
o.id,
104+
o.status,
105+
o.timestamp,
112106
)
113107
)
114108

@@ -119,8 +113,8 @@ def demo_05(trader: shift.Trader):
119113
print("Canceling all pending orders...", end=" ")
120114

121115
# trader.cancel_all_pending_orders() also works
122-
for order in trader.get_waiting_list():
123-
trader.submit_cancellation(order)
116+
for o in trader.get_waiting_list():
117+
trader.submit_cancellation(o)
124118

125119
i = 0
126120
while trader.get_waiting_list_size() > 0:
@@ -142,11 +136,11 @@ def demo_06(trader: shift.Trader):
142136
:return:
143137
"""
144138

145-
aapl_market_buy = shift.Order(shift.Order.Type.MARKET_BUY, "AAPL", 1)
146-
trader.submit_order(aapl_market_buy)
139+
aapl_mb = shift.Order(shift.Order.Type.MARKET_BUY, "AAPL", 1)
140+
trader.submit_order(aapl_mb)
147141

148-
xom_market_buy = shift.Order(shift.Order.Type.MARKET_BUY, "XOM", 1)
149-
trader.submit_order(xom_market_buy)
142+
xom_mb = shift.Order(shift.Order.Type.MARKET_BUY, "XOM", 1)
143+
trader.submit_order(xom_mb)
150144

151145
return
152146

@@ -207,11 +201,11 @@ def demo_08(trader: shift.Trader):
207201
:return:
208202
"""
209203

210-
aapl_market_sell = shift.Order(shift.Order.Type.MARKET_SELL, "AAPL", 1)
211-
trader.submit_order(aapl_market_sell)
204+
aapl_ms = shift.Order(shift.Order.Type.MARKET_SELL, "AAPL", 1)
205+
trader.submit_order(aapl_ms)
212206

213-
xom_market_sell = shift.Order(shift.Order.Type.MARKET_SELL, "XOM", 1)
214-
trader.submit_order(xom_market_sell)
207+
xom_ms = shift.Order(shift.Order.Type.MARKET_SELL, "XOM", 1)
208+
trader.submit_order(xom_ms)
215209

216210
return
217211

@@ -226,22 +220,22 @@ def demo_09(trader: shift.Trader):
226220
print(
227221
"Symbol\t\t\t\tType\t Price\t\tSize\tExecuted\tID\t\t\t\t\t\t\t\t\t\t\t\t\t\t Status\t\tTimestamp"
228222
)
229-
for order in trader.get_submitted_orders():
230-
if order.status == shift.Order.Status.FILLED:
231-
price = order.executed_price
223+
for o in trader.get_submitted_orders():
224+
if o.status == shift.Order.Status.FILLED:
225+
price = o.executed_price
232226
else:
233-
price = order.price
227+
price = o.price
234228
print(
235229
"%6s\t%16s\t%7.2f\t\t%4d\t\t%4d\t%36s\t%23s\t\t%26s"
236230
% (
237-
order.symbol,
238-
order.type,
231+
o.symbol,
232+
o.type,
239233
price,
240-
order.size,
241-
order.executed_size,
242-
order.id,
243-
order.status,
244-
order.timestamp,
234+
o.size,
235+
o.executed_size,
236+
o.id,
237+
o.status,
238+
o.timestamp,
245239
)
246240
)
247241

@@ -256,11 +250,8 @@ def demo_10(trader: shift.Trader):
256250
"""
257251

258252
print(" Price\t\tSize\t Dest\t\tTime")
259-
for order in trader.get_order_book("AAPL", shift.OrderBookType.GLOBAL_BID, 5):
260-
print(
261-
"%7.2f\t\t%4d\t%6s\t\t%19s"
262-
% (order.price, order.size, order.destination, order.time)
263-
)
253+
for o in trader.get_order_book("AAPL", shift.OrderBookType.GLOBAL_BID, 5):
254+
print("%7.2f\t\t%4d\t%6s\t\t%19s" % (o.price, o.size, o.destination, o.time))
264255

265256

266257
def main(argv):

0 commit comments

Comments
 (0)