python-3.x - 交互式经纪商 API 客户端 /Python 将 LMT 价格设置为当前价格
问题描述
使用 Python 和 IB API 如何将 lmt 价格设置为当前市场价格。下面是一个示例,当您调用 make_order 并通过操作和数量传递价格时。如何将价格定义为 MarketPrice?
def make_order(action, quantity,price):
if price is not None:
order = Order()
order.m_orderType = 'LMT'
order.m_totalQuantity = 2
order.m_action = action
order.m_lmtPrice = price
order.m_outsideRth = True
解决方案
您需要通过调用类似reqTickByTickData
or的函数来访问当前价格reqMktData
。然后您可以将该lmtPrice
字段设置为当前价格。
如果你想以当前价格下单,你创建一个市价单不是更好吗?
推荐阅读
- javascript - 在 PWA (Android) 上禁用 Google 搜索 Snackbar
- python - Python计算具有特殊值的行
- javascript - 更新 Firestore 数据库中的数据
- flutter - 如何在 Flutter 中有两个不同的文本位置(顶部和底部)?
- c# - 拖放时如何保留按钮单击功能?
- excel - 从 xls 导入范围
- jquery - 关闭时间必须大于打开时间
- react-native - usestate 挂钩与计时器在 useeffect 挂钩内无法正常工作
- mysql - MySQL LOAD XML LOCAL INFILE:忽略特定标签
- google-cloud-platform - 云运行服务调用