Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
lit26 committed Aug 18, 2020
1 parent 7ae85d3 commit cc680aa
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Tianning Li'

# The full version, including alpha/beta/rc tags
release = '0.5.1'
release = '0.6'


# -- General configuration ---------------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions docs/earnings.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Forex
**************************

Getting earning dates information.

.. automodule:: finvizfinance.earnings
:members:



1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Contents
Insider <insider>
Forex <forex>
Crypto <crypto>
Earnings <earnings>


Indices and tables
Expand Down
61 changes: 61 additions & 0 deletions example/example.ipynb

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions finvizfinance/earnings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import os
import pandas as pd
from finvizfinance.screener.financial import Financial
from finvizfinance.screener.overview import Overview
from finvizfinance.screener.valuation import Valuation
from finvizfinance.screener.ownership import Ownership
from finvizfinance.screener.performance import Performance
from finvizfinance.screener.technical import Technical
"""
.. module:: earnings
:synopsis: earnings.
.. moduleauthor:: Tianning Li <[email protected]>
"""

class Earnings:
"""Earnings
Partition dataframe of ticker information of period of earning dates(This Week,
Next Week, Previous Week, This Month) into dates
"""
def __init__(self):
"""initiate module
"""
self.earning_days = []
self.df_days = {}
self.df = None
self.period = ''

def setPeriod(self, period='This Week'):
"""Set the period.
Args:
period(str): choose an option of period(This Week, Next Week,
Previous Week, This Month).
"""
check_list = ['This Week', 'Next Week', 'Previous Week','This Month']
if period not in check_list:
print('Available period: {}'.format(check_list))
raise ValueError()
self.period = period
ffinancial = Financial()
filters_dict = {'Earnings Date': period}
ffinancial.set_filter(filters_dict=filters_dict)
self.df = ffinancial.ScreenerView(order='Earnings Date', verbose=0)
self.earning_days = list(set(self.df['Earnings'].to_list()))
self.earning_days.sort()

def partitionDays(self, mode='financial'):
"""Partition dataframe to separate dataframes according to the dates.
Args:
mode(str): choose an option of period(financial, overview, valuation, ownership,
performance, technical).
"""
check_list = ['financial', 'overview', 'valuation', 'ownership','performance','technical']
if mode not in check_list:
print('Available mode: {}'.format(check_list))
raise ValueError()

for earning_day in self.earning_days:
if mode == 'financial':
self.df_days[earning_day] = self.df[self.df['Earnings'] == earning_day].reset_index(drop=True)
else:
self.df_days[earning_day] = self.df[self.df['Earnings'] == earning_day]['Ticker'].to_list()

fearnings = None
if mode == 'financial':
return self.df_days
elif mode == 'overview':
fearnings = Overview()
elif mode == 'valuation':
fearnings = Valuation()
elif mode == 'ownership':
fearnings = Ownership()
elif mode == 'performance':
fearnings = Performance()
elif mode == 'technical':
fearnings = Technical()

filters_dict = {'Earnings Date': self.period}
fearnings.set_filter(filters_dict=filters_dict)
df2 = fearnings.ScreenerView(order='Earnings Date', verbose=0)
df2_days = {}
for earning_day in self.earning_days:
tickers = self.df_days[earning_day]
df2_days[earning_day] = df2[df2['Ticker'].isin(tickers)].reset_index(drop=True)
self.df_days = df2_days
return self.df_days

def outputExcel(self,output_file='earning_days.xlsx'):
"""Output dataframes to single Excel file.
Args:
output_file(str): name of the output excel file.
"""
print('Print to Excel...')
with pd.ExcelWriter(output_file,
datetime_format='YYYY-MM-DD',
engine='xlsxwriter') as writer:
for name, df in self.df_days.items():
sheet_name = '_'.join(name.split('/'))
df.to_excel(writer, sheet_name=sheet_name, index=False)

def outputCSV(self, output_dir='earning_days'):
"""Output dataframes to csv files.
Args:
output_dir(str): name of the output directory.
"""
print('Print to CSV...')
isdir = os.path.isdir(output_dir)
if not isdir:
os.mkdir(output_dir)
for name, df in self.df_days.items():
file_name = '_'.join(name.split('/'))
df.to_csv(output_dir+'/'+file_name+'.csv',index=False)
4 changes: 3 additions & 1 deletion finvizfinance/forex.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def __init__(self):

def performance(self, change='percent'):
"""Get forex performance table.
Args:
change (str): choose a option of change(percent, PIPS)
change (str): choose an option of change(percent, PIPS)
Returns:
df(pandas.DataFrame): forex performance table
Expand All @@ -36,6 +37,7 @@ def performance(self, change='percent'):

def chart(self, forex, timeframe='D'):
"""Get forex chart.
Args:
forex (str): foreign exchange name
timeframe (str): choice of timeframe(5M, H, D, W, M)
Expand Down
7 changes: 4 additions & 3 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
| Date | Version | Comment |
| ------------- | ------------- | ------------- |
| 2020/08/13 | 0.6 | Add earning module |
| 2020/08/13 | 0.5.1 | Fix bug in group folder |
| 2020/08/13 | 0.5 | Update Quote module and add compare function to screener |
| 2020/08/13 | 0.4.1 | Adding group spectrum module |
| 2020/08/13 | 0.4 | Adding group folder |
| 2020/08/13 | 0.3 | Adding forex and crypto module |
| 2020/08/13 | 0.4.1 | Add group spectrum module |
| 2020/08/13 | 0.4 | Add group folder |
| 2020/08/13 | 0.3 | Add forex and crypto module |
| 2020/08/02 | 0.2.3 | Update filter in screener |
| 2020/08/02 | 0.2.2 | Fix a bug in screen order|
| 2020/07/31 | 0.2.1 | Add order to screen module |
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

HERE = pathlib.Path(__file__).parent

VERSION = '0.5.1'
VERSION = '0.6'
PACKAGE_NAME = 'finvizfinance'
AUTHOR = 'Tianning Li'
AUTHOR_EMAIL = '[email protected]'
Expand All @@ -19,7 +19,8 @@
'datetime',
'requests',
'bs4',
'lxml'
'lxml',
'os'
]
CLASSIFIERS = [
'Programming Language :: Python :: 3.5',
Expand Down

0 comments on commit cc680aa

Please sign in to comment.