当前位置:网站首页>解决:- 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
输出结果:
如果想要测试代码,自己可以按照上述字段来,这就是使用的格式了
边栏推荐
- node安装及环境变量配置
- 2022年8月计划,着重ue4视频教程
- MySql统计函数COUNT详解
- MySql COUNT statistics function explanation
- npm ---- install yarn
- Node installation and environment configuration
- DNS resolution process
- Reverse resolve dns server
- At age 94, pioneer Turing award winner, computational complexity theory, Juris Hartmanis, died
- BGP+MPLS Comprehensive Experiment
猜你喜欢
APT + Transform 实现多模块应用Application生命周期分发
Nacos database configuration
chrome 插件开发指南
MySQL高阶---存储引擎、索引、锁
(笔记整理未完成)【图论】图的遍历
zabbix email alarm and WeChat alarm
Toolbox App 1.25 New Features at a Glance | Version Update
Analysis of the source code of the JS UI framework of Hongmeng system
MySQL高级SQL语句(二)
Specified URL is not reachable,caused by :‘Read timed out
随机推荐
About the local server problem after ue4.27 pixel streaming package
Servlet
推出 Space On-Premises (本地部署版) Beta 版!
mysql高阶语句(一)
.NET Static Code Weaving - Rougamo Release 1.1.0
APT + Transform to realize multi module Application distributed Application life cycle
享年94岁,图灵奖得主、计算复杂性理论先驱Juris Hartmanis逝世
MySQL 5.7 安装教程(全步骤、保姆级教程)
Ant three sides: MQ message loss, duplication, backlog problem, what are the solutions?
MySQL classic 50 practice questions and the most detailed analysis of the whole network
CAT1 4G+Ethernet development board Tencent cloud mobile phone WeChat applet display temperature and delivery control
MySQL 23 classic interviews hang the interviewer
(Notes are not completed) [Graph Theory] Traversal of graphs
Analysis of port 9848 error at startup of Nacos client (non-version upgrade problem)
Pagoda+FastAdmin 404 Not Found
MySQL - Multi-table query and case detailed explanation
有点奇怪!访问目的网址,主机能容器却不行
Py's mlxtend: a detailed guide to the introduction, installation, and usage of the mlxtend library
nodejs的安装和全局配置(超详细哦)
一文搞懂C操作符