better templatize commands and run processes

This commit is contained in:
lza_menace 2020-09-08 21:46:06 -07:00
parent 2a1d22646c
commit 11ebd2261f

View file

@ -158,9 +158,10 @@ class Trader(TradeOgre):
if __name__ == '__main__':
parser = ArgumentParser(description='Helpful TradeOgre trading script')
parser.add_argument('-m', '--market-maker', action='store_true', help='Put in buy/sell orders')
parser.add_argument('-b', '--balances', action='store_true', help='Update coin balances of both base and currency')
parser.add_argument('-u', '--update-orders', action='store_true', help='Update status of orders')
parser.add_argument('--market-maker', action='store_true', help='Put in buy/sell orders')
parser.add_argument('--balances', action='store_true', help='Update coin balances of both base and currency')
parser.add_argument('--update-orders', action='store_true', help='Update status of orders')
parser.add_argument('--run', action='store_true', help='Run continuously')
args = parser.parse_args()
t = Trader()
@ -181,42 +182,46 @@ if __name__ == '__main__':
t.store_balances()
exit()
while True:
try:
t.store_market_data()
except Exception as e:
logging.info('[ERROR] Unable to store market data!', e)
# update orders every 5 minutes
if orders_counter == 5:
if args.run:
while True:
try:
t.update_orders()
logging.info('[ORDERS] Resetting orders counter')
orders_counter = 0
t.store_market_data()
except Exception as e:
logging.info('[ERROR] Unable to update orders!', e)
logging.info('[ERROR] Unable to store market data!', e)
# update balances every 6 minutes
if balances_counter == 6:
try:
t.store_balances()
logging.info('[BALANCE] Resetting balances counter')
balances_counter = 0
except Exception as e:
logging.info('[ERROR] Unable to update balances!', e)
# update orders every 5 minutes
if args.update_orders:
if orders_counter == 5:
try:
t.update_orders()
logging.info('[ORDERS] Resetting orders counter')
orders_counter = 0
except Exception as e:
logging.info('[ERROR] Unable to update orders!', e)
# start market makers every 2 minutes
if market_maker_counter == 2:
try:
t.start_market_maker()
logging.info('[MARKET MAKER] Resetting market maker counter')
market_maker_counter = 0
except Exception as e:
logging.info('[ERROR] Unable to start market maker!', e)
# update balances every 6 minutes
if args.balances:
if balances_counter == 6:
try:
t.store_balances()
logging.info('[BALANCE] Resetting balances counter')
balances_counter = 0
except Exception as e:
logging.info('[ERROR] Unable to update balances!', e)
orders_counter += 1
balances_counter += 1
market_maker_counter += 1
# start market makers every 2 minutes
if args.market_maker:
if market_maker_counter == 2:
try:
t.start_market_maker()
logging.info('[MARKET MAKER] Resetting market maker counter')
market_maker_counter = 0
except Exception as e:
logging.info('[ERROR] Unable to start market maker!', e)
# sleep 1 minute
sleep(60)
orders_counter += 1
balances_counter += 1
market_maker_counter += 1
# sleep 1 minute
sleep(60)