# 初始化交易所连接等参数 while True: # 获取当前市场深度 order_book = get_order_book() # 计算买卖报价 market_maker = MarketMaker(order_book, spread=20) bid_price = market_maker.get_bid_price() ask_price = market_maker.get_ask_price() # 获取当前持仓 positions = get_positions() # 计算可用资金 available_fund = get_available_fund() # 判断是否可以下单 if positions['long'] < 100 and available_fund > ask_price: # 下单买入 sendLongOrder(quantity=1) elif positions['short'] < 100 and available_fund > bid_price: # 下单卖出 sendShortOrder(quantity=1) # 暂停一段时间后继续循环 time.sleep(1)
标签:available,做市商,get,positions,流程,fund,下单,price From: https://www.cnblogs.com/kingkaixuan/p/17273148.html