import bitmex import time from configuration import * from strategy import Strategy from trader import Trader if __name__ == "__main__": client = bitmex.bitmex(test=TEST_EXCHANGE, api_key=API_KEY, api_secret=API_SECRET) strategy = Strategy(client, timeframe=TIMEFRAME) trader = Trader(client, strategy, money_to_trade=AMOUNT_MONEY_TO_TRADE, leverage=LEVERAGE) while True: if round(time.time()) % time_to_wait_new_trade[TIMEFRAME] == 0: trader.execute_trade() time.sleep(5) # 10
sc = SlackClient(SLACK_TOKEN) client = bitmex.bitmex(test=False, api_key=ID, api_secret=SECRET) strategy = Strategy(client, timeframe=TIMEFRAME) trader = Trader(client, sc, strategy, ohlcv_candles, money_to_trade=AMOUNT_MONEY_TO_TRADE, leverage=LEVERAGE) while True: if round(time.time()) % time_to_wait_new_trade[TIMEFRAME] == 0: time.sleep(1) response = trader.execute_trade() if response is not None: if trader.send_notifcation(response) is True: print('Notification send successfully') else: print('Notification Failed') exec_price = response[0]['price'] order_counter = order_counter + 1. print('Order Number : {}'.format(order_counter)) time.sleep(2) while True: order_status = client.Order.Order_getOrders( symbol='XBTUSD', count=2, reverse=True).result() if order_status[0][0][ 'ordStatus'] == 'Filled' and flag == False: stop_order_response = trader.set_stop_limit(