问题描述
整个部分是代码。在Python上添加股票代码时无法找出解决方案,并发布了相同的错误消息。
任何帮助将不胜感激。
我是编码的新手,并且已经看了很多有关它的视频,所以我希望一切都有意义。
import yfinance as yf
import datetime as dt
import pandas as pd
from pandas_datareader import data as pdr
import matplotlib.pyplot as plt
yf.pdr_override()
start =dt.datetime(2020,4,1)
now = dt.datetime.now()
stock = input("Enter the stock symbol : ")
while stock != "quit":
df = pdr.get_data_yahoo(stock,start,now)
df ["High"].plot(label="high")
pivots=[]
dates=[]
counter=0
lastPivot=0
Range=[0,0]
dateRange=[0,]
for i in df.index:
currentMax=max(Range,default=0)
value=round(df["High"][i],2)
Range=Range[1:9]
Range.append(value)
dateRange=dateRange[1:9]
dateRange.append(i)
if currentMax==max(Range,default=0):
counter+=1
else:
counter=0
if counter==5:
lastPivot=currentMax
datloc=Range.index(lastPivot)
lastDate=dateRange[dateloc]
pivots.append(lastPivot)
dates.append(lastDate)
print()
timeD=dt.timedelta(days=30)
for index in range(len(pivots)):
print(str(pivots[index])+": "+str(dates[index]))
plt.plot_date([dates[index],dates[index]+timdD],[pivots[index],pivots[index]],linestyle="-",linewidth=2,marker=",")
plt.show()
stock = input("Enter the stock symbol : ")
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)