-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Future | ||
************************** | ||
|
||
Getting future information. | ||
|
||
.. automodule:: finvizfinance.future | ||
:members: | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,7 @@ Contents | |
Insider <insider> | ||
Forex <forex> | ||
Crypto <crypto> | ||
Future <future> | ||
Earnings <earnings> | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from finvizfinance.util import webScrap, imageScrapFunction | ||
import pandas as pd | ||
import json | ||
|
||
""" | ||
.. module:: future | ||
:synopsis: future. | ||
.. moduleauthor:: Tianning Li <ltianningli@gmail.com> | ||
""" | ||
|
||
class Future: | ||
"""Future | ||
Getting information from the finviz future page. | ||
""" | ||
def __init__(self): | ||
"""initiate module | ||
""" | ||
pass | ||
|
||
def performance(self, timeframe='D'): | ||
"""Get forex performance table. | ||
Args: | ||
timeframe (str): choice of timeframe(D, W, M, Q, HY, Y) | ||
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: | ||
raise ValueError() | ||
|
||
soup = webScrap('https://finviz.com/futures_performance.ashx'+params) | ||
data = soup.text[soup.text.find('var rows = ')+11:soup.text.find('FinvizInitFuturesPerformance(rows);')] | ||
data = json.loads(data.strip()[:-1]) | ||
df = pd.DataFrame(data) | ||
return df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters