Coder Social home page Coder Social logo

astro30 / valinvest Goto Github PK

View Code? Open in Web Editor NEW
150.0 4.0 28.0 76 KB

A value investing tool based on Warren Buffett, Joseph Piotroski and Benjamin Graham thoughts

License: MIT License

Python 100.00%
investing investment value-investing buffett piotroski graham python pandas numpy

valinvest's Introduction


Valinvest

A value investing tool based on Warren Buffett, Joseph Piotroski and Benjamin Graham thoughts

Welcome to Valinvest

๐Ÿ”ฅ Important update ๐Ÿ”ฅ

The Financial API used by valinvest to get financial data has been rewritten and now requires a API Key in order to make request. So, the first step now is to register on https://financialmodelingprep.com/login and get an API key. Keep it, you will need it to use valinvest ;)

โœจtl;dr โœจ

For a given stock ticker, valinvest calculates a score from 0 to 9. The higher the score, the better the company is according to the scoring methodology.

  1. Install it
pip install valinvest
  1. Calculate score
>>> import valinvest
>>> aapl = valinvest.Fundamental('AAPL', YOUR_API_KEY)
>>> aapl.fscore()
6.8

Table of contents ๐Ÿ“š

Introduction

The aim of the package is to evaluate a stock according to his fundamentals by setting a score and identify buy and sells opportunies through technical indicators.

Methodology description

The scoring methodology is based on Joseph Piotroski's study (Value Investing: The Use of Historical Financial Statement Information to Separate Winners from Losers). The F-Score is used to help financial investment decisions by finding the best value stocks on the market.

The Piostroski score is calculated based on 9 criteria divided into 3 groups:

Profitability

  • Return on Assets (1 point if it is positive in the current year, 0 otherwise)
  • Operating Cash Flow (1 point if it is positive in the current year, 0 otherwise)
  • Change in Return of Assets (ROA) (1 point if ROA is higher in the current year compared to the previous one, 0 otherwise)
  • Accruals (1 point if Operating Cash Flow/Total Assets is higher than ROA in the current year, 0 otherwise)

Leverage, Liquidity and Source of Funds

  • Change in Leverage (long-term) ratio (1 point if the ratio is lower this year compared to the previous one, 0 otherwise)
  • Change in Current ratio (1 point if it is higher in the current year compared to the previous one, 0 otherwise)
  • Change in the number of shares (1 point if no new shares were issued during the last year)

Operating Efficiency

  • Change in Gross Margin (1 point if it is higher in the current year compared to the previous one, 0 otherwise)
  • Change in Asset Turnover ratio (1 point if it is higher in the current year compared to the previous one, 0 otherwise)

This software calculates an alternate version of the F-Score as follows:

Growth

  • Net Revenue
  • EBITDA
  • Earnings per share (EPS)

Profitability

  • CROIC
  • ROIC

Debts

  • EBITDA cover ratio
  • Debt coverage

Market sensibility

  • Beta

Investment

  • Equity buyback

Installation

pip install valinvest

Examples

Starbucks Corporation (SBUX)

2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Score
REV_G 1 1 1 1 1 1 1 1 1 1 1
EBT_G 1 1 1 0 1 1 1 0 0 1 0.7
EPS_G 1 1 1 0 1 0 1 1 1 0 0.7
ROIC 0 0 1 0 0 0 0 0 0 0 0 0.1
CROIC 1 1 1 1 1 0 1 1 1 1 1 0.9
5YRS_BETA 1
EBITDA_COVER 1 1 1 1 1 1 1 1 1 1 1 1
DEBT_COST 0 0 0 0 1 1 1 1 1 1 1 0.7
EQ_BUYBACK 1 0 0 1 0 0 1 1 1 1 0.6
F-SCORE 6.7
>>> import valinvest
>>> sbux = valinvest.Fundamental('SBUX')
>>> sbux.fscore()
6.7

Apple Inc. (AAPL)

2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 Score
REV_G 1 1 1 1 1 1 0 1 1 0 0.8
EBT_G 1 1 1 0 1 1 0 1 1 0 0.7
EPS_G 1 1 1 0 0 1 0 1 1 0 0.6
ROIC 1 1 1 1 1 1 1 1 1 1 1 1
CROIC 1 1 1 1 1 1 1 1 1 1 1 1
5YRS_BETA 0
EBITDA_COVER 1 1 1 1 1 1 1 1 1 1 1 1
DEBT_COST 1 1 1 1 1 1 1 1 1 1 1 1
EQ_BUYBACK 1 0 0 1 0 1 1 1 1 1 0.7
F-SCORE 6.8
>>> import valinvest
>>> aapl = valinvest.Fundamental('AAPL')
>>> aapl.fscore()
6.8

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Credits

This software uses code from several open source packages:

valinvest's People

Contributors

astro30 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

valinvest's Issues

FutureWarning: The behavior of `series[i:j]` with an integer-dtype index is deprecated.

Hi,
Just tried the package and I get this warning.

/usr/local/lib/python3.9/dist-packages/valinvest/fundamentals.py:469: FutureWarning: The behavior of series[i:j] with an integer-dtype index is deprecated. In a future version, this will be treated as label-based indexing, consistent with e.g. series[i] lookups. To retain the old behavior, use series.iloc[i:j]. To get the future behavior, use series.loc[i:j].
return property[-years:].sum() / years
/usr/local/lib/python3.9/dist-packages/valinvest/fundamentals.py:469: FutureWarning: The behavior of series[i:j] with an integer-dtype index is deprecated. In a future version, this will be treated as label-based indexing, consistent with e.g. series[i] lookups. To retain the old behavior, use series.iloc[i:j]. To get the future behavior, use series.loc[i:j].
return property[-years:].sum() / years
/usr/local/lib/python3.9/dist-packages/valinvest/fundamentals.py:469: FutureWarning: The behavior of series[i:j] with an integer-dtype index is deprecated. In a future version, this will be treated as label-based indexing, consistent with e.g. series[i] lookups. To retain the old behavior, use series.iloc[i:j]. To get the future behavior, use series.loc[i:j].
return property[-years:].sum() / years
/usr/local/lib/python3.9/dist-packages/valinvest/fundamentals.py:374: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function.
stmt[stmt["header"] == "net_income"].groupby(
/usr/local/lib/python3.9/dist-packages/valinvest/fundamentals.py:435: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function.
stmt[stmt["header"] == "net_income"].groupby(
/usr/local/lib/python3.9/dist-packages/valinvest/fundamentals.py:469: FutureWarning: The behavior of series[i:j] with an integer-dtype index is deprecated. In a future version, this will be treated as label-based indexing, consistent with e.g. series[i] lookups. To retain the old behavior, use series.iloc[i:j]. To get the future behavior, use series.loc[i:j].
return property[-years:].sum() / years
/usr/local/lib/python3.9/dist-packages/valinvest/fundamentals.py:291: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function.
stmt[stmt["header"] == "net_income"].groupby(
/usr/local/lib/python3.9/dist-packages/valinvest/fundamentals.py:336: FutureWarning: The default value of numeric_only in DataFrameGroupBy.sum is deprecated. In a future version, numeric_only will default to False. Either specify numeric_only or select only columns which should be valid for the function.
stmt[stmt["header"] == "net_income"].groupby(

AttributeError: module 'pandas' has no attribute 'json_normalize'

File "", line 1, in
aapl = valinvest.Fundamental('AMD', '2e90d2fed0a9dc605ffcea7ef76954ff')

File "C:\Users\Tin\Anaconda3\lib\site-packages\valinvest\fundamentals.py", line 57, in init
self.statements = self._get_financial_statements()

File "C:\Users\Tin\Anaconda3\lib\site-packages\valinvest\fundamentals.py", line 116, in _get_financial_statements
res = pd.concat([res, self._get_financial_statement(statement)])

File "C:\Users\Tin\Anaconda3\lib\site-packages\valinvest\fundamentals.py", line 80, in _get_financial_statement
df = pd.json_normalize(res["financials"])

AttributeError: module 'pandas' has no attribute 'json_normalize'

module 'valinvest' has no attribute 'Fundamental'

Followed instructions in readme. Getting this error

AttributeError: module 'valinvest' has no attribute 'Fundamental'

Launching from Visual Studio using the following code

import valinvest

aapl = valinvest.Fundamental('AAPL', 'my key)
aapl.fscore()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.