diff --git a/LICENSE b/LICENSE index 1e1e3c8..6a127cb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Iching Samuel +Copyright (c) 2022 Ichinga Samuel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sample_backtester.py b/examples/sample_backtester.py similarity index 100% rename from sample_backtester.py rename to examples/sample_backtester.py diff --git a/sample_bot.py b/examples/sample_bot.py similarity index 100% rename from sample_bot.py rename to examples/sample_bot.py diff --git a/src/aiomql/contrib/strategies/finger_trap.py b/src/aiomql/contrib/strategies/finger_trap.py index 888714d..061c1e6 100644 --- a/src/aiomql/contrib/strategies/finger_trap.py +++ b/src/aiomql/contrib/strategies/finger_trap.py @@ -60,8 +60,6 @@ class FingerTrap(Strategy): else: self.tracker.update(trend="ranging", snooze=self.ttf.seconds, order_type=None) - - self.tracker.update(trend="bullish") #Todo remove this line except Exception as err: logger.error(f"{err} for {self.symbol} in {self.__class__.__name__}.check_trend") self.tracker.update(snooze=self.ttf.seconds, order_type=None) @@ -80,10 +78,10 @@ class FingerTrap(Strategy): candles["cbe"] = candles.ta_lib.cross(candles.close, candles.ema, above=False) current = candles[-1] - if True or self.tracker.bullish and current.cae: + if self.tracker.bullish and current.cae: sl = find_bullish_fractal(candles).low self.tracker.update(snooze=self.ttf.seconds, order_type=OrderType.BUY, sl=sl) - elif True or self.tracker.bearish and current.cbe: + elif self.tracker.bearish and current.cbe: sl = find_bearish_fractal(candles).high self.tracker.update(snooze=self.ttf.seconds, order_type=OrderType.SELL, sl=sl) else: @@ -102,12 +100,11 @@ class FingerTrap(Strategy): await self.watch_market() if self.tracker.new is False: await self.sleep(secs=5) - return - if self.tracker.order_type is None: + elif self.tracker.order_type is None: await self.sleep(secs=self.tracker.snooze) - return - await self.trader.place_trade(order_type=self.tracker.order_type, parameters=self.parameters, - sl=self.tracker.sl) + else: + await self.trader.place_trade(order_type=self.tracker.order_type, parameters=self.parameters, + sl=self.tracker.sl) await self.sleep(secs=self.tracker.snooze) except Exception as err: logger.error(f"{err} For {self.symbol} in {self.__class__.__name__}.trade") diff --git a/src/aiomql/lib/bot.py b/src/aiomql/lib/bot.py index e61002d..99c42b4 100644 --- a/src/aiomql/lib/bot.py +++ b/src/aiomql/lib/bot.py @@ -67,9 +67,9 @@ class Bot: self.add_coroutine(coroutine=self.executor.exit) if len(self.executor.strategy_runners) == 0: - logger.warning("No strategies were added to the bot. Exiting after 10 seconds") - await asyncio.sleep(10) - raise SystemExit + logger.warning("No strategies were added to the bot. Exiting in five seconds") + await asyncio.sleep(5) + self.config.shutdown = True except Exception as err: logger.error("%s: Bot initialization failed", err) raise SystemExit @@ -93,8 +93,9 @@ class Bot: self.add_coroutine(coroutine=self.executor.exit) if len(self.executor.strategy_runners) == 0: - logger.warning("No strategies were added to the bot. Exiting after 10 seconds") - time.sleep(10) + logger.warning("No strategies were added to the bot. Exiting in 5 seconds") + time.sleep(5) + self.config.shutdown = True except Exception as err: logger.error("%s: Bot initialization failed", err) raise SystemExit