-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbalances.py
More file actions
25 lines (21 loc) · 739 Bytes
/
Copy pathbalances.py
File metadata and controls
25 lines (21 loc) · 739 Bytes
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
from binance.client import Client
import BinanceKeys as BKeys
from parameters import *
def balances(df):
"""
Gets balances of both assets.
Args:
df (dataframe): dataframe of prices.
Returns:
amt1 (float), amt2 (float): amount of symbol1 and symbol2 owned times 0.99, in symbol2 units
"""
n=len(df)-1
client = Client(BKeys.key(), BKeys.secretKey())
balance2 = client.get_asset_balance(asset=asset2())
balance1 = client.get_asset_balance(asset=asset1())
balance2 = float(balance2["free"])
balance1 = float(balance1["free"])
balance2 = balance2 / df["price"][n] # converting to BNB
amt1 = balance1 * 0.99
amt2 = balance2 * 0.99 # it's in amt2
return amt1,amt2