Skip to content

Commit

Permalink
Optimize future class
Browse files Browse the repository at this point in the history
  • Loading branch information
lit26 committed Jun 17, 2024
1 parent 659b4b4 commit c61513f
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions finvizfinance/future.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,20 @@ def performance(self, timeframe="D"):
Returns:
df(pandas.DataFrame): forex performance table
"""
params = None
if timeframe == "D":
params = ""
elif timeframe == "W":
params = "?v=12"
elif timeframe == "M":
params = "?v=13"
elif timeframe == "Q":
params = "?v=14"
elif timeframe == "HY":
params = "?v=15"
elif timeframe == "Y":
params = "?v=16"
else:
timeframe_dict = {
'W': 12,
'M': 13,
'Q': 14,
'HY':15,
'Y': 16
}
params = {}
if timeframe in timeframe_dict:
params['v'] = timeframe_dict[timeframe]
elif timeframe != 'D':
raise ValueError("Invalid timeframe '{}'".format(timeframe))

soup = web_scrap("https://finviz.com/futures_performance.ashx" + params)
soup = web_scrap("https://finviz.com/futures_performance.ashx", params)

html = soup.prettify()
data = html[
Expand Down

0 comments on commit c61513f

Please sign in to comment.