Safer keys for funding_rate and mark_price dictionaries, based on rounding down the hour
This commit is contained in:
parent
8bfcf4ee09
commit
0c2501e11b
@ -1767,12 +1767,18 @@ class Exchange:
|
|||||||
)
|
)
|
||||||
history = {}
|
history = {}
|
||||||
for candle in candles:
|
for candle in candles:
|
||||||
# TODO: Round down to the nearest funding fee time,
|
d = datetime.fromtimestamp(int(candle[0] / 1000), timezone.utc)
|
||||||
# incase a timestamp ever has a delay of > 1s
|
# Round down to the nearest hour, in case of a delayed timestamp
|
||||||
milliseconds = int(candle[0] / 1000) * 1000
|
|
||||||
# The millisecond timestamps can be delayed ~20ms
|
# The millisecond timestamps can be delayed ~20ms
|
||||||
|
time = datetime(
|
||||||
|
d.year,
|
||||||
|
d.month,
|
||||||
|
d.day,
|
||||||
|
d.hour,
|
||||||
|
tzinfo=timezone.utc
|
||||||
|
).timestamp() * 1000
|
||||||
opening_mark_price = candle[1]
|
opening_mark_price = candle[1]
|
||||||
history[milliseconds] = opening_mark_price
|
history[time] = opening_mark_price
|
||||||
return history
|
return history
|
||||||
except ccxt.NotSupported as e:
|
except ccxt.NotSupported as e:
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
@ -1855,7 +1861,17 @@ class Exchange:
|
|||||||
since=since
|
since=since
|
||||||
)
|
)
|
||||||
for fund in response:
|
for fund in response:
|
||||||
funding_history[int(fund['timestamp'] / 1000) * 1000] = fund['fundingRate']
|
d = datetime.fromtimestamp(int(fund['timestamp'] / 1000), timezone.utc)
|
||||||
|
# Round down to the nearest hour, in case of a delayed timestamp
|
||||||
|
# The millisecond timestamps can be delayed ~20ms
|
||||||
|
time = datetime(
|
||||||
|
d.year,
|
||||||
|
d.month,
|
||||||
|
d.day,
|
||||||
|
d.hour,
|
||||||
|
tzinfo=timezone.utc
|
||||||
|
).timestamp() * 1000
|
||||||
|
funding_history[time] = fund['fundingRate']
|
||||||
return funding_history
|
return funding_history
|
||||||
except ccxt.DDoSProtection as e:
|
except ccxt.DDoSProtection as e:
|
||||||
raise DDosProtection(e) from e
|
raise DDosProtection(e) from e
|
||||||
|
Loading…
Reference in New Issue
Block a user