mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-17 05:48:07 +00:00
v3.20
This commit is contained in:
@@ -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 *
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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'})
|
||||
|
||||
Reference in New Issue
Block a user