Крипто -торговый бот Python
def run_bot_for_ticker(ccxt_ticker, trading_ticker):
currently_holding = False
while 1:
# STEP 1: FETCH THE DATA
ticker_data = fetch_data(ccxt_ticker)
if ticker_data is not None:
# STEP 2: COMPUTE THE TECHNICAL INDICATORS & APPLY THE TRADING STRATEGY
trade_rec_type = get_trade_recommendation(ticker_data)
print(f'{datetime.now().strftime("%d/%m/%Y %H:%M:%S")} TRADING RECOMMENDATION: {trade_rec_type}')
# STEP 3: EXECUTE THE TRADE
if (trade_rec_type == 'BUY' and not currently_holding) or \
(trade_rec_type == 'SELL' and currently_holding):
print(f'Placing {trade_rec_type} order')
trade_successful = execute_trade(trade_rec_type,trading_ticker)
currently_holding = not currently_holding if trade_successful else currently_holding
# SLEEP BEFORE REPEATING THE STEPS
time.sleep(CANDLE_DURATION_IN_MIN*60)
else:
print(f'Unable to fetch ticker data - {ccxt_ticker}. Retrying!!')
time.sleep(5)
CCXT_TICKER_NAME = 'BTC/USDT'
TRADING_TICKER_NAME = 'btcusdt'
run_bot_for_ticker(CCXT_TICKER_NAME,TRADING_TICKER_NAME)
HandsomeOldGod5355