烛台图表贸易站数据

时间:2017-03-06 22:46:20

标签: python matplotlib tradestation

我是python的新手,我正在尝试从tradestation下载的CSV文件中生成烛台图表。 csv中的数据是Symbol,Date,O,H,L,C,Volume

我正在使用matplot lib,我创建了一个数据框来读取下面链接中显示的CSV,并在我的C盘中的文件夹中显示csv路径。

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)

以下代码适用于仅在十个数据期间从关闭数据生成烛台,但我需要每日烛台并且无法弄清楚。

#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')

非常感谢任何帮助。非常感谢你。

0 个答案:

没有答案