mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-19 14:58:07 +00:00
v3.18
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "aiomql"
|
name = "aiomql"
|
||||||
version = "3.17"
|
version = "3.18"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
classifiers = [
|
classifiers = [
|
||||||
|
|||||||
@@ -51,14 +51,18 @@ class Bot:
|
|||||||
Raises:
|
Raises:
|
||||||
SystemExit if sign in was not successful
|
SystemExit if sign in was not successful
|
||||||
"""
|
"""
|
||||||
init = await self.account.sign_in()
|
try:
|
||||||
if not init:
|
init = await self.account.sign_in()
|
||||||
logger.warning(f"Unable to sign in to MetaTrder 5 Terminal")
|
if not init:
|
||||||
|
logger.warning(f"Unable to sign in to MetaTrder 5 Terminal")
|
||||||
|
raise SystemExit
|
||||||
|
logger.info("Login Successful")
|
||||||
|
await self.init_symbols()
|
||||||
|
self.executor.remove_workers()
|
||||||
|
self.add_coroutine(self.config.task_queue.start)
|
||||||
|
except Exception as err:
|
||||||
|
logger.error(f"{err}. Bot initialization failed")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
logger.info("Login Successful")
|
|
||||||
await self.init_symbols()
|
|
||||||
self.executor.remove_workers()
|
|
||||||
self.add_coroutine(self.config.task_queue.start)
|
|
||||||
|
|
||||||
def add_function(self, func: Callable, **kwargs: dict):
|
def add_function(self, func: Callable, **kwargs: dict):
|
||||||
"""Add a function to the executor.
|
"""Add a function to the executor.
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class Config:
|
|||||||
record_trades: bool = True
|
record_trades: bool = True
|
||||||
filename: str = "aiomql.json"
|
filename: str = "aiomql.json"
|
||||||
win_percentage: float = 0.85
|
win_percentage: float = 0.85
|
||||||
records_dir = Path.home() / "Documents" / "Aiomql" / "Trade Records"
|
records_dir = Path(Path.home() / "Documents" / "Aiomql" / "Trade Records").mkdir(parents=True, exist_ok=True)
|
||||||
config_dir: str = ''
|
config_dir: str = ''
|
||||||
_initialize = True
|
_initialize = True
|
||||||
state: dict = {}
|
state: dict = {}
|
||||||
@@ -62,6 +62,8 @@ class Config:
|
|||||||
def __setattr__(self, key, value):
|
def __setattr__(self, key, value):
|
||||||
if key == 'root_dir':
|
if key == 'root_dir':
|
||||||
value = Path(value).absolute().resolve()
|
value = Path(value).absolute().resolve()
|
||||||
|
if key == 'records_dir':
|
||||||
|
value = self.create_records_dir(value)
|
||||||
super().__setattr__(key, value)
|
super().__setattr__(key, value)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -90,6 +92,15 @@ class Config:
|
|||||||
except Exception as _:
|
except Exception as _:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def create_records_dir(self, records_dir: str | Path):
|
||||||
|
"""Create records directory if it does not exist"""
|
||||||
|
try:
|
||||||
|
records_dir = Path(records_dir).absolute().resolve() if isinstance(records_dir, str) else records_dir
|
||||||
|
records_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
return records_dir
|
||||||
|
except Exception as _:
|
||||||
|
logger.warning("Unable to create records directory")
|
||||||
|
|
||||||
def load_config(self, file: str = None, reload: bool = True, filename: str = None, config_dir: str = ''):
|
def load_config(self, file: str = None, reload: bool = True, filename: str = None, config_dir: str = ''):
|
||||||
"""Load configuration settings from a file."""
|
"""Load configuration settings from a file."""
|
||||||
if not (self._initialize or reload):
|
if not (self._initialize or reload):
|
||||||
@@ -105,7 +116,6 @@ class Config:
|
|||||||
data = json.load(fh)
|
data = json.load(fh)
|
||||||
fh.close()
|
fh.close()
|
||||||
[setattr(self, key, value) for key, value in data.items()]
|
[setattr(self, key, value) for key, value in data.items()]
|
||||||
self.records_dir.mkdir(parents=True, exist_ok=True) if self.records_dir else ...
|
|
||||||
|
|
||||||
def account_info(self) -> dict[str, int | str]:
|
def account_info(self) -> dict[str, int | str]:
|
||||||
"""Returns Account login details as found in the config object if available
|
"""Returns Account login details as found in the config object if available
|
||||||
|
|||||||
Reference in New Issue
Block a user