当前位置:网站首页>解决:- SPY: No data found for this date range, symbol may be delisted报错
解决:- SPY: No data found for this date range, symbol may be delisted报错
2022-08-02 06:02:00 【淮雵的Blog】
问题描述:
原代码如下:
import pandas as pd
from statsmodels.tsa.stattools import adfuller
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from blitz.modules import BayesianLSTM
from blitz.utils import variational_estimator
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
%matplotlib inline
from collections import deque
import yfinance as yf
import numpy as np
plt.rcParams.update({
'figure.figsize':(20,10)})
plt.rcParams.update({
'font.size':20})
ticker = "SPY"
ticker_y = yf.Ticker("SPY")
df = ticker_y.history(period="5y")
然后出现报错:- SPY: No data found for this date range, symbol may be delisted
- SPY: No data found for this date range, symbol may be delisted
解决方案:
其实原因就在于这里使用的为Yahoo财经数据(从import yfinance as yf就可以证明这是Yahoo财经数据),但是由于现在使用Python访问不了那个网站了,所以可以自行寻找该网站的数据。使用read_csv等函数进行引用。
因此,解决方案为:
import pandas as pd
from statsmodels.tsa.stattools import adfuller
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from blitz.modules import BayesianLSTM
from blitz.utils import variational_estimator
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
%matplotlib inline
from collections import deque
import yfinance as yf
import numpy as np
plt.rcParams.update({
'figure.figsize':(20,10)})
plt.rcParams.update({
'font.size':20})
df_non_stat = pd.read_csv("stock_train.csv", index_col = 0, parse_dates=[0])
df_non_stat
输出结果:

如果想要测试代码,自己可以按照上述字段来,这就是使用的格式了
边栏推荐
- Go inside the basic knowledge
- Tips for programmers to write PPT
- (Notes are not completed) [Graph Theory] Traversal of graphs
- Node installation and configuration (node-v12.20.2-x64 ) and introduction to node version switching
- MySQL - 多表查询与案例详解
- 【21天学习挑战赛】顺序查找
- punch day05
- [数据集][VOC]男女数据集voc格式6188张
- 暑期总结(三)
- Difference between npm and yarn
猜你喜欢

MySQL Advanced Study Notes

npm does not recognize the "npm" item as the name of a cmdlet, function, script file, or runnable program.Please check the spelling of the name, and if the path is included, make sure the path is corr

Pagoda+FastAdmin 404 Not Found

abaqus如何快速导入其他cae文件的assembly?

GCC编译器技术解析

MySQL 23道经典面试吊打面试官

Toolbox App 1.25 New Features at a Glance | Version Update

有点奇怪!访问目的网址,主机能容器却不行

Node installation and configuration of environment variables

Specified URL is not reachable,caused by :‘Read timed out
随机推荐
node安装及环境变量配置
Detailed explanation of 9 common reasons for MySQL index failure
MySQL Advanced Statements (1)
Analysis of port 9848 error at startup of Nacos client (non-version upgrade problem)
MySQL - Multi-table query and case detailed explanation
request.getSession(), the story
The international top conference OSDI included Taobao system papers for the first time, and the device-cloud collaborative intelligence was recommended by the keynote speech of the conference
MySQL database video tutorial from beginner to proficient
nacos源码启动找不到istio包
HCIP BGP Comprehensive Experiment Establishing peers, route reflectors, federation, route announcement and aggregation
Toolbox App 1.25 新功能一览 | 版本更新
Nacos installation detailed process
CAT1 4G+Ethernet development board Tencent cloud mobile phone WeChat applet display temperature and delivery control
Toolbox App 1.25 New Features at a Glance | Version Update
July 18-July 31, 2022 (Ue4 video tutorials and documentation, 20 hours. Total 1412 hours, 8588 hours left)
MySQL高级语句(一)
武汉高性能计算大会2022举办,高性能计算生态发展再添新动力
ASP.NET Core Web API 幂等性
C# FileInfo类
MySQL Advanced SQL Statements (2)