@@ -108,16 +108,22 @@ async def _push_mark_price(self, symbol: str, ticker: dict):
108
108
async def _push_funding_rate (self , symbol : str , ticker : dict ):
109
109
try :
110
110
ticker = self .channel .exchange_manager .exchange .parse_funding (ticker , from_ticker = True )
111
+ if not ticker .get (enums .ExchangeConstantsFundingColumns .NEXT_FUNDING_TIME .value , 0 ):
112
+ # not enough info, don't push possibly false data
113
+ return
111
114
predicted_funding_rate = ticker .get (
112
115
enums .ExchangeConstantsFundingColumns .PREDICTED_FUNDING_RATE .value , constants .NaN
113
116
)
117
+ funding_rate = ticker .get (enums .ExchangeConstantsFundingColumns .FUNDING_RATE .value , constants .NaN )
118
+ next_funding_time = ticker [enums .ExchangeConstantsFundingColumns .NEXT_FUNDING_TIME .value ]
119
+ last_funding_time = ticker .get (enums .ExchangeConstantsFundingColumns .LAST_FUNDING_TIME .value , constants .NaN )
114
120
await exchanges_channel .get_chan (constants .FUNDING_CHANNEL , self .channel .exchange_manager .id )\
115
121
.get_internal_producer ().push (
116
122
symbol ,
117
- decimal .Decimal (str (ticker [ enums . ExchangeConstantsFundingColumns . FUNDING_RATE . value ] )),
123
+ decimal .Decimal (str (funding_rate or constants . NaN )),
118
124
decimal .Decimal (str (predicted_funding_rate or constants .NaN )),
119
- ticker [ enums . ExchangeConstantsFundingColumns . NEXT_FUNDING_TIME . value ] ,
120
- ticker [ enums . ExchangeConstantsFundingColumns . LAST_FUNDING_TIME . value ]
125
+ decimal . Decimal ( str ( next_funding_time or constants . NaN )) ,
126
+ decimal . Decimal ( str ( last_funding_time or constants . NaN )),
121
127
)
122
128
except Exception as e :
123
129
self .logger .exception (e , True , f"Fail to update funding rate from ticker : { e } " )
0 commit comments