示例#1
0
exchange.connect()

START_PNL = exchange.get_pnl()

ma_A = MovingAverage(exchange, "PHILIPS_A")

tick = 1

while not should_kill_attempt(exchange, START_PNL):
    time.sleep(0.11)

    print(f"tick {tick}")
    tick += 1

    ma_A.update()

    # Don't want to balance our trades from our MM positions
    exchange.delete_orders("PHILIPS_A")

    if balance_positions(exchange, total_threshold=40):
        print("Balanced positions")
        continue

    arbitrage(exchange)
    stoikov_mm(exchange, "PHILIPS_A", ma_A.volatile(), delta=0.1, volume=50)

    if START_PNL is None:
        START_PNL = exchange.get_pnl()

print("Exit")
示例#2
0
 B_best_bid = e.get_last_price_book(instrument_id2).bids[0].price
 B_best_ask = e.get_last_price_book(instrument_id2).asks[0].price
 
 # print(A_best_bid, A_best_ask, B_best_bid, B_best_ask)
 
 if A_best_bid > B_best_ask:
     A_best_bid_vol = e.get_last_price_book(instrument_id1).bids[0].volume
     B_best_ask_vol = e.get_last_price_book(instrument_id2).asks[0].volume
     
     volume = min(A_best_bid_vol, B_best_ask_vol)
     
     result = e.insert_order(instrument_id1, price = A_best_bid, volume=volume, side='bid', order_type='limit')
     result = e.insert_order(instrument_id2, price = B_best_ask, volume=volume, side='ask', order_type='limit')
     print(f"Order Id: {result}")
     
 if B_best_bid > A_best_ask:
     A_best_ask_vol = e.get_last_price_book(instrument_id1).asks[0].volume
     B_best_bid_vol = e.get_last_price_book(instrument_id2).bids[0].volume
     
     volume = min(A_best_ask_vol, B_best_bid_vol)
     
     result = e.insert_order(instrument_id2, price = B_best_bid, volume=volume, side='bid', order_type='limit')
     result = e.insert_order(instrument_id1, price = A_best_ask, volume=volume, side='ask', order_type='limit')
     print(f"Order Id: {result}")
 
 time.sleep(0.25)
 
 if len(e.get_outstanding_orders(instrument_id1)) != 0:
     e.delete_orders(instrument_id1)
 if len(e.get_outstanding_orders(instrument_id2)) != 0:
     e.delete_orders(instrument_id2)