Updated time to utc in test_update_funding_fees, some funding rate key errors because a timestamp is likely not in utc

This commit is contained in:
Sam Germain 2021-11-06 05:56:58 -06:00
parent fd63fa7dda
commit cb97c6f388
3 changed files with 4 additions and 2 deletions

View File

@ -1711,6 +1711,8 @@ class Exchange:
def _get_funding_fee_dates(self, d1: datetime, d2: datetime): def _get_funding_fee_dates(self, d1: datetime, d2: datetime):
d1_hours = d1.hour + 1 if self.funding_fee_cutoff(d1) else d1.hour d1_hours = d1.hour + 1 if self.funding_fee_cutoff(d1) else d1.hour
if d1_hours == 24:
d1_hours = 0
d1 = datetime(d1.year, d1.month, d1.day, d1_hours, tzinfo=timezone.utc) d1 = datetime(d1.year, d1.month, d1.day, d1_hours, tzinfo=timezone.utc)
d2 = datetime(d2.year, d2.month, d2.day, d2.hour, tzinfo=timezone.utc) d2 = datetime(d2.year, d2.month, d2.day, d2.hour, tzinfo=timezone.utc)

View File

@ -275,7 +275,7 @@ class FreqtradeBot(LoggingMixin):
trade.pair, trade.pair,
trade.amount, trade.amount,
trade.open_date trade.open_date
) ) + (trade.funding_fees or 0.0)
else: else:
funding_fees = self.exchange.get_funding_fees_from_exchange( funding_fees = self.exchange.get_funding_fees_from_exchange(
trade.pair, trade.pair,

View File

@ -4718,7 +4718,7 @@ def test_update_funding_fees(mocker, default_conf, time_machine, fee):
time: 0, mark: 1.2, fundRate: 0.00049426, nominal_value: 147.6, fundFee: 0.072952776 time: 0, mark: 1.2, fundRate: 0.00049426, nominal_value: 147.6, fundFee: 0.072952776
time: 8, mark: 1.2, fundRate: 0.00032715, nominal_value: 147.6, fundFee: 0.04828734 time: 8, mark: 1.2, fundRate: 0.00032715, nominal_value: 147.6, fundFee: 0.04828734
''' '''
time_machine.move_to("2021-09-01 00:00:00") time_machine.move_to("2021-09-01 00:00:00 +00:00")
funding_rates = { funding_rates = {
"LTC/BTC": { "LTC/BTC": {