-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountSorting.py
More file actions
117 lines (98 loc) · 4.24 KB
/
AccountSorting.py
File metadata and controls
117 lines (98 loc) · 4.24 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Novixel's Coinbase Account Sorter
# AccountSorting.py
# CryptoCollector
# Version 1.2.1b
# May 5th, 2021
from Connect import CoinConnect
import configparser
import Setup as cfg
from time import sleep
bot = CoinConnect()
auth = bot.auth
quote = "BTC" # Change me ONLY if your a big boy!
MainQuote = "GBP"
mlist = []
def GetTicker(product_id):
product_id = product_id
#print("\n #####",product_id,"TICKER")
tick = auth.get_product_ticker(product_id)
for k , v in tick.items():
cfg.SaveTicker(str(k),str(v))
#print(k, "=\t",v)
#cfg.LogThis(("Tick",product_id,tick["price"])) # MAYBE !!! CAUTION WILL CALL ALOT
return tick["price"]
def GetTotal(available):
price = float(GetTicker(("BTC" + "-" + MainQuote )))
x = available * price
return x
def AllAccounts():
cfg.LogThis(("ALL ACCOUNTS CALLED",""))
# Lets Check All Of The Accounts With Available Funds
global mlist
a = auth.get_accounts()
Specials = ["USD","USDC","EUR","GBP"]
mlist = []
alist = []
acList = []
print("\n AVAILABLE FUNDS:")
cfg.LogThis(("Reading Available Accounts!",""))
for i in a: # Lets Check Every Account
avai = float(i["available"]) # Grab The Funds
cur = i["currency"] # And the Ticker Name
# Save The Useful Stuff
if avai > 0 and cur == "BTC": # First check if we have Bitcoin!!!
cfg.LogThis(("Account:","%.4f"%avai,cur))
acList.append(cur)
price = float(GetTicker("BTC-USD"))
mlist.append(float("%.4f"%(avai * price)))
#print("\n",cur)
for k,v in i.items():
cfg.SaveAccount(str(cur),str(k),str(v))
#print(cur,k,"=\t",v)
cfg.SaveAccount(str(cur),str(quote + "_value"),str("%.8f"%avai))
cfg.SaveAccount(str(cur),str(MainQuote + "_value"),str("%.2f"%(GetTotal(avai))))
elif avai > 0 and cur != quote: # if we have funds and its NOT bitcoin
cfg.LogThis(("Account:","%.4f"%avai,cur))
acList.append(cur)
print("\n####\t" + cur + "-"+ quote)
for k,v in i.items():
cfg.SaveAccount(str(cur),str(k),str(v)) # save stuff
if k == "available":
print(" We Have =\t",v,cur)
#print(k,"=\t",v)
# convert the coin if special
if cur in Specials:
temPro = ( quote + "-" + cur )
price = float(GetTicker(temPro))
price = 1 / price
else:
temPro = ( cur + "-" + quote )
price = float(GetTicker(temPro))
product_id = temPro
convert = avai * price
exchange = GetTotal(float(convert))
mlist.append(float("%.4f"%exchange))
# Magic Time
cfg.SaveAccount(str(cur),str(quote + "_value"),str("%.8f"%convert))
cfg.SaveAccount(str(cur),str(MainQuote + "_value"),str("%.2f"%exchange))
cfg.LogThis((str(cur),str(MainQuote + "_value"),str("%.2f"%exchange)))
cfg.LogThis((str(cur),str(quote + "_value"),str("%.8f"%convert)))
alist.append(convert) # add to list of totals balances in BTC
convert = convert # make it look pretty for the camera
print(" Market Price =\t", "%.8f"%price, quote)
print(" Total Value =\t", "%.8f"%convert, quote)
print(" Total Quote =\t", "%.2f"%exchange, MainQuote)
cfg.LogThis((" Market Price =", "%.8f"%price, quote))
cfg.LogThis((" Total Value =", "%.8f"%convert, quote))
cfg.LogThis((" Total Quote =", "%.2f"%exchange, MainQuote))
sleep(1)
#Now Lets Send This To a Bot! to check ranges
#alist.append(float(cfg.ReadAccount("BTC","available")))
QuoteTotal = GetTotal(sum(alist))
print("\n\tTotal Bitcoin\t", "%.8f"%sum(alist), quote)
print("\tFor a Total of\t", ("%.2f"%QuoteTotal), MainQuote)
cfg.LogThis(("Total Bitcoin", "%.8f"%sum(alist), quote))
cfg.LogThis(("For a Total of", ("%.2f"%QuoteTotal), MainQuote))
# print("\n")
return acList
AllAccounts()