3 min de lectura
Ethereum: matplotlib chart not showing candle data as vertical line only (no wicks, open high low close)
CRYPTOCURRENCY
Here is a step -by -step guide on how to create a table of Ethereum candles on Matplotlib in Python:
`Python
Bring matplotlib.plot like PLT
Import matplotlib. Kindergarten for mates
Bring numbhy as e.g.
Bring Yfinance YF
Datetime, time, time
Get your current time (displayed as the X axis)
Start_date = datetime.tlatay (). Strtime ("%y-%m-%d")
End_date = (datetime.tlatay () with (days = 30)). Strtime ("%y-%m-%d")
Set the API terminal to Ethereum prices
Apiendpoint = "
Set appointment parameters
Params = {
"Symbol": "ETH",
"Interval": "1m",
"Limit": 100,
Maximum number of data points for download
"Timrange": Start_Date + ',' + End_Date,
}
Send the application subscription and get an answer
Answer = YF.GET (APIENDPOINT, PARAMS = PARAMS)
Convert your answer to the panda database
df = pd.dataframe (answer) .t
Create dates of the X axis (catalog) 1-100 (assuming that we need at least 100 data points)
Dates = e.g. arrow (1, linen (df.columns)))
Set the Matplotlib date format
Plt.gca (). Xaxis.set_major_formater (mates.dateformer ('%y-%m-%d'))))))))
Draw a candle table
Plt.figure (drawing = (14.10))
Because in the area (linen (dates) -1):
Plt.plot ([i0.01, (i+1)0.01], [df.loc [i, 'closed']. Medium (), df.loc [I+1, 'close'] average ()], color = "g")
If not (i == linen (df.columns) - 2):
Do not draw the last candle
Plt.plot ([i0.01, i0.01 + 0.01], [df.loc [i, 'high']. Medium (), df.loc [i + 1, 'high'] Medium ()], color = "g")
Elif (i == Len (df.columns) - 2):
Do not describe your first candle
Plt.plot ([i0.01, I0.01 + 0.02], [df.loc [i, "low"]. Medium (), df.loc [i + 1, "low"] Medium ()], color = "g")
Plt.xlabel ("data")
Plt.ylabel ("price (USD)")
PLT.ITLE ("Ethereum Candle Mapht")
Plt.show ()
To fill this script, you must install the required libraries (‘MatpLotlib’, ‘Pandas’ and ‘Yfinance’). You also need the API Binance key.
Make sure that the API Binance end point is correctly set in accordance with the API documentation.