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

如果想要测试代码,自己可以按照上述字段来,这就是使用的格式了
边栏推荐
- HCIP BGP Comprehensive Experiment Establishing peers, route reflectors, federation, route announcement and aggregation
- odoo field 设置匿名函数domain
- Technology empowers Lhasa's "lungs", Huawei helps Lalu Wetland Smart Management to protect lucid waters and lush mountains
- C# FileInfo类
- Nodejs installation and global configuration (super detailed)
- At age 94, pioneer Turing award winner, computational complexity theory, Juris Hartmanis, died
- rhce homework
- SphereEx苗立尧:云原生架构下的Database Mesh研发实践
- BGP+MPLS Comprehensive Experiment
- Node installation and configuration (node-v12.20.2-x64 ) and introduction to node version switching
猜你喜欢

typescript ‘props‘ is declared but its value is never read 解决办法

关于ue4.27像素流送打包后的本地服务器问题

Node installation and environment variable configuration

MySQL 5.7 安装教程(全步骤、保姆级教程)

专家见解|经济低迷期把握创新机会的 3 大方法
![[npm install error report collection] - npm ERR! code ENOTEMPTY npm ERR! syscall rmdir](/img/c5/2c42e26e577506573985b30669ca6c.png)
[npm install error report collection] - npm ERR! code ENOTEMPTY npm ERR! syscall rmdir

MySQL(3)

Technology empowers Lhasa's "lungs", Huawei helps Lalu Wetland Smart Management to protect lucid waters and lush mountains

MySQL索引常见面试题(2022版)

HCIP day 3 experiment
随机推荐
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
Reverse resolve dns server
Go inside the basic knowledge
ASP.NET Core Web API 幂等性
ue先视频教程后深入
MySQL Advanced - MVCC (ultra-detailed finishing)
使用jOOQ 3.14合成外键在视图上写隐式连接
Nacos数据库配置
MySql -- 不存在则插入,存在则更新或忽略
July 18-July 31, 2022 (Ue4 video tutorials and documentation, 20 hours. Total 1412 hours, 8588 hours left)
Technology empowers Lhasa's "lungs", Huawei helps Lalu Wetland Smart Management to protect lucid waters and lush mountains
MySQL 23 classic interviews hang the interviewer
Project development specification
About the local server problem after ue4.27 pixel streaming package
MySQL联合查询(多表查询)
MySQL Advanced Statements (1)
The nacos source code can not find the istio package
typescript 'props' is declared but its value is never read solution
MySQL Advanced Statements (1)
nodejs的安装和全局配置(超详细哦)