当前位置:网站首页>解决:- 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
输出结果:
如果想要测试代码,自己可以按照上述字段来,这就是使用的格式了
边栏推荐
- MySQL高级学习笔记
- MySQL 5.7 installation tutorial (full-step, nanny-level tutorial)
- abaqus如何快速导入其他cae文件的assembly?
- 振兴农村循环经济 和数链串起农业“生态链”
- MySQL 5.7 安装教程(全步骤、保姆级教程)
- MySql COUNT statistics function explanation
- The stock price has repeatedly hit new lows, and the real estate SaaS giant is in trouble. How should Mingyuan Cloud transform and save itself?
- Two good php debug tutorials
- MySQL Advanced Statements (1)
- Node installation and configuration (node-v12.20.2-x64 ) and introduction to node version switching
猜你喜欢
随机推荐
Nacos database configuration
MySQL Advanced Statements (1)
MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql
node安装及环境变量配置
Servlet
MySQL高级语句(一)
Tips for programmers to write PPT
Node installation and environment variable configuration
Node installation and configuration of environment variables
项目开发规范
文件上传漏洞(二)
nacos源码启动找不到istio包
Nacos installation detailed process
(笔记整理未完成)【图论】图的遍历
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高级语句(一)
Kind of weird!Access the destination URL, the host can container but not
MySQL高级学习笔记
MySql -- 不存在则插入,存在则更新或忽略
APP special test: traffic test