Open AI Projeck Binance CCXT
import ccxt
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# Initialize the Binance exchange object
binance = ccxt.binance()
# Define the data lists for the bid and ask prices
bid_prices = []
ask_prices = []
# Define the function to update the plot
def update_plot(num):
# Fetch the latest ticker data for the BTC/USDT pair
ticker = binance.fetch_ticker('BTC/USDT')
bid_prices.append(ticker['bid'])
ask_prices.append(ticker['ask'])
# Limit the data to the last 100 data points
bid_prices2 = bid_prices[-100:]
ask_prices2 = ask_prices[-100:]
plt.clf()
plt.plot(bid_prices2, label='Bid')
plt.plot(ask_prices2, label='Ask')
plt.xlabel('Time')
plt.ylabel('Price')
plt.title('BTC/USDT Bid and Ask Prices')
plt.text(0.8, 0.9, 'Bid: ${:.2f}'.format(
ticker['bid']), transform=plt.gca().transAxes)
plt.text(0.8, 0.85, 'Ask: ${:.2f}'.format(
ticker['ask']), transform=plt.gca().transAxes)
plt.legend()
# Create the animation
ani = animation.FuncAnimation(plt.gcf(), update_plot, interval=1000)
plt.show()
1. test net dalam ccxt
https://stackoverflow.com/questions/63634227/how-to-tell-ccxt-to-use-binance-bybit-testnet
2. cara setting ke future
https://github.com/ccxt/ccxt/issues/6273
Komentar
Posting Komentar