From c0310d29d5760d8f5db27355c5ecd4df833753f1 Mon Sep 17 00:00:00 2001 From: Ichinga Samuel Date: Sun, 1 Dec 2024 23:25:01 +0100 Subject: [PATCH] add initialized attribute to Symbol class --- src/aiomql/lib/backtester.py | 3 +-- src/aiomql/lib/bot.py | 4 +--- src/aiomql/lib/symbol.py | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/aiomql/lib/backtester.py b/src/aiomql/lib/backtester.py index 2acfdb5..ab57270 100644 --- a/src/aiomql/lib/backtester.py +++ b/src/aiomql/lib/backtester.py @@ -105,8 +105,6 @@ class BackTester: Args: coroutine (Coroutine): A coroutine to be executed on_separate_thread (bool): Run the coroutine - **kwargs (dict): keyword arguments for the coroutine - Returns: """ @@ -200,6 +198,7 @@ class BackTester: "volume_real": tick.volume_real, } strategy.symbol.set_attributes(**info) + strategy.symbol.initialized = True self.executor.add_strategy(strategy=strategy) return True except Exception as err: diff --git a/src/aiomql/lib/bot.py b/src/aiomql/lib/bot.py index 8552b0e..d1fbb83 100644 --- a/src/aiomql/lib/bot.py +++ b/src/aiomql/lib/bot.py @@ -105,7 +105,6 @@ class Bot: Args: function (Callable): A function to be executed - **kwargs: Keyword arguments for the function """ self.executor.add_function(function=function, kwargs=kwargs) @@ -115,8 +114,6 @@ class Bot: Args: coroutine (Coroutine): A coroutine to be executed on_separate_thread (bool): Run the coroutine - **kwargs (dict): keyword arguments for the coroutine - Returns: """ @@ -189,6 +186,7 @@ class Bot: info["select"] = select tick = Tick(**tick._asdict()) strategy.symbol.tick = tick + strategy.symbol.initialized = True strategy.symbol.set_attributes(**info) self.executor.add_strategy(strategy=strategy) return True diff --git a/src/aiomql/lib/symbol.py b/src/aiomql/lib/symbol.py index d036763..97642d7 100644 --- a/src/aiomql/lib/symbol.py +++ b/src/aiomql/lib/symbol.py @@ -27,7 +27,7 @@ class Symbol(_Base, SymbolInfo): Full properties are on the SymbolInfo Object. Make sure Symbol is always initialized with a name argument """ - + initialized: bool tick: Tick account: Account @@ -109,6 +109,7 @@ class Symbol(_Base, SymbolInfo): info_tick = await self.info_tick() await self.book_add() if info is not None and info_tick is not None: + self.initialized = True return True logger.warning("Unable to initialize %s", self.name) return False