hbdmapi / huobi_futures_Python

An Asynchronous Event-driven High-frequency Trading System,huobi future,huobi coin margined swap, huobi usdt margined swap included.
MIT License
267 stars 113 forks source link

属性无值 #33

Closed Lxtluck closed 4 years ago

Lxtluck commented 4 years ago
    self.long_quantity = long_quantity  # 多仓数量
    self.long_avg_price = long_avg_price  # 多仓持仓平均价格
    self.long_pnl_ratio = long_pnl_ratio # 多仓收益率
    self.long_pnl_unreal = long_pnl_unreal # 多仓未实现盈亏
    self.long_pnl = long_pnl # 多仓已实现盈亏
    self.long_pos_margin = long_pos_margin # 多仓持仓保证金 

以上属性 只有long_quantity与long_avg_price有值,其余均为None,是什么原因

foonsun commented 4 years ago

可以开启Debug模式,原始log也打印下提供方便排查呢

Lxtluck commented 4 years ago

如何开启Debug模式

Lxtluck commented 4 years ago

我pull了一下代码 发现现在log打印的特别多 是改变了log级别吗

Lxtluck commented 4 years ago

I [2020-08-14 01:30:34,968] [-] [MyStrategy] position update: [platform: huobi_future, account: account, strategy: my_test_strategy, symbol: ETH/quarter, short_quantity: None, short_avg_price: None, long_quantity: 1600, long_avg_price: 438.2935461256214, liquid_price: None, utime: 1597368634798]

foonsun commented 4 years ago

是的,默认开启Debug模式了,这边也看下。

Lxtluck commented 4 years ago

爆仓价格也不显示 为None

Lxtluck commented 4 years ago

还有就是 我要取实时的成交价格 怎么取?self属性里没找到

foonsun commented 4 years ago

@Lxtluck 目前强平价等数据属性是预留,目前还没做实现,后续会做下补充。

foonsun commented 4 years ago

on_event_trade_update 是最新公开成交记录的回调,这里可以去拿最新成交价格。

Lxtluck commented 4 years ago

[MyStrategy] trade update: {"platform": "huobi_future", "symbol": "ETH_CQ", "action": "SELL", "price": "434.07100000", "quantity": "4.00000000", "timestamp": 1597374506535} 假如我要取这个price怎么取?

igkoh commented 4 years ago

In position from on_event_position_update, [platform: huobi_future, account: account, strategy: my_test_strategy, symbol: ETH/quarter, short_quantity: None, short_avg_price: None, long_quantity: 1600, long_avg_price: 438.2935461256214, liquid_price: None, utime: 1597368634798]

[platform: huobi_future, account: 13938898680, strategy: my_test_strategy, symbol: BTC/quarter, short_quantity: 202, short_avg_price: 11834.813543485521, long_quantity: 0, long_avg_price: 0, liquid_price: None, utime: 1597368542798]

Sometimes position reports short_quantity: 0 short_avg_price: 0 instead of None. How the system decides to report None or zero in position?

foonsun commented 4 years ago

[MyStrategy] trade update: {"platform": "huobi_future", "symbol": "ETH_CQ", "action": "SELL", "price": "434.07100000", "quantity": "4.00000000", "timestamp": 1597374506535} 假如我要取这个price怎么取?

上面是标准的class属性的获取方式,可以参考python class属性如何获取。

foonsun commented 4 years ago

In position from on_event_position_update, [platform: huobi_future, account: account, strategy: my_test_strategy, symbol: ETH/quarter, short_quantity: None, short_avg_price: None, long_quantity: 1600, long_avg_price: 438.2935461256214, liquid_price: None, utime: 1597368634798]

[platform: huobi_future, account: 13938898680, strategy: my_test_strategy, symbol: BTC/quarter, short_quantity: 202, short_avg_price: 11834.813543485521, long_quantity: 0, long_avg_price: 0, liquid_price: None, utime: 1597368542798]

Sometimes position reports short_quantity: 0 short_avg_price: 0 instead of None. How the system decides to report None or zero in position?

Hi,@igkoh, The position is None when your account has never opened the long or short position.Once your account has opened the long or short position,the position will be zero.

igkoh commented 4 years ago

@foonsun Once you kindly explained as: since position is not created at all, quantity and price are not existent up to that moment, thus None. Afterward, quantity and position have numerical values of zero.

foonsun commented 4 years ago

yes.@igkoh.