bmoscon / cryptofeed

Cryptocurrency Exchange Websocket Data Feed Handler
Other
2.21k stars 682 forks source link

Handle null next_funding_time and estimated_rate in HuobiSwap funding #1004

Closed agijsberts closed 8 months ago

agijsberts commented 8 months ago

HuobiSwap has null values for next_funding_time and estimated_rate in the funding rate, as can be seen at https://api.hbdm.com/swap-api/v1/swap_funding_rate?contract_code=BTC-USD:

{"status":"ok","data":{"estimated_rate":null,"funding_rate":"0.000268519557868291","contract_code":"BTC-USD","symbol":"BTC","fee_asset":"BTC","funding_time":"1705334400000","next_funding_time":null},"ts":1705307089168}

This PR sets the corresponding values to None if this is the case, thus avoiding an exception and missing data. I'm not completely sure about the rationale for the early stopping with the cached value in self.funding_updates, but if the reasoning was to avoid duplicate values then the pair funding_rate and funding_time should work just as well.