I am very new to python and I am trying to produce a candlestick chart from CSV files downloaded from tradestation. The data in the csv is Symbol, Date, O, H, L, C, Volume
I am using matplot lib and I have create a dataframe to read the CSV shown in the link below with the csv path in a folder in my C drive.
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
#from sentdex matplot lib candle tutorial
import matplotlib.dates as mdates
import matplotlib.ticker as mticker
from matplotlib.finance import candlestick_ohlc
start = dt.datetime(2000,1,1)
end = dt.datetime(2017,12,31)
df = pd.read_csv('C:\TS\spy.CSV', parse_dates=True, index_col=1)
The following code works for producing a candlestick from the close data only in a ten data period but I need a daily candlestick and have not been able to figure that out.
#Candle Code Here
df_ohlc = df['Close'].resample('10D').ohlc()
print(df_ohlc.head())
df_ohlc = df_ohlc.reset_index()
#MDATES: mdates type that...is mostly just a pain in the butt, but that's the date type for matplotlib graphs
df_ohlc['Date'] = df_ohlc['Date'].map(mdates.date2num)
#df_ohlc['Open'] = df_ohlc['Open']
#ax1.xaxis_date: What this does for us is converts the axis from the raw mdate numbers to dates.
ax1.xaxis_date()
candlestick_ohlc(ax1, df_ohlc.values, width=3, colorup='g')
Any help is greatly appreciated. Thank you very much.