-
Notifications
You must be signed in to change notification settings - Fork 5
/
3c_use_account.py
77 lines (62 loc) · 1.79 KB
/
3c_use_account.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
#################################################################
#
# 3commas bot stats
# giving a better overview of your deals in 3commas
#
# https://github.com/gunleik/3commas-tools
#
# @gunleik
#
#################################################################
import time
import sys
import os
from py3cw.request import Py3CW
from datetime import date
from pprint import pprint
my_action = ""
arguments = len(sys.argv) - 1
if arguments > 0:
my_action = sys.argv[1]
if my_action == "--help":
print()
print("Usage: ./3c_use_account.sh [real|paper]")
print()
print("Use this to change active account to be used with 3c_bot_stats")
print()
print("arguments:")
print(" real, set active account to real account")
print(" paper, set active account to paper account")
print()
sys.exit()
if str(my_action) == "real" or str(my_action) == "paper":
my_nothing = "yeay"
else:
print("Expected argument: real / paper")
print("Specify if I should change to real or paper account")
sys.exit()
# initiate API with key/secret from os env
p3cw = Py3CW(
key=os.environ.get('threecommas_key').rstrip(),
secret=os.environ.get('threecommas_secret').rstrip(),
request_options={
'request_timeout': 10,
'nr_of_retries': 1,
'retry_status_codes': [502]
}
)
# change to paper account requires api with account write access
# real or paper account is set on global account settings, so manually changing
# this in the 3c web console makes the setting for this script also
error, mode = p3cw.request(
entity='users',
action='change_mode',
payload={
"mode": str(my_action)
}
)
if mode == True:
print("Changed to use account: " + str(my_action))
else:
print("Something failed:")
pprint(error)