2.94K 浏览
0
from tqsdk import TqApi, TqSim
api = TqApi(TqSim(init_balance=100000))

quote = api.get_quote("SHFE.rb1901")
print("Last Price: %f" % (quote.last_price))
print("Bid Price 1: %f" % (quote.bid_price1))
print("Ask Price 1: %f" % (quote.ask_price1))
print("Bid Volume 1: %f" % (quote.bid_volume1))
print("Ask Volume 1: %f" % (quote.ask_volume1))

order = api.insert_order(symbol="SHFE.rb1901", direction="BUY", offset="OPEN", limit_price=quote.ask_price1,volume=2)
print(order)

while order.status != "FINISHED":
  api.wait_update()
  print("委托单状态: %s, 未成交手数: %d 手" % (order.status, order.volume_left))

<img style="font-family: Verdana, Arial, Helvetica, sans-serif;" src="https://www.shinnytech.com/wp-content/uploads/anspress-temp/f4ccc5d005f522b6b5430501e5dce28a1da71f80_3707.JPG" />
李思恒 已回答的问题 2020年8月17日
0

因为get_quote的合约是已经下架的合约,换成现在可交易的合约就没有问题了

李思恒 已回答的问题 2020年8月17日