Skip to content

nthanhtung/vn_stock_analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


key feature

OLAP cube to analyze data in multiple dimensions

  • symbol
  • industry
  • time period

fundamental analysis

  • free cash flow to firm (fcff) valuation:
  • et asset valuation
  • financial ratio: p/e, p/b
  • year over year growth rate
  • what if analysis to build financial model

technical analysis

  • candle signal
  • macd, sma, rsi, volume signal

how to setup

1. manual install wheel file in folder /dependency

file name: TA_Lib-0.4.21-cp39-cp39-win_amd64.whl

2. install all library in requirements.txt

pip install -r requirements.txt

3. download data & template power bi report

link: https://drive.google.com/drive/folders/1bCgw5kKVVOLYC3QKsSSrR3_KIb1JAmn_?usp=sharing

4. edit data path

  • in power bi: parameter in utility
  • in python code: /test/x.py

5. run python script in folder script/python to get daily data

    1. script switch_dir.py
    1. script etl.py : only need to load daily data
  • Note: you can build this project as wheel file, then install vn_stock_analysis wheel file, then you don't need to run switch_dir.py

6. export forecast data

in power bi, go to tab : Export Forecast Data export to location: data/pbi/finance_data_year_forecast.csv

hardcoded rule to clean data

  • if eps = 0 then eps = eps average all period
  • if eps average > 4000 then eps average = 4000
  • if eps average < -4000 then eps average = -4000
  • return rate of market = return of vnindex 21 year

my key learning from this project:

  • OOP
  • Selenium
  • OLAP cubes
  • Technical Analysis
  • Fundamental Analysis

below part is in progress (to be completed)

use case

stock scan based on signal:

  • technical analysis
  • fundamental analysis

stock correlation with relevant commodity:

  • HPG with steel
  • PNJ with gold
  • PVS with VNindex

data source

data source
https://www.cophieu68.vn/export.php
https://finfoapi-hn.vndirect.com.vn/stocks/adPrice?symbols=HOSE&fromDate=2015-01-01&toDate=2021-05-31
https://finfo-api.vndirect.com.vn/v3/stocks/financialStatement?secCodes=VNM&fromDate=2017-06-30&toDate=2019-06-30
stock price hourly last 5 day
https://dchart-api.vndirect.com.vn/dchart/history?resolution=5&symbol=VNM&from=1620000000&to=1622893022
financial data year end, quarter end
https://finfo-api.vndirect.com.vn/v3/stocks/balanceSheet?secCodes=VNM&fromDate=2019-01-01&toDate=2019-12-31
https://finfo-api.vndirect.com.vn/v3/stocks/financialStatement?secCodes=VNM&reportTypes=QUARTER&fromDate=2017-06-30&toDate=2019-06-30
stock price daily: https://finfoapi-hn.vndirect.com.vn/stocks/adPrice?symbols=VNM&fromDate=2015-01-01&toDate=2021-05-31

example template

example template

https://github.com/wilsonfreitas/awesome-quant
https://pypi.org/project/finance-calculator/
https://indzara.com/stock-market-templates/
https://stackoverflow.com/questions/39501277/efficient-python-pandas-stock-beta-calculation-on-many-dataframes

E

get data 20 y 1 shot
get data this y daily
VN data: higher prority
    firm finance statement
    price & volume data
    stock symbal mapping: industry
World data:
    US stock market
    Comodity price

T

technical analysis
fundamental analysis
benchmark analysis:
    industry
    regional, global
backtest & strategy efficiency analysis
stock correlation with relevant commodity

L

write semantic layer data to yearly file

design

text diagram sttm report template: excel/power bi/web mockup


market gap in stock trading analysis tool

stock valuation tool:
    input:
        growth assumption
        market risk


stock scan based on stock valuation


industry benchmarking tool:
    p/e
    p/b
    beta
    vs us, asean

Discounted cash flow (DCF) valuation views the intrinsic value of a security

cash flows actually paid to stockholders
    dividend discount model (DDM)
cash flows available for distribution to shareholders
    free cash flow to the firm (FCFF)
    free cash flow to equity (FCFE)
    analysts consider free cash flow models to be more useful than DDMs in practice
    Free cash flows provide an economically sound basis for valuation
market multiples

practice
    residual income
    dividend discount
    discounted free cash flow
    FCFF models are used roughly twice as frequently as FCFE models
    Analysts like to use free cash flow as the return (either FCFF or FCFE)
        The company does not pay dividends.
        Free cash flows align with profitability within a reasonable forecast period with which the analyst is comfortable.

Calculation

FCFF = CFO + Int(1 – Tax rate) – FCInv.

FCFE = CFO – FCInv + Net borrowing.

Equity value = Firm value – Market value of debt.

Dividing the total value of equity by the number of outstanding shares gives the value per share.


WACC = (E/V x Re) + ((D/V x Rd) x (1 – T))

Where:

E = market value of the firm’s equity (market cap) D = market value of the firm’s debt V = total value of capital (equity plus debt) E/V = percentage of capital that is equity D/V = percentage of capital that is debt Re = cost of equity (required rate of return) Rd = cost of debt (yield to maturity on existing debt) T = tax rate

Re = Rf + β × (Rm − Rf)

Where:

Rf = the risk-free rate (typically the 10-year U.S. Treasury bond yield) β = equity beta (levered) Rm = annual return of the market

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages