diff --git a/pyproject.toml b/pyproject.toml index c8a3cba..225edb9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] name = "aiomql" -version = "3.19" +version = "3.20" readme = "README.md" requires-python = ">=3.11" classifiers = [ diff --git a/src/aiomql/__init__.py b/src/aiomql/__init__.py index 5a2dc45..996569f 100644 --- a/src/aiomql/__init__.py +++ b/src/aiomql/__init__.py @@ -15,5 +15,5 @@ from .history import History from .trader import Trader from .terminal import Terminal from .sessions import Session, Sessions -from .utils import dict_to_string, round_off +from .utils import dict_to_string, round_off, find_bearish_fractal, find_bullish_fractal from .lib import * diff --git a/src/aiomql/lib/strategies/finger_trap.py b/src/aiomql/lib/strategies/finger_trap.py index 57c5066..f76d8a8 100644 --- a/src/aiomql/lib/strategies/finger_trap.py +++ b/src/aiomql/lib/strategies/finger_trap.py @@ -74,13 +74,11 @@ class FingerTrap(Strategy): trend = self.ttf.time // self.etf.time bull_trend = cae.iloc[-trend:] bear_trend = cbe.iloc[-trend:] - count = 24 * 60 * 60 // self.etf.time - last_24 = candles[-count:] if self.tracker.bullish and any(bull_trend): - sl = getattr(find_bullish_fractal(candles), 'low', last_24.low.min()) + sl = find_bullish_fractal(candles).low self.tracker.update(snooze=self.ttf.time, order_type=OrderType.BUY, sl=sl) elif self.tracker.bearish and any(bear_trend): - sl = getattr(find_bearish_fractal(candles), 'high', last_24.high.max()) + sl = find_bearish_fractal(candles).high self.tracker.update(snooze=self.ttf.time, order_type=OrderType.SELL, sl=sl) else: self.tracker.update(snooze=self.etf.time, order_type=None) @@ -96,7 +94,7 @@ class FingerTrap(Strategy): async def trade(self): logger.info(f"Trading {self.symbol}") async with self.sessions as sess: - await self.sleep(self.etf.time) + await self.sleep(self.ttf.time) while True: await sess.check() try: diff --git a/src/aiomql/result.py b/src/aiomql/result.py index 25a1cc6..202ca10 100644 --- a/src/aiomql/result.py +++ b/src/aiomql/result.py @@ -1,6 +1,7 @@ import csv from logging import getLogger from threading import RLock +from pathlib import Path from .core import Config from .core.models import OrderSendResult @@ -30,7 +31,8 @@ class Result: self.parameters = parameters or {} self.result = result self.name = name or parameters.get('name', 'Trades') - self.config.create_records_dir() + if not Path(self.config.records_dir).exists(): + Path(self.config.records_dir).mkdir(parents=True, exist_ok=True) def get_data(self) -> dict: res = self.result.get_dict(exclude={'retcode', 'comment', 'retcode_external', 'request_id', 'request'})