-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raw_to_Xy raises KeyError #118
Comments
This is the whole Error-message:
|
Hey! Thank you for your interest! Hmmm, I am not sure where it comes from. Could you please upload your Cheers |
Hello Jan, thanks for helping me out. I am not sure if this is the best way to share my DataFrame, if you need it in a different format just tell me. Its the result of the yfinance package with the function
|
So the problem is that Line 263 in eb6c858
The reason why 0's are not supported is because one then computes per day percentage changes which would lead to division by zero. I guess the simplest way around this is to replace 0's with NAN's and that way the from deepdow.utils import raw_to_Xy
import numpy as np
import yfinance as yf
tickers = [
"1COV.DE",
"MRK.DE",
"LIN.DE",
"FRE.DE",
"DWNI.DE",
"BEI.DE",
"MUV2.DE",
"DPW.DE",
"BAS.DE",
"VOW3.DE",
"SIE.DE",
"CON.DE",
"VNA.DE",
"RWE.DE",
"HEN3.DE",
"ALV.DE",
]
raw_df = yf.download(tickers = tickers,
start="2010-01-01",
end="2021-01-01",
interval = "1d",
group_by = 'ticker',
)
print((raw_df == 0).sum().sum())
raw_df_adj = raw_df.replace(0, np.nan)
print((raw_df_adj == 0).sum().sum())
lookback, gap, horizon = 5, 2, 4
X, timestamps, y, asset_names, indicators = raw_to_Xy(raw_df_adj,
lookback=lookback,
gap=gap,
freq="B",
horizon=horizon) Standard output: [*********************100%***********************] 16 of 16 completed
223
0 Anyway, maybe |
Ah, that make sense! The code is running now, thanks! |
Yes, exactly! The |
Perfect! Thanks a lot for your help! |
Hello,
I am running into a weird error, that I don't understand. I used Yahoo Finance to download a DataFrame with the Index of
MultiIndex([( 'SIE.DE', 'Open'),
( 'SIE.DE', 'High'),
( 'SIE.DE', 'Low'),
( 'SIE.DE', 'Close'),
( 'SIE.DE', 'Volume'),
('EOAN.DE', 'Open'),
('EOAN.DE', 'High'),
('EOAN.DE', 'Low'),
('EOAN.DE', 'Close'),
('EOAN.DE', 'Volume'),
...
('BAYN.DE', 'Open'),
('BAYN.DE', 'High'),
('BAYN.DE', 'Low'),
('BAYN.DE', 'Close'),
('BAYN.DE', 'Volume'),
( 'BEI.DE', 'Open'),
( 'BEI.DE', 'High'),
( 'BEI.DE', 'Low'),
( 'BEI.DE', 'Close'),
( 'BEI.DE', 'Volume')],
length=150)
So I have a DataFrame, where there are the Assets in the zero level and the first level being indecators. If i run now the raw_to_Xy Function like this
I receive an KeyError: 'Open' with the explanation
I tried to stay as close to the documentation as possible and don't see, where I am wrong.
Other than that: Great repository, I am really fascinated by all the possibilties that this gives for modern Portfolio Optimization!
The text was updated successfully, but these errors were encountered: