You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtimeimportccxtimportasciichartpy#Define a dictionary for your crypto informationcryptocom= {
"exchange_name": 'cryptocom', # Use the exchange name as a string"pairs": ["ETH/BTC", "ETH/USD"]
}
#List of pairspairs=cryptocom["pairs"]
#Initialize the exchange using the exchange nameexchange=getattr(ccxt, cryptocom["exchange_name"])()
#Function to get and print the spot pricedefget_spot_price(pair):
ticker=exchange.fetch_ticker(pair)
spot_price=ticker['last']
print(f"Spot price of {pair}: {spot_price}")
returnspot_price#Get and print your ETH balance in USDget_USD=ETH_BAL*get_spot_price(pairs[2])
print(f"Your ETH balance in USD is {get_USD}")
#Refactored code for updating ETH spot priceinterval=30ETH_SPOT= []
plot_data= []
deffetch_and_update_spot_price():
whileTrue:
ticker=get_spot_price(pairs[2])
ETH_SPOT.append(ticker)
iflen(ETH_SPOT) ==2:
change=ETH_SPOT[1] -ETH_SPOT[0]
plot_data.append(change)
s=plot_datachart=asciichartpy.plot(s, {'height': 10, 'padding': ' ', 'offset': 5})
print(chart)
ETH_SPOT.pop(0)
time.sleep(0.5)
#Sleep for 30 seconds, not in a looptime.sleep(interval)
#Call the function to start updating the spot pricefetch_and_update_spot_price()
Hiya,
Please add the Python port docs.
Cheers,
Jonny
The text was updated successfully, but these errors were encountered: