Skip to content

Instantly share code, notes, and snippets.

@fatherofluqmaan
Last active August 18, 2021 10:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatherofluqmaan/f3e674eebfea5ef2662bf6b06f597fdd to your computer and use it in GitHub Desktop.
Save fatherofluqmaan/f3e674eebfea5ef2662bf6b06f597fdd to your computer and use it in GitHub Desktop.
custom coding from the Strategy.py file. The code is only that which has been changed
{
"coinbasepro" : {
"api_url" : "https://api.pro.coinbase.com",
"api_key_file" : "coinbase.key",
"config" : {
"live" : 0,
"sellatloss" : 0,
"sellatresistance" : 0,
"buymaxsize" : 50,
"trailingstoploss" : -1.5,
"disablebullonly" : 1,
"disablebuynearhigh" : 0,
"disablebuymacd" : 1,
"disablebuyobv" : 0,
"disablebuyelderray" : 0,
"disablefailsafefibonaccilow" : 1,
"disableprofitbankreversal" : 1,
"disabletracker" : 1,
"autorestart" : 1,
"graphs" : 0,
"verbose" : 0,
"stats" : 0
}
}
}
2021-08-06 19:05:20-'gran:3600'--1INCH-EUR Margin : 5.5886%
2021-08-06 19:05:20-'gran:3600'--1INCH-GBP Margin : 5.4037%
2021-08-06 19:05:20-'gran:3600'--1INCH-USD Margin : 6.2945%
2021-08-06 19:05:20-'gran:3600'--AAVE-EUR Margin : 6.5140%
2021-08-06 19:05:20-'gran:3600'--AAVE-GBP Margin : 7.6709%
2021-08-06 19:05:20-'gran:3600'--AAVE-USD Margin : 19.8301%
2021-08-06 19:05:20-'gran:3600'--ADA-ETH Margin : -10.8460%
2021-08-06 19:05:20-'gran:3600'--ADA-EUR Margin : 8.9829%
2021-08-06 19:05:20-'gran:3600'--ADA-GBP Margin : 8.9639%
2021-08-06 19:05:20-'gran:3600'--ADA-USD Margin : 10.5291%
2021-08-06 19:05:20-'gran:3600'--ADA-USDC Margin : 10.4165%
2021-08-06 19:05:20-'gran:3600'--ALGO-USD Margin : 7.1416%
2021-08-06 19:05:20-'gran:3600'--AMP-USD Margin : 1.4409%
2021-08-06 19:05:20-'gran:3600'--ANKR-EUR Margin : 58.4682%
2021-08-06 19:05:20-'gran:3600'--ANKR-GBP Margin : 54.4286%
2021-08-06 19:05:20-'gran:3600'--ANKR-USD Margin : 57.5210%
2021-08-06 19:05:20-'gran:3600'--ATOM-BTC Margin : 5.7373%
2021-08-06 19:05:20-'gran:3600'--ATOM-USD Margin : 6.5611%
2021-08-06 19:05:20-'gran:3600'--BAL-BTC Margin : -11.1487%
2021-08-06 19:05:20-'gran:3600'--BAL-USD Margin : 17.6662%
2021-08-06 19:05:20-'gran:3600'--BAND-BTC Margin : 6.4078%
2021-08-06 19:05:20-'gran:3600'--BAND-EUR Margin : 11.9518%
2021-08-06 19:05:20-'gran:3600'--BAND-GBP Margin : 13.4908%
2021-08-06 19:05:20-'gran:3600'--BAND-USD Margin : 11.9591%
2021-08-06 19:05:20-'gran:3600'--BAT-ETH Margin : 7.3053%
2021-08-06 19:05:20-'gran:3600'--BAT-EUR Margin : 17.1194%
2021-08-06 19:05:20-'gran:3600'--BAT-USD Margin : 5.1580%
2021-08-06 19:05:20-'gran:3600'--BAT-USDC Margin : 13.7360%
2021-08-06 19:05:20-'gran:3600'--BCH-EUR Margin : 10.9907%
2021-08-06 19:05:20-'gran:3600'--BCH-GBP Margin : 5.1468%
2021-08-06 19:05:20-'gran:3600'--BCH-USD Margin : 15.2339%
2021-08-06 19:05:20-'gran:3600'--BNT-EUR Margin : 17.9804%
2021-08-06 19:05:20-'gran:3600'--BNT-GBP Margin : 11.4065%
2021-08-06 19:05:20-'gran:3600'--BNT-USD Margin : 11.3422%
2021-08-06 19:05:20-'gran:3600'--BTC-EUR Margin : 16.6203%
2021-08-06 19:05:20-'gran:3600'--BTC-GBP Margin : 15.5311%
2021-08-06 19:05:20-'gran:3600'--BTC-USD Margin : 17.8365%
2021-08-06 19:05:20-'gran:3600'--BTC-USDC Margin : 17.8723%
2021-08-06 19:05:20-'gran:3600'--BTC-USDT Margin : 18.0595%
2021-08-06 19:05:20-'gran:3600'--CGLD-EUR Margin : 5.9293%
2021-08-06 19:05:20-'gran:3600'--CHZ-EUR Margin : 6.2602%
2021-08-06 19:05:20-'gran:3600'--CHZ-GBP Margin : 6.2772%
2021-08-06 19:05:20-'gran:3600'--CHZ-USD Margin : 6.5908%
2021-08-06 19:05:20-'gran:3600'--CLV-GBP Margin : 29.0429%
2021-08-06 19:05:20-'gran:3600'--CLV-USD Margin : 17.8064%
2021-08-06 19:05:20-'gran:3600'--CLV-USDT Margin : 7.4884%
2021-08-06 19:05:20-'gran:3600'--COMP-BTC Margin : 14.5567%
2021-08-06 19:05:20-'gran:3600'--COMP-USD Margin : 8.2699%
2021-08-06 19:05:20-'gran:3600'--CRV-EUR Margin : 13.7718%
2021-08-06 19:05:20-'gran:3600'--CRV-GBP Margin : 12.5264%
2021-08-06 19:05:20-'gran:3600'--CRV-USD Margin : 6.2126%
2021-08-06 19:05:20-'gran:3600'--CTSI-USD Margin : 14.2355%
2021-08-06 19:05:20-'gran:3600'--CVC-USDC Margin : 5.4733%
2021-08-06 19:05:20-'gran:3600'--DASH-USD Margin : 9.7840%
2021-08-06 19:05:20-'gran:3600'--DNT-USDC Margin : 5.7237%
2021-08-06 19:05:20-'gran:3600'--DOGE-USD Margin : 9.7081%
2021-08-06 19:05:20-'gran:3600'--DOGE-USDT Margin : 10.8403%
2021-08-06 19:05:20-'gran:3600'--DOT-BTC Margin : 18.2761%
2021-08-06 19:05:20-'gran:3600'--DOT-EUR Margin : 27.5591%
2021-08-06 19:05:20-'gran:3600'--DOT-GBP Margin : 15.3918%
2021-08-06 19:05:20-'gran:3600'--DOT-USD Margin : 28.5158%
2021-08-06 19:05:20-'gran:3600'--DOT-USDT Margin : 28.0322%
2021-08-06 19:05:20-'gran:3600'--ENJ-USD Margin : 5.2545%
2021-08-06 19:05:20-'gran:3600'--EOS-EUR Margin : 5.3460%
2021-08-06 19:05:20-'gran:3600'--EOS-USD Margin : 5.6747%
2021-08-06 19:05:20-'gran:3600'--ETC-EUR Margin : 7.3028%
2021-08-06 19:05:20-'gran:3600'--ETC-GBP Margin : 7.2648%
2021-08-06 19:05:20-'gran:3600'--ETC-USD Margin : 7.2779%
2021-08-06 19:05:20-'gran:3600'--ETH-DAI Margin : 17.6186%
2021-08-06 19:05:20-'gran:3600'--ETH-EUR Margin : 16.3495%
2021-08-06 19:05:20-'gran:3600'--ETH-GBP Margin : 17.7202%
2021-08-06 19:05:20-'gran:3600'--ETH-USD Margin : 17.5565%
2021-08-06 19:05:20-'gran:3600'--ETH-USDC Margin : 17.2684%
2021-08-06 19:05:20-'gran:3600'--ETH-USDT Margin : 17.7093%
2021-08-06 19:05:20-'gran:3600'--FET-USD Margin : 12.3678%
2021-08-06 19:05:20-'gran:3600'--FIL-BTC Margin : 5.7358%
2021-08-06 19:05:20-'gran:3600'--FIL-EUR Margin : 12.8276%
2021-08-06 19:05:20-'gran:3600'--FIL-GBP Margin : 11.2325%
2021-08-06 19:05:20-'gran:3600'--FIL-USD Margin : 13.7727%
2021-08-06 19:05:20-'gran:3600'--FORTH-BTC Margin : -15.8947%
2021-08-06 19:05:20-'gran:3600'--FORTH-EUR Margin : 9.1285%
2021-08-06 19:05:20-'gran:3600'--FORTH-GBP Margin : 7.8909%
2021-08-06 19:05:20-'gran:3600'--FORTH-USD Margin : 7.4843%
2021-08-06 19:05:20-'gran:3600'--GRT-EUR Margin : 7.8825%
2021-08-06 19:05:20-'gran:3600'--GRT-GBP Margin : 6.1489%
2021-08-06 19:05:20-'gran:3600'--GRT-USD Margin : 7.0124%
2021-08-06 19:05:20-'gran:3600'--GTC-USD Margin : 33.3219%
2021-08-06 19:05:20-'gran:3600'--ICP-USD Margin : -16.8558%
2021-08-06 19:05:20-'gran:3600'--ICP-USDT Margin : -17.0511%
2021-08-06 19:05:20-'gran:3600'--KNC-USD Margin : 10.8306%
2021-08-06 19:05:20-'gran:3600'--LINK-BTC Margin : 12.1688%
2021-08-06 19:05:20-'gran:3600'--LINK-ETH Margin : 13.8419%
2021-08-06 19:05:20-'gran:3600'--LINK-EUR Margin : 32.3667%
2021-08-06 19:05:20-'gran:3600'--LINK-GBP Margin : 40.5802%
2021-08-06 19:05:20-'gran:3600'--LINK-USD Margin : 12.7266%
2021-08-06 19:05:20-'gran:3600'--LOOM-USDC Margin : 23.6151%
2021-08-06 19:05:20-'gran:3600'--LPT-USD Margin : 19.5913%
2021-08-06 19:05:20-'gran:3600'--LRC-USD Margin : 6.3962%
2021-08-06 19:05:20-'gran:3600'--LTC-EUR Margin : 11.4559%
2021-08-06 19:05:20-'gran:3600'--LTC-GBP Margin : 10.7420%
2021-08-06 19:05:20-'gran:3600'--LTC-USD Margin : 5.0593%
2021-08-06 19:05:20-'gran:3600'--MANA-ETH Margin : -15.1408%
2021-08-06 19:05:20-'gran:3600'--MASK-EUR Margin : 37.5328%
2021-08-06 19:05:20-'gran:3600'--MASK-GBP Margin : 40.3004%
2021-08-06 19:05:20-'gran:3600'--MASK-USD Margin : 11.7313%
2021-08-06 19:05:20-'gran:3600'--MASK-USDT Margin : 29.7817%
2021-08-06 19:05:20-'gran:3600'--MATIC-EUR Margin : 7.6311%
2021-08-06 19:05:20-'gran:3600'--MATIC-GBP Margin : 11.6159%
2021-08-06 19:05:20-'gran:3600'--MATIC-USD Margin : 11.9208%
2021-08-06 19:05:20-'gran:3600'--MIR-EUR Margin : 6.8021%
2021-08-06 19:05:20-'gran:3600'--MIR-USD Margin : 6.9521%
2021-08-06 19:05:20-'gran:3600'--MKR-USD Margin : 16.6361%
2021-08-06 19:05:20-'gran:3600'--MLN-USD Margin : 5.7465%
2021-08-06 19:05:20-'gran:3600'--NKN-USD Margin : 5.0283%
2021-08-06 19:05:20-'gran:3600'--NMR-BTC Margin : 27.7870%
2021-08-06 19:05:20-'gran:3600'--NMR-EUR Margin : 27.0712%
2021-08-06 19:05:20-'gran:3600'--NMR-GBP Margin : 23.6743%
2021-08-06 19:05:20-'gran:3600'--NMR-USD Margin : 29.2229%
2021-08-06 19:05:20-'gran:3600'--NU-EUR Margin : 5.3971%
2021-08-06 19:05:20-'gran:3600'--NU-GBP Margin : 7.2798%
2021-08-06 19:05:20-'gran:3600'--NU-USD Margin : 5.4475%
2021-08-06 19:05:20-'gran:3600'--OGN-USD Margin : 6.0013%
2021-08-06 19:05:20-'gran:3600'--OMG-EUR Margin : 5.4784%
2021-08-06 19:05:20-'gran:3600'--OMG-GBP Margin : 9.1772%
2021-08-06 19:05:20-'gran:3600'--OMG-USD Margin : 5.7465%
2021-08-06 19:05:20-'gran:3600'--QNT-USD Margin : 30.9567%
2021-08-06 19:05:20-'gran:3600'--REN-USD Margin : 8.8487%
2021-08-06 19:05:20-'gran:3600'--REP-BTC Margin : -9.5022%
2021-08-06 19:05:20-'gran:3600'--REP-USD Margin : -15.1577%
2021-08-06 19:05:20-'gran:3600'--RLC-USD Margin : 43.1236%
2021-08-06 19:05:20-'gran:3600'--RLY-EUR Margin : 21.6418%
2021-08-06 19:05:20-'gran:3600'--RLY-GBP Margin : 16.8330%
2021-08-06 19:05:20-'gran:3600'--RLY-USD Margin : 20.9559%
2021-08-06 19:05:20-'gran:3600'--RLY-USDT Margin : 21.0214%
2021-08-06 19:05:20-'gran:3600'--SKL-EUR Margin : 29.4982%
2021-08-06 19:05:20-'gran:3600'--SKL-GBP Margin : 33.0297%
2021-08-06 19:05:20-'gran:3600'--SKL-USD Margin : 29.7173%
2021-08-06 19:05:20-'gran:3600'--SNX-EUR Margin : 12.2610%
2021-08-06 19:05:20-'gran:3600'--SNX-GBP Margin : 12.2211%
2021-08-06 19:05:20-'gran:3600'--SNX-USD Margin : 13.3066%
2021-08-06 19:05:20-'gran:3600'--SOL-BTC Margin : 8.5385%
2021-08-06 19:05:20-'gran:3600'--SOL-EUR Margin : 5.0843%
2021-08-06 19:05:20-'gran:3600'--SOL-GBP Margin : 6.4726%
2021-08-06 19:05:20-'gran:3600'--SOL-USD Margin : 5.2843%
2021-08-06 19:05:20-'gran:3600'--SOL-USDT Margin : 6.8897%
2021-08-06 19:05:20-'gran:3600'--STORJ-USD Margin : 30.1087%
2021-08-06 19:05:20-'gran:3600'--SUSHI-ETH Margin : 6.7964%
2021-08-06 19:05:20-'gran:3600'--SUSHI-EUR Margin : 5.0587%
2021-08-06 19:05:20-'gran:3600'--SUSHI-USD Margin : 21.4124%
2021-08-06 19:05:20-'gran:3600'--TRB-BTC Margin : 8.2771%
2021-08-06 19:05:20-'gran:3600'--TRB-USD Margin : 16.5591%
2021-08-06 19:05:20-'gran:3600'--UMA-EUR Margin : 5.6529%
2021-08-06 19:05:20-'gran:3600'--UMA-GBP Margin : 5.8832%
2021-08-06 19:05:20-'gran:3600'--UMA-USD Margin : 5.0429%
2021-08-06 19:05:20-'gran:3600'--UNI-BTC Margin : 8.2700%
2021-08-06 19:05:20-'gran:3600'--UNI-USD Margin : 8.7472%
2021-08-06 19:05:20-'gran:3600'--WBTC-USD Margin : 17.6533%
2021-08-06 19:05:20-'gran:3600'--XLM-EUR Margin : 6.6374%
2021-08-06 19:05:20-'gran:3600'--XLM-USD Margin : 5.1117%
2021-08-06 19:05:20-'gran:3600'--XTZ-EUR Margin : 5.8926%
2021-08-06 19:05:20-'gran:3600'--XTZ-GBP Margin : 5.1123%
2021-08-06 19:05:20-'gran:3600'--XTZ-USD Margin : 5.1431%
2021-08-06 19:05:20-'gran:3600'--YFI-BTC Margin : -8.2711%
2021-08-06 19:05:20-'gran:3600'--YFI-USD Margin : 15.7667%
2021-08-06 19:05:20-'gran:3600'--ZEC-BTC Margin : 6.7428%
2021-08-06 19:05:20-'gran:3600'--ZEC-USD Margin : 13.2849%
2021-08-06 19:05:20-'gran:3600'--ZEC-USDC Margin : 6.2656%
2021-08-06 19:05:20-'gran:3600'--ZRX-EUR Margin : 17.6604%
2021-08-06 19:05:20-'gran:3600'--ZRX-USD Margin : 18.3575%
#!/usr/bin/env bash
rm -f short-simbot-run.txt
dte=$(date +"%Y-%m-%d %T")
dt=$(date +"%Y-%m-%d")
c=$(< "pairs.txt" wc -l)
a="$c"
simst='2021-07-25'
simen='2021-08-05'
mkdir -p raw-sim-outputs
echo "Enter required granularity (86400,21600,3600,900)"
read -r grn
echo "Enter suffix for file outputs (run1,cc,robin,moon,HODL)"
read -r nme
echo "[+] Current config set"
echo -e "\n"
cat config.json | grep -B30 '.telegram' | awk -F'\"telegram' '{print $1}'
sleep 3
echo "[+] Running simulations, total pairs count: $c"
while IFS= read -r PP; do
python3 pycryptobot.py --sim fast-sample --exchange coinbasepro --simstartdate "$simst" --simenddate "$simen" --granularity "$grn" --market "$PP" --disabletelegram 2> multi-simbot-run-"$nme".> cat multi-simbot-run-"$nme".txt | grep "Margin.*" | sed -e "s@^@$dte-'gran:$grn'--$PP @" >> multi-simbot-results-"$nme".txt
cat multi-simbot-run-"$nme".txt > "./raw-sim-outputs/$PP-$dt-rawout-$nme.txt"
let "--c"
echo "Simulations remaining: $c"
done < pairs.txt
sort -u multi-simbot-results-"$nme".txt >> multi-sim-results-"$nme"_"$dt".txt
fte=$(date +"%Y-%m-%d %T")
echo -e "$dte: All $a multi-simulations complete.\nDate Range: $simst to $simen, file suffix is $nme" | notify
from datetime import datetime
from pandas import DataFrame
from models.PyCryptoBot import PyCryptoBot
from models.AppState import AppState
from models.helper.LogHelper import Logger
class Strategy():
def __init__(self, app: PyCryptoBot=None, state: AppState=AppState, df: DataFrame=DataFrame, iterations: int=0) -> None:
if not isinstance(df, DataFrame):
raise TypeError("'df' not a Pandas dataframe")
if len(df) == 0:
raise ValueError("'df' is empty")
self._action = 'WAIT'
self.app = app
self.state = state
self._df = df
self._df_last = app.getInterval(df, iterations)
def isBuySignal(self, now: datetime = datetime.today().strftime('%Y-%m-%d %H:%M:%S'), price: float=0.0) -> bool:
# required technical indicators or candle sticks for buy signal strategy
required_indicators = [ 'ema12gtema26co', 'macdgtsignal', 'goldencross', 'obv_pc', 'eri_buy' ]
for indicator in required_indicators:
if indicator not in self._df_last:
raise AttributeError(f"'{indicator}' not in Pandas dataframe")
# buy signal exclusion (if disabled, do not buy within 3% of the dataframe close high)
if self.state.last_action == 'SELL' and self.app.disableBuyNearHigh() is True and (price > (self._df['close'].max() * 0.97)):
log_text = str(now) + ' | ' + self.app.getMarket() + ' | ' + self.app.printGranularity() + ' | Ignoring Buy Signal (price ' + str(price) + ' within 3% of high ' + str(self._df['close'].max()) + ')'
Logger.warning(log_text)
return False
# if EMA, MACD are disabled, do not buy
if self.app.disableBuyEMA() and self.app.disableBuyMACD() :
log_text = str(now) + ' | ' + self.app.getMarket() + ' | ' + self.app.printGranularity() + ' | EMA, MACD indicators are disabled '
Logger.warning(log_text)
return False
# criteria for a buy signal 1
if (bool(self._df_last['ema12gtema26co'].values[0]) is True or self.app.disableBuyEMA())\
and (bool(self._df_last['macdgtsignal'].values[0]) is True or self.app.disableBuyMACD()) \
and (bool(self._df_last['goldencross'].values[0]) is True or self.app.disableBullOnly()) \
and (float(self._df_last['obv_pc'].values[0]) > -5 or self.app.disableBuyOBV()) \
and (bool(self._df_last['eri_buy'].values[0]) is True or self.app.disableBuyElderRay()) \
and self.state.last_action != 'BUY': # required for all strategies
Logger.debug('*** Buy Signal ***')
for indicator in required_indicators:
Logger.debug(f'{indicator}: {self._df_last[indicator].values[0]}')
Logger.debug(f'last_action: {self.state.last_action}')
return True
# criteria for buy signal 2 (optionally add additional buy singals)
elif (bool(self._df_last['ema12gtema26co'].values[0]) is True or self.app.disableBuyEMA())\
and bool(self._df_last['macdgtsignalco'].values[0]) is True \
and (bool(self._df_last['goldencross'].values[0]) is True or self.app.disableBullOnly()) \
and (float(self._df_last['obv_pc'].values[0]) > -5 or self.app.disableBuyOBV()) \
and (bool(self._df_last['eri_buy'].values[0]) is True or self.app.disableBuyElderRay()) \
and self.state.last_action != 'BUY': # required for all strategies
Logger.debug('*** Buy Signal ***')
for indicator in required_indicators:
Logger.debug(f'{indicator}: {self._df_last[indicator].values[0]}')
Logger.debug(f'last_action: {self.state.last_action}')
return True
return False
def isSellSignal(self) -> bool:
# required technical indicators or candle sticks for buy signal strategy
required_indicators = [ 'ema12ltema26co', 'macdltsignal' ]
for indicator in required_indicators:
if indicator not in self._df_last:
raise AttributeError(f"'{indicator}' not in Pandas dataframe")
# criteria for a sell signal 1
if bool(self._df_last['ema12ltema26co'].values[0]) is True \
and (bool(self._df_last['macdltsignal'].values[0]) is True or self.app.disableBuyMACD()) \
and self.state.last_action not in ['', 'SELL']:
Logger.debug('*** Sell Signal ***')
for indicator in required_indicators:
Logger.debug(f'{indicator}: {self._df_last[indicator].values[0]}')
Logger.debug(f'last_action: {self.state.last_action}')
return True
return False
def isSellTrigger(self, price: float=0.0, price_exit: float=0.0, margin: float=0.0, change_pcnt_high: float=0.0, obv_pc: float=0.0, macdltsignal: bool=False) -> bool:
# loss failsafe sell at fibonacci band
if self.app.disableFailsafeFibonacciLow() is False and self.app.allowSellAtLoss() and self.app.sellLowerPcnt() is None and self.state.fib_low > 0 and self.state.fib_low >= float(price):
log_text = '! Loss Failsafe Triggered (Fibonacci Band: ' + str(self.state.fib_low) + ')'
Logger.warning(log_text)
self.app.notifyTelegram(self.app.getMarket() + ' (' + self.app.printGranularity() + ') ' + log_text)
return True
# loss failsafe sell at trailing_stop_loss - ### CUSTOM EDITS 2021-08-06 ###
# "Changes to the criteria to only allow '--trailingstoploss' to be active when margin is above 3% or below -15%, but not in between, suggested by AP"
if self.app.trailingStopLoss() != None and change_pcnt_high < self.app.trailingStopLoss() and (self.app.allowSellAtLoss() or margin > 5 or margin < -15):
log_text = '! Trailing Stop Loss Triggered (< ' + str(self.app.trailingStopLoss()) + '%)'
Logger.warning(log_text)
self.app.notifyTelegram(self.app.getMarket() + ' (' + self.app.printGranularity() + ') ' + log_text)
return True
# loss failsafe sell at sell_lower_pcnt
elif self.app.disableFailsafeLowerPcnt() is False and self.app.allowSellAtLoss() and self.app.sellLowerPcnt() != None and margin < self.app.sellLowerPcnt():
log_text = '! Loss Failsafe Triggered (< ' + str(self.app.sellLowerPcnt()) + '%)'
Logger.warning(log_text)
self.app.notifyTelegram(self.app.getMarket() + ' (' + self.app.printGranularity() + ') ' + log_text)
return True
# profit bank at sell_upper_pcnt
if self.app.disableProfitbankUpperPcnt() is False and self.app.sellUpperPcnt() != None and margin > self.app.sellUpperPcnt():
log_text = '! Profit Bank Triggered (> ' + str(self.app.sellUpperPcnt()) + '%)'
Logger.warning(log_text)
self.app.notifyTelegram(self.app.getMarket() + ' (' + self.app.printGranularity() + ') ' + log_text)
return True
# profit bank when strong reversal detected
if self.app.disableProfitbankReversal() is False and margin > 3 and obv_pc < 0 and macdltsignal is True:
log_text = '! Profit Bank Triggered (Strong Reversal Detected)'
Logger.warning(log_text)
self.app.notifyTelegram(self.app.getMarket() + ' (' + self.app.printGranularity() + ') ' + log_text)
return True
# profit bank when strong reversal detected
if self.app.sellAtResistance() is True and margin >= 2 and price > 0 and price != price_exit:
log_text = '! Profit Bank Triggered (Selling At Resistance)'
Logger.warning(log_text)
if not (not self.app.allowSellAtLoss() and margin <= 0):
self.app.notifyTelegram(self.app.getMarket() + ' (' + self.app.printGranularity() + ') ' + log_text)
return True
return False
def isWaitTrigger(self, margin: float=0.0):
# configuration specifies to not sell at a loss ### CUSTOM EDITS 2021-08-06 ###
# Changes to the critera to only allow a sell signal to trigger a sale if the margin is under -10% and over 5%, suggested by AP"
if self.state.action == 'SELL' and not self.app.allowSellAtLoss() and (margin <= 5 and margin > -10):
log_text = '! Ignore Sell Signal (No Sell At Loss)'
Logger.warning(log_text)
return True
return False
def getAction(self):
if self.isBuySignal():
return 'BUY'
elif self.isSellSignal():
return 'SELL'
else:
return 'WAIT'
# COMMENTARY ON CHANGES: The two combined should only allow a maximum loss of 15%. If you are running simulations, remember to check the raw output to see where your margin was high and low, also check that all BUYS have SOLD, if not then the last line of the sim is important to show whether the hold has a positive or negative margin.
@NeverVane
Copy link

the config.json file miss a '}' at the end

@fatherofluqmaan
Copy link
Author

the config.json file miss a '}' at the end

Thanks.

Its because i have my Telegram below it, so i've just cut it short and forgot to replace the missing curly brace, appreciate the spot!

@aascham
Copy link

aascham commented Aug 18, 2021

When margin is in between 3-5% and trailing stop loss triggers there is no sell? Just get spammed with messages from the telegram bot. Should the 3 and the 5 in trailingStopLoss and isWaitTrigger not be swapped?

@fatherofluqmaan
Copy link
Author

When margin is in between 3-5% and trailing stop loss triggers there is no sell? Just get spammed with messages from the telegram bot. Should the 3 and the 5 in trailingStopLoss and isWaitTrigger not be swapped?

Not particularly, I would just raise the trigger to 5 rather than 3, I did a lot of testing and this would potentially just be due to this, ill change it in this, but I have other posts now that are more up to date.

However, we have been working with Mark Whittle to get some dev done in the bot to give us the configurable options that should be updating very soon, this will allow all of this to be configured rather than hard coded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment