#!/usr/bin/python from binance.enums import * from binance.rmt_srv import RmtSrvObj if __name__ == "__main__": pair = 'ETHUSDT' rmt_srv = RmtSrvObj(pair, KLINE_INTERVAL_1DAY, 7) # ret = rmt_srv.get_kline() # print(ret) # print(rmt_srv.get_available_coins()) # print(rmt_srv.get_all_orders()) print(rmt_srv.get_order(72632872)) print(rmt_srv.get_order(72619361))
price_digits = int(args.p) price_gap = float(args.g) price_gap_num = int(args.n) target_coin_reserve = float(args.r) base_coin_reserve = float(args.s) exchange = args.e present = datetime.datetime.now() print('\n%s Main start...' % present) if exchange == 'binance': base_coin = base_coin.upper() target_coin = target_coin.upper() pair = '%s%s' % (target_coin, base_coin) print("The pair is %s " % pair) rmt_srv = BnbRmtSrvObj(pair, KLINE_INTERVAL_1DAY, 7, debug=True) elif exchange == 'okex': pair = '%s_%s' % (target_coin, base_coin) print("The pair is %s " % pair) rmt_srv = OkexRmtSrvObj(pair, '1day', 7, debug=True) else: print('Wrong exchange name: %s' % exchange) pair = None rmt_srv = None exit(1) db_name = exchange db_api = DbApi(db_url, db_name, mongo_user, mongo_pwd) # cancel all unfinished orders print('Cancel all orders')
args = parser.parse_args() # print(args) base_coin = args.b target_coin = args.t exchange = args.e present = datetime.datetime.now() print('\n%s Cancel start...' % present) if exchange == 'binance': base_coin = base_coin.upper() target_coin = target_coin.upper() pair = '%s%s' % (target_coin, base_coin) print("The pair is %s " % pair) rmt_srv = BnbRmtSrvObj(pair, KLINE_INTERVAL_1DAY, 7, debug=True) elif exchange == 'okex': pair = '%s_%s' % (target_coin, base_coin) print("The pair is %s " % pair) rmt_srv = OkexRmtSrvObj(pair, '1day', 7, debug=True) else: print('Wrong exchange name: %s' % exchange) pair = None rmt_srv = None exit(1) db_name = exchange db_api = DbApi(db_url, db_name, mongo_user, mongo_pwd) # cancel all unfinished orders print('Cancel all orders')
continue # insert new order into database time.sleep(0.5) self.db_api.insert_order(self.rmt_srv.get_order(order_id)) except Exception as e: print(e) continue if __name__ == "__main__": pair = 'ETHUSDT' target_coin = 'ETH' base_coin = 'USDT' # create a new instance rmt_srv = RmtSrvObj(pair, line_type=KLINE_INTERVAL_1DAY, size=7, debug=True) db_url = "mongodb://localhost:27017/" db_name = "binance" db_api = DbApi(db_url, db_name) policy = Policy(db_api, rmt_srv=rmt_srv, target_coin=target_coin, base_coin=base_coin, target_amount_digits=3, base_amount_digits=2, price_digits=2) policy.sell_policy() # buy_policy(okSpot, 8, base_coin) # print(okSpot.balance('dpy'))
if __name__ == "__main__": parser = argparse.ArgumentParser(description='coin trade') parser.add_argument('-e', help='exchange name') args = parser.parse_args() # print(args) exchange = args.e base_coin = 'usdt' target_coin = 'btc' if exchange == 'binance': base_coin = base_coin.upper() target_coin = target_coin.upper() pair = '%s%s' % (target_coin, base_coin) print("The pair is %s " % pair) rmt_srv = BnbRmtSrvObj(pair, KLINE_INTERVAL_1DAY, 7) elif exchange == 'okex': pair = '%s_%s' % (target_coin, base_coin) print("The pair is %s " % pair) rmt_srv = OkexRmtSrvObj(pair, '1day', 7) else: print('Wrong exchange name: %s' % exchange) pair = None rmt_srv = None exit(1) coins = rmt_srv.get_available_coins() target_price = rmt_srv.current_price update_flag = False db_name = exchange
target_coin = args.t target_amount_digits = int(args.a) price_digits = int(args.p) profit_ratio = float(args.r) fee_ratio = float(args.f) exchange = args.e present = datetime.datetime.now() print('\n%s Check if any order is dealt' % present) if exchange == 'binance': base_coin = base_coin.upper() target_coin = target_coin.upper() pair = '%s%s' % (target_coin, base_coin) print("The pair is %s " % pair) rmt_srv = BnbRmtSrvObj(pair, KLINE_INTERVAL_1DAY, 7, debug=True) elif exchange == 'okex': pair = '%s_%s' % (target_coin, base_coin) print("The pair is %s " % pair) rmt_srv = OkexRmtSrvObj(pair, '1day', 7, debug=True) else: print('Wrong exchange name: %s' % exchange) pair = None rmt_srv = None exit(1) update_flag = False db_name = exchange db_api = DbApi(db_url, db_name, mongo_user, mongo_pwd) # check if any order is dealt