Fixed time format for schedule and update_funding_fees conf is mocked better
This commit is contained in:
parent
6e1e1e00c2
commit
29e582c6d9
@ -4,7 +4,7 @@ Freqtrade is the main module of this bot. It contains the class Freqtrade()
|
|||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, time, timezone
|
||||||
from math import isclose
|
from math import isclose
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
@ -112,7 +112,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
|
|
||||||
if self.trading_mode == TradingMode.FUTURES:
|
if self.trading_mode == TradingMode.FUTURES:
|
||||||
for time_slot in self.exchange.funding_fee_times:
|
for time_slot in self.exchange.funding_fee_times:
|
||||||
schedule.every().day.at(time_slot).do(self.update_funding_fees())
|
schedule.every().day.at(str(time(time_slot))).do(self.update_funding_fees)
|
||||||
self.wallets.update()
|
self.wallets.update()
|
||||||
|
|
||||||
def notify_status(self, msg: str) -> None:
|
def notify_status(self, msg: str) -> None:
|
||||||
@ -195,6 +195,9 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
if self.get_free_open_trades():
|
if self.get_free_open_trades():
|
||||||
self.enter_positions()
|
self.enter_positions()
|
||||||
|
|
||||||
|
if self.trading_mode == TradingMode.FUTURES:
|
||||||
|
schedule.run_pending()
|
||||||
|
|
||||||
Trade.commit()
|
Trade.commit()
|
||||||
|
|
||||||
def process_stopped(self) -> None:
|
def process_stopped(self) -> None:
|
||||||
|
@ -7,6 +7,7 @@ from copy import deepcopy
|
|||||||
from math import isclose
|
from math import isclose
|
||||||
from unittest.mock import ANY, MagicMock, PropertyMock
|
from unittest.mock import ANY, MagicMock, PropertyMock
|
||||||
import time_machine
|
import time_machine
|
||||||
|
import schedule
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
import pytest
|
import pytest
|
||||||
@ -4284,15 +4285,17 @@ def test_get_valid_price(mocker, default_conf_usdt) -> None:
|
|||||||
@pytest.mark.parametrize('exchange,trading_mode,calls', [
|
@pytest.mark.parametrize('exchange,trading_mode,calls', [
|
||||||
("ftx", TradingMode.SPOT, 0),
|
("ftx", TradingMode.SPOT, 0),
|
||||||
("ftx", TradingMode.MARGIN, 0),
|
("ftx", TradingMode.MARGIN, 0),
|
||||||
("binance", TradingMode.FUTURES, 1),
|
("binance", TradingMode.FUTURES, 2),
|
||||||
("kraken", TradingMode.FUTURES, 2),
|
("kraken", TradingMode.FUTURES, 3),
|
||||||
("ftx", TradingMode.FUTURES, 8),
|
("ftx", TradingMode.FUTURES, 9),
|
||||||
])
|
])
|
||||||
def test_update_funding_fees(mocker, default_conf, exchange, trading_mode, calls):
|
def test_update_funding_fees(mocker, default_conf, exchange, trading_mode, calls):
|
||||||
|
|
||||||
patch_RPCManager(mocker)
|
patch_RPCManager(mocker)
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker, id=exchange)
|
||||||
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.update_funding_fees', return_value=True)
|
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.update_funding_fees', return_value=True)
|
||||||
|
default_conf['trading_mode'] = trading_mode
|
||||||
|
default_conf['collateral'] = 'isolated'
|
||||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
|
|
||||||
with time_machine.travel("2021-09-01 00:00:00 +00:00") as t:
|
with time_machine.travel("2021-09-01 00:00:00 +00:00") as t:
|
||||||
@ -4314,5 +4317,6 @@ def test_update_funding_fees(mocker, default_conf, exchange, trading_mode, calls
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
t.move_to("2021-09-01 08:00:00 +00:00")
|
t.move_to("2021-09-01 08:00:00 +00:00")
|
||||||
|
schedule.run_pending()
|
||||||
|
|
||||||
assert freqtrade.update_funding_fees.call_count == calls
|
assert freqtrade.update_funding_fees.call_count == calls
|
||||||
|
Loading…
Reference in New Issue
Block a user