forked from SaxonWarrior/TradeBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop_bots.py
88 lines (65 loc) · 2.67 KB
/
stop_bots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
from binance_api import Binance
from tcommas_api import API3Commas
from utils import *
from pprint import pprint
import argparse
import sys
import time
import run_config
from datetime import datetime
from time import gmtime, strftime
import signal
from timeout import timeout
#----------------------------------
'''
'''
#----------------------------------
parser = argparse.ArgumentParser()
parser.add_argument("--dry", help='Dry run', action='store_true', default=None)
parser.add_argument("--binance_account_flag", help='Part of binance account name identifier', default=None)
parser.add_argument("--all", help='All accounts from config file', action='store_true', default=None)
args = parser.parse_args()
if (args.all and args.binance_account_flag) or (not args.all and not args.binance_account_flag):
print("Error: Can't use --all flag with --binance_account_flag, need one specified")
exit(1)
#----------------------------------
def stop_account(account_id, api_key, api_secret):
account=getBinanceAPI(api_key, api_secret).futuresAccount()
chunks = 100
count = 0
bots = []
while True:
tbots=get3CommasAPI().getBots(OPTIONS=f"?limit={chunks}&offset={chunks*count}")
count += 1
if len(tbots) > 0:
bots.extend(tbots)
else:
break
stop_all_bots(bots, account_id, args.dry)
#----------------------------------
print ("-----------------------------------------------------------------")
for Binance_API in run_config.Binance_APIs:
if args.binance_account_flag and args.binance_account_flag in Binance_API['account_name']:
account_name = Binance_API['account_name']
Binance_API_KEY = Binance_API['Binance_API_KEY']
Binance_API_SECRET = Binance_API['Binance_API_SECRET']
account, account_txt = getAccountID(account_name)
print (account_txt)
stop_account(account, Binance_API_KEY, Binance_API_SECRET)
print ("-----------------------------------------------------------------")
break
elif args.all:
account_name = Binance_API['account_name']
Binance_API_KEY = Binance_API['Binance_API_KEY']
Binance_API_SECRET = Binance_API['Binance_API_SECRET']
account, account_txt = getAccountID(account_name)
print (account_txt)
stop_account(account, Binance_API_KEY, Binance_API_SECRET)
print ("-----------------------------------------------------------------")
if args.dry:
print("*************************")
print("***Running in DRY mode***")
print("*************************")
sys.stdout.flush()
print ("-----------------------------------------------------------------")