Your cart is currently empty!
February 9, 2025
Here is a step -by -step guide on how to create a graphic of the Ethereum candles using Matplotlib in Python:
`Python
Matters matplotlib.pyplot as PLT
Matters matplotlib.dates like mdates
Import number such as NP
It matters yfinance like yf
From DateTime import datetime, Timelta
Get the current hour (it will be displayed as axis X)
Start_date = datetime.today (). Strftime ('%Y-%M-%D')
end_date = (datetime.today () -Timedelta (days = 30)). Strftime ('%Y-%M-%D')
Define the Api point for Ethereum prices
apiendpoint = "
Set Parameters for the API request
Params = {
"Symbol": "et",
"Interval": "1m",
"Limit": 100,
the maximum number of databases to be recovered
'Timerge': start_date + ',' + end_date,
}
Send the API application and get the answer
Answer = YF.GET (Apiendpoint, Params = Params)
Convert the answer to a Panda flopherme
DF = Pd.Datrame (Reply) .t
Create Axis X data (index) from 1 to 100 (assuming that we need at least 100 data points)
Data = Np.arange (1, Len (DF.Columns))
Set the format of the date for matplotlib
PLT.GCA (). Xaxis.set_major_formatter (mdates.dateformatter ('%y-%m-%d'))
Take the candles chart
PLT.Figura (Fussize = (14,10))
For the interval (Len (data) -1):
PLT.PLOT ([I0.01, (I+1)0.01], [DF.LOl [I, 'Chiust']. Mean (), DF.LOl [I+1, 'closed']. = 'G ')
Otherwise (I == Len (DF.Columns) - 2):
Do not connect the last candle
PLT.PLOT ([I0.01, i0.01 + 0.01], [DF.LOl [I, 'high']. Mean (), DF.Loc [I + 1, 'high'] average ()], color = 'g')
Elif (I == Len (DF.Columns) - 2):
Do not trace the first candle
PLT.PLOT ([I0.01, i0.01 + 0.02], [DF.LOl [I, 'Basso']. Mean (), DF.LOl [I + 1, 'Basso'] average ()], color = 'g')
PLT.XLABEL ('Data')
PLT.YLabel ('Price (USD)')
PLT.Title ("Ethereum candles graphic")
plt.show ()
To perform this script, you need to have the necessary installed bookstores (Matplotlib
,Pandas
and Yfinance
). You also need a binance bee key.
Make sure that Binance API’s goal is fixed correctly according to the API documentation.