FutunnOpen / py-futu-api

富途 OpenAPI Python SDK
Apache License 2.0
1.03k stars 220 forks source link

history_order_list_query & position_list_query questions #149

Open tomingchen opened 11 months ago

tomingchen commented 11 months ago

I have 2 option orders executed, one is CSP (BABA) and the other is a call Spread (QQQ). I've 2 questions below:

1. From the API: data = trd_ctx.position_list_query()

with the selected fields from the data,

       stock_name  qty  can_sell_qty  cost_price  market_val  ...  today_sell_val  today_buy_qty  today_buy_val  position_side  today_pl_val

0 QQQ 240105 400.00C -1.0 -1.0 3.79 -388.0 ... 0.0 0.0 0.0 SHORT 0.0 1 BABA 240105 72.00P -1.0 -1.0 0.93 -99.0 ... 0.0 0.0 0.0 SHORT 0.0 2 QQQ 240105 405.00C 1.0 1.0 2.38 234.0 ... 0.0 0.0 0.0 LONG 0.0

It does show my holdings, BABA (CSP) and QQQ (Call Spread), but how do I associate the QQQ SHORT/LONG as a spread?

2. From the API: data = trd_ctx.history_order_list_query() With the a few selected fields from the data,

       stock_name    trd_side   order_status  qty  price              create_time             updated_time trail_spread

0 BABA 240105 72.00P SELL_SHORT FILLED_ALL 1.0 0.93 2023-11-24 10:17:55.893 2023-11-24 10:18:18.559 N/A 1 JETS 231229 15.50P SELL_SHORT CANCELLED_ALL 1.0 0.15 2023-11-22 15:48:56.049 2023-11-22 16:16:09.038 N/A

I don't see QQQ in this history_order_list, is it the correct API to gather all the historical order? or is my usage wrong?

My environment is: Moomoo OpenD 7.5.3708 moomoo-api 7.5.3708

thanks.

FutunnOpen commented 11 months ago

I have 2 option orders executed, one is CSP (BABA) and the other is a call Spread (QQQ). I've 2 questions below:

From the API: data = trd_ctx.position_list_query()

with the selected fields from the data,

       stock_name  qty  can_sell_qty  cost_price  market_val  ...  today_sell_val  today_buy_qty  today_buy_val  position_side  today_pl_val

0 QQQ 240105 400.00C -1.0 -1.0 3.79 -388.0 ... 0.0 0.0 0.0 SHORT 0.0 1 BABA 240105 72.00P -1.0 -1.0 0.93 -99.0 ... 0.0 0.0 0.0 SHORT 0.0 2 QQQ 240105 405.00C 1.0 1.0 2.38 234.0 ... 0.0 0.0 0.0 LONG 0.0

It does show my holdings, BABA (CSP) and QQQ (Call Spread), but how do I associate the QQQ SHORT/LONG as a spread?

From the API: data = trd_ctx.history_order_list_query() With the a few selected fields from the data,

       stock_name    trd_side   order_status  qty  price              create_time             updated_time trail_spread

0 BABA 240105 72.00P SELL_SHORT FILLED_ALL 1.0 0.93 2023-11-24 10:17:55.893 2023-11-24 10:18:18.559 N/A 1 JETS 231229 15.50P SELL_SHORT CANCELLED_ALL 1.0 0.15 2023-11-22 15:48:56.049 2023-11-22 16:16:09.038 N/A

I don't see QQQ in this history_order_list, is it the correct API to gather all the historical order? or is my usage wrong?

My environment is: Moomoo OpenD 7.5.3708 moomoo-api 7.5.3708

thanks.

OpenAPI does not support complex option strategy orders.

  1. You cannot relate the option positions to a CSP or Call Spread order.
  2. You cannot see the option strategy orders from neighter history_order_list nor order_list_query interface.
Phonicavi commented 8 months ago

@FutunnOpen Hi, 我也遇到同样的问题:实际执行的期权相关订单仅long/short单腿期权的部分能够被history_order_list接口获取 (所有的组合期权策略和自定义策略均没有被获取)。 这对于复核订单信息、计算P&L等都会造成不便。请问未来是否有计划支持这些订单的获取? 或者是否有类似App当中账户信息的 "资金>资金明细" 类似的功能接口, 可以按月份获取每笔股票/期权的成交金额和交易费用的接口? 这样也便于核算成本等。谢谢!