hotfix/options-stats-index-rename: renames the index column to 'strike' when get_stats('strike') (#5160)

* renames the index column to 'strike' when get_stats('strike')

* black

---------

Co-authored-by: James Maslek <jmaslek11@gmail.com>
This commit is contained in:
Danglewood
2023-06-20 13:01:26 -07:00
committed by GitHub
parent 8a70c6205d
commit 346e4bc89b

View File

@@ -1158,9 +1158,9 @@ def calculate_stats(options: object, by: Optional[str] = "expiration") -> pd.Dat
stats["Total Volume"] = stats["Calls Volume"] + stats["Puts Volume"]
stats["Volume Ratio"] = round(stats["Puts Volume"] / stats["Calls Volume"], 2)
stats["Vol-OI Ratio"] = round(stats["Total Volume"] / stats["Total OI"], 2)
if by == "strike":
stats.rename_axis("Strike", inplace=True)
stats.rename_axis("Expiration", inplace=True)
if by == "strike":
stats.rename_axis(index={"Expiration": "Strike"}, inplace=True)
return stats.replace([np.nan, np.inf], None)