Closed deeleeramone closed 2 years ago
myself and @deeleeramone no longer see this
Reopening because I am now seeing this again.
I'm going to try to take this one. I'm also seeing it in stocks/options
Learned some things yesterday:
It occurred to me that this expiration is a "standard" expiration instead of a weekly one. So i checked other expirations and was unable to reproduce the warning for:
Needs more investigation. My current theory is that it may be related to the expiration being a "standard" within a month that also contains weekly ones. Not sure why that would be the case, but I'm going to have to keep testing.
Interesting. Any thoughts here, @jmaslek?
Does the command still work?
If it's just the warning that's usually just a pandas thing like the warning says
It does work, but it would be nice to get rid of these messages.
User report from this morning, where it doesn't work:
I did some more research last night and found a couple of things:
the warning occurs only when some of the options in the chain have implied volatility <= 0. Those rows are filtered out in yfinance_model, line 72:
df_list = [x[x["impliedVolatility"] > 0] for x in df_list]
On line 80, when greeks are set, we're now modifying a slice of the original DataFrame. This only happens if there isn't enough activity for a certain option and the price remains constant, which is why this warning only appears intermittently.
There's no reason to keep the original df, so adding a .copy()
statement will permanently handle the warning
df_list = [x[x["impliedVolatility"] > 0].copy() for x in df_list]
I don't know why the warning is intermittent and it stopped appearing mid-testing last night (seems to be back this morning).
But, I actually found an unrelated issue that does break the functionality.
The --export
flag no longer works for stocks/ba:
I can fix this pretty easily, but it's related to the same code that is likely causing the SettingWithCopyWarning. Should I make it a separate issue?
queries --export csv
does break it in my installer package version.
Do we need a new issue, or, just keep this one evolving because it is the same command it was raised for, @DidierRLopes?
My two cents:
I can fix the export problem and both SettingWithCopyWarnings immediately with just a few tweaks. I am just working on updating the pytests because they don't appear to be properly checking whether the --export flag works correctly.
The other error (related to Google returning 429) is going to be a bit more involved. We'll have to look at the core _get_data() function and figure out how to make it return something that is acceptable to all of the other functions that call it. Right now, it raises an exception, but then it still returns the rest of the JSON response. Shouldn't be too tricky, but it's definitely a separate set of considerations, in my opinion.
stocks/ba/queries - SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.
Does not break the terminal, but prints a warning message.