当前位置:网站首页>解决:- 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
输出结果:

如果想要测试代码,自己可以按照上述字段来,这就是使用的格式了
边栏推荐
- APP special test: traffic test
- postgres 多个变量填充字符串,字串格式化
- 2022年7月18日-7月31日(Ue4视频教程和文档,20小时。合计1412小时,剩8588小时)
- In-depth analysis of the initialization of member variables and local variables
- rhce homework
- 提交代码流程
- MySQL high-level --- storage engine, index, lock
- Write implicit join on view with jOOQ 3.14 synthetic foreign key
- HCIP 第四天
- Analysis of port 9848 error at startup of Nacos client (non-version upgrade problem)
猜你喜欢
随机推荐
MySQL Advanced SQL Statements
8/1 思维+扩展欧几里得+树上dp
MySQL索引常见面试题(2022版)
Servlet
Dataset: A detailed guide to the download link collection of commonly used datasets in machine learning
APP special test: traffic test
How to install the specified version package with NPM and view the version number
Nacos安装详细过程
View source and switch mirrors in two ways: npm and nrm
.NET Static Code Weaving - Rougamo Release 1.1.0
DNS resolution process
Pagoda+FastAdmin 404 Not Found
About the local server problem after ue4.27 pixel streaming package
提交代码流程
C# FileInfo类
解决C#非静态字段、方法或属性“islandnum.Program.getIslandCount(int[][], int, int)”要求对象引用
一文搞懂C操作符
Not annotated parameter overrides @NonNullApi parameter
C# Coding Conventions Handbook
【21天学习挑战赛】顺序查找









