我的代码:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
lot_size = 3750
min_vol = 60
path = 'C:\\Data\\ONGC19FEBFUT.txt'
df = pd.read_csv(path, sep=",")
df.columns = ['Date','Time','Price','volume']
df['Volume'] = np.where((df.volume/lot_size) < min_vol, 0, (df.volume/lot_size))
df["Time"] = pd.to_datetime(df['Time'])
df.plot(x="Time",y='Price', rot=0, color='g')
plt.title("Date: " + str(df['Date'].iloc[0]))
dff = df[df.Volume > min_vol].reset_index(drop=True)
dff = dff[['Time','Price','Volume']]
print(dff)
dict = dff.to_dict('index')
for x in range(0, len(dict)):
plt.axhline(y=dict[x]['Price'],linewidth=1, color='blue')
plt.subplots_adjust(left=0.05, bottom=0.06, right=0.95, top=0.96, wspace=None, hspace=None)
plt.show()
我的当前输出:
Dataframe dff给出了要在图表上绘制的价格值。我想分离要按 30 分钟持续时间绘制的价格值,即要在时间范围内绘制从 09:00 到 09:30 的价格值,要在此时间范围内绘制从 09:30 到 10:00 的价格值等等。我想限制每 30 分钟时间范围的水平价格线。
汪汪一只猫
相关分类