Use scheduler as Object, not the automatic Singleton
This commit is contained in:
parent
bdad604fab
commit
70000b5843
@ -10,7 +10,7 @@ from threading import Lock
|
|||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
import schedule
|
from schedule import Scheduler
|
||||||
|
|
||||||
from freqtrade import __version__, constants
|
from freqtrade import __version__, constants
|
||||||
from freqtrade.configuration import validate_config_consistency
|
from freqtrade.configuration import validate_config_consistency
|
||||||
@ -109,6 +109,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
self.trading_mode = TradingMode(self.config['trading_mode'])
|
self.trading_mode = TradingMode(self.config['trading_mode'])
|
||||||
else:
|
else:
|
||||||
self.trading_mode = TradingMode.SPOT
|
self.trading_mode = TradingMode.SPOT
|
||||||
|
self._schedule = Scheduler()
|
||||||
|
|
||||||
if self.trading_mode == TradingMode.FUTURES:
|
if self.trading_mode == TradingMode.FUTURES:
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
for time_slot in range(0, 24):
|
for time_slot in range(0, 24):
|
||||||
for minutes in [0, 15, 30, 45]:
|
for minutes in [0, 15, 30, 45]:
|
||||||
t = str(time(time_slot, minutes, 2))
|
t = str(time(time_slot, minutes, 2))
|
||||||
schedule.every().day.at(t).do(update)
|
self._schedule.every().day.at(t).do(update)
|
||||||
|
|
||||||
def notify_status(self, msg: str) -> None:
|
def notify_status(self, msg: str) -> None:
|
||||||
"""
|
"""
|
||||||
@ -293,7 +294,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
logger.warning(f"Error updating Order {order.order_id} due to {e}")
|
logger.warning(f"Error updating Order {order.order_id} due to {e}")
|
||||||
|
|
||||||
if self.trading_mode == TradingMode.FUTURES:
|
if self.trading_mode == TradingMode.FUTURES:
|
||||||
schedule.run_pending()
|
self._schedule.run_pending()
|
||||||
|
|
||||||
def update_closed_trades_without_assigned_fees(self):
|
def update_closed_trades_without_assigned_fees(self):
|
||||||
"""
|
"""
|
||||||
|
@ -4303,6 +4303,6 @@ def test_update_funding_fees(mocker, default_conf, trading_mode, calls, time_mac
|
|||||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
|
|
||||||
time_machine.move_to(f"{t2} +00:00")
|
time_machine.move_to(f"{t2} +00:00")
|
||||||
schedule.run_pending()
|
freqtrade._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