Hello again i am one last step before the bot launch i must to define 2 parameters (gather_data and get states) but i cant because when i go to define i block the other commands please if some know to help me
the not defined commands are in 28 and 29 lines df = gather_data(symbols,48)
states = get_states(df,symbols)
symbols = ['BTC','ETH','LTC']
start_n_hours_ago = 48
balance_unit = 'USDT'
first = True
BUY_AMOUNT_USDT = 300
precision = {}
for symbol in symbols:
precision[symbol] = client.get_symbol_info(f'{symbol}USDT')['quotePrecision']
from os import truncate
while True:
if (datetime.now().second % 10 == 0) or first:
if (datetime.now().minute == 0 and datetime.now().second == 10) or first:
# refresh data
first = False
df = gather_data(symbols,48)
states = get_states(df,symbols)
print('Current state of the market:')
print(states)
try:
print('\n')
if balance_unit == 'USDT': # looking to buy
for symbol in symbols:
ask_price = float(client.get_orderbook_ticker(symbol = f'{symbol}USDT')['askPrice'])
lower_band = df[f'{symbol}_lower_band'].iloc[-1]
print(f'{symbol}: ask price {ask_price} | lower_band {lower_band}')
if ask_price < lower_band and states[symbol] == 'inside': #buy signal
##########################
buy_order = client.order_limit_buy(symbol=f'{symbol}USDT',
quantity=truncate(BUY_AMOUNT_USDT / ask_price, precision[symbol]),
price=ask_price)
start = datetime.now()
while True:
time.sleep(1)
buy_order = client.get_order(symbol=buy_order['symbol'], orderId=buy_order['orderId'])
# resolve buy order
seconds_since_buy = (datetime.now() - start).seconds
print(seconds_since_buy)
if float(buy_order['executedQty']) == 0 and seconds_since_buy > 60*60:
# no fill
client.cancel_order(symbol=buy_order['symbol'], orderId=buy_order['orderId'])
break
if float(buy_order['executedQty']) != 0 and float(buy_order['executedQty']) != float(buy_order['origQty']) and seconds_since_buy > 60*60:
#partial fill
client.cancel_order(symbol=buy_order['symbol'], orderId=buy_order['orderId'])
balance_unit = symbol
break
if float(buy_order['executedQty']) == float(buy_order['origQty']):
# complety filled
balance_unit = symbol
break
#########################
balance_unit = symbol
break
if balance_unit != 'USDT': # looking to sell
bid_price = float(client.get_orderbook_ticker(symbol = f'{balance_unit}USDT') ['bidPrice'])
upper_band = df[f'{balance_unit}_upper_band'].iloc[-1]
if bid_price > upper_band and states[balance_unit] == 'inside': # sell signal
#######################
client.order_market_sell(symbol=buy_order['symbol'],
quantity=truncate(float(buy_order['executedQty']), precision[buy_order['symbol'].replace('USDT','')]))
print('sell')
#######################
balance_unit = 'USDT'
time.sleep(1)
except Client.BinanceAPIException as e:
print (e.status_code)
print (e.message)
if someone know to tell me please
thanks in advance