Im trying to create a live candlestick chart that gets the price from just scraping the live gold price from a website. I’m not sure but i think that is the only way of getting live forex data without paying. I was thinking about updating a candle with the scraped data for 15 minutes and then close that candle and create a new candle so it works like TradingView. Is it possible to create something like that using matplotlib and are there any recommendations for creating something like that?
i have made a simple candlestick chart that gets historical gold price data from a csv as an example for the matplotlib candlestick chart thingy.
import pandas as pd
import mplfinance as mpf
import matplotlib.pyplot as plt
df = pd.read_csv("XAUUSD15.csv", delimiter='t', header=None)
df.columns = ["Date", "Open", "High", "Low", "Close", "Volume"]
df["Date"] = pd.to_datetime(df['Date'], format='%Y-%m-%d %H:%M')
df.set_index('Date', inplace=True)
style = "yahoo"
last_candles = df.iloc[-150:]
fig, ax = plt.subplots(figsize=(8, 3.9))
mpf.plot(last_candles, type='candle', style=style,
volume=False, ax=ax, ylabel='',
xrotation=0, datetime_format='%Y-%m-%d %H:%M')
ax.set_facecolor('#101010')
fig.patch.set_facecolor('xkcd:black')
ax.grid(True, color='black', linestyle='--', linewidth=0.5)
ax.xaxis.set_visible(False)
ax.tick_params(axis='y', colors='white')
plt.tight_layout()
plt.show()
Martin Ryan Lacis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.