mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-23 08:48:05 +00:00
v4
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ class FingerTrap(Strategy):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
self.tracker.update(trend="ranging", snooze=self.ttf.seconds, order_type=None)
|
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:
|
except Exception as err:
|
||||||
logger.error(f"{err} for {self.symbol} in {self.__class__.__name__}.check_trend")
|
logger.error(f"{err} for {self.symbol} in {self.__class__.__name__}.check_trend")
|
||||||
self.tracker.update(snooze=self.ttf.seconds, order_type=None)
|
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)
|
candles["cbe"] = candles.ta_lib.cross(candles.close, candles.ema, above=False)
|
||||||
current = candles[-1]
|
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
|
sl = find_bullish_fractal(candles).low
|
||||||
self.tracker.update(snooze=self.ttf.seconds, order_type=OrderType.BUY, sl=sl)
|
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
|
sl = find_bearish_fractal(candles).high
|
||||||
self.tracker.update(snooze=self.ttf.seconds, order_type=OrderType.SELL, sl=sl)
|
self.tracker.update(snooze=self.ttf.seconds, order_type=OrderType.SELL, sl=sl)
|
||||||
else:
|
else:
|
||||||
@@ -102,12 +100,11 @@ class FingerTrap(Strategy):
|
|||||||
await self.watch_market()
|
await self.watch_market()
|
||||||
if self.tracker.new is False:
|
if self.tracker.new is False:
|
||||||
await self.sleep(secs=5)
|
await self.sleep(secs=5)
|
||||||
return
|
elif self.tracker.order_type is None:
|
||||||
if self.tracker.order_type is None:
|
|
||||||
await self.sleep(secs=self.tracker.snooze)
|
await self.sleep(secs=self.tracker.snooze)
|
||||||
return
|
else:
|
||||||
await self.trader.place_trade(order_type=self.tracker.order_type, parameters=self.parameters,
|
await self.trader.place_trade(order_type=self.tracker.order_type, parameters=self.parameters,
|
||||||
sl=self.tracker.sl)
|
sl=self.tracker.sl)
|
||||||
await self.sleep(secs=self.tracker.snooze)
|
await self.sleep(secs=self.tracker.snooze)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"{err} For {self.symbol} in {self.__class__.__name__}.trade")
|
logger.error(f"{err} For {self.symbol} in {self.__class__.__name__}.trade")
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ class Bot:
|
|||||||
self.add_coroutine(coroutine=self.executor.exit)
|
self.add_coroutine(coroutine=self.executor.exit)
|
||||||
|
|
||||||
if len(self.executor.strategy_runners) == 0:
|
if len(self.executor.strategy_runners) == 0:
|
||||||
logger.warning("No strategies were added to the bot. Exiting after 10 seconds")
|
logger.warning("No strategies were added to the bot. Exiting in five seconds")
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(5)
|
||||||
raise SystemExit
|
self.config.shutdown = True
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error("%s: Bot initialization failed", err)
|
logger.error("%s: Bot initialization failed", err)
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
@@ -93,8 +93,9 @@ class Bot:
|
|||||||
self.add_coroutine(coroutine=self.executor.exit)
|
self.add_coroutine(coroutine=self.executor.exit)
|
||||||
|
|
||||||
if len(self.executor.strategy_runners) == 0:
|
if len(self.executor.strategy_runners) == 0:
|
||||||
logger.warning("No strategies were added to the bot. Exiting after 10 seconds")
|
logger.warning("No strategies were added to the bot. Exiting in 5 seconds")
|
||||||
time.sleep(10)
|
time.sleep(5)
|
||||||
|
self.config.shutdown = True
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error("%s: Bot initialization failed", err)
|
logger.error("%s: Bot initialization failed", err)
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|||||||
Reference in New Issue
Block a user