Code Monkey home page Code Monkey logo

vnstock's Introduction

Welcome to Thinh's space

🐳 About me

  • 🔭 Crafting Vietnam's Financial Landscape with vnstock — Open Source, Quality Code, and a Data-Driven Commitment to Automated Excellence.

🔨 Languages and Tools :

Python  JavaScript  CSS  HTML  PostgresSQL  Bash     

🔥 My Stats :

GitHub Streak

Thinh Vu's GitHub stats

Top Langs


♥️ What I love doing

a. Focused projects

  • Thinh Vu Blog - My lifelong learning journey
  • Vnstock - Empowering Smart Investment Analysis in the Vietnam Stock Market with vnstock.
  • LEarn Anything - Ignite the passion for learning and exploration with LEarn Anything!

b. Popular blog posts

  1. The complete Google Colab 101 tutorial
  2. vnstock - Load Vietnam stock market data to your data pipeline with Python via API
  3. 10 tips of self-studying Data Analysis with Python
  4. The Complete Guide to Using Obsidian

c. Personal stories

  1. Python for Data analysis - Getting Started with Jupyter Notebook, Google Colab, and Rasberry Pi
  2. How did I fall in love with Python? My personal stories on experiencing data analysis tools

vnstock's People

Contributors

andrey-jef avatar hungdq11 avatar nvh95 avatar thinh-vu 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  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

vnstock's Issues

List of tickets that is not available via listing_companies()

VVS,XDC,HSV,CST,BVL,SGI,TOS,VTZ,SSH,BCA,FUCTVGF3,FUEIP100,GMH,BIG,CMM,CNA,FUEKIV30,ODE,HMR,PCH,DSD,NO1,MGR,PPT,CVP,CAR,GPC,FUCTVGF4,FUEDCMID,FUEKIVFS,FUEMAVND,GCF,LPT,ACS,ACV,AFX,CKA,AGP,CAG,LTG,AGG,AGX,AG1,AGE,ACG,ANT,APH,APL,HII,A32,ASG,ATG,AVC,BAF,BAL,BCV,BNA,BRR,CBC,BLW,VLB,BBH,BBT,BCB,BCP,MVC,BFC,BDG,BSA,PRT,BEL,NBT,BGW,BHK,BHP,BCM,BLT,DBD,BHG,BIO,BWE,BKG,BLI,MH3,DTB,BMD,BMG,BMS,MBN,BNW,VTG,BSP,BSR,BTN,BTD,BTV,BLN,BVN,TNH,BWA,BWS,HNB,C69,C22,C71,TS3,CPA,CFV,CCT,CCA,HFB,CMW,KCB,CBS,VSM,CDH,CDG,CRE,STK,TW3,CFM,CH5,CHC,CLX,CI5,CE1,CEG,C4G,C12,CKG,CIP,CBI,CK8,CMK,ADG,CMF,TVH,TIN,CMD,CAT,CC1,CDP,TCK,CMN,ICN,CNN,DP1,DTP,CPH,CIA,CRC,SGP,CT3,GTS,ICT,TTS,AUM,DCR,DCG,DRG,DRI,UDL,DWC,DHB,ADS,DAN,DNE,DAP,DAS,DPG,TDB,VBG,DCF,DM7,DC1,TTE,DLM,DUS,NSS,DNW,DND,CDN,DSC,DNT,DOC,MCD,BSD,DMN,DOP,CDR,DWS,DPP,DP2,DSV,BDT,DTN,DTV,MTV,MGG,DVC,DSG,DVW,DXS,FUESSV50,E1VFVN30,E29,EME,EMG,EMS,EPC,FUESSVFL,EVG,EVF,EIC,LEC,FHS,ROS,FBA,FIC,FIR,FSO,ART,FOC,FBC,FCS,FRM,DP3,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,XHC,XMP,YBM,YEG,YTC

Add Vnstock command line

hi @thinh-vu
Bạn có thể thêm module command line cho app vnstock , thì sẽ dễ sử dụng hơn
Ví dụ như:
vnstock list -a Show toan bộ công ty
vnstock price -s HPG , -> show gia của HPG

Rồi bổ sung thêm dần dần :)))

Dữ liệu vnindex chỉ đến năm 2020

Mô tả lỗi
Mô tả một cách rõ ràng và ngắn gọn về lỗi.

stock_historical_data('VNINDEX', '2013-01-01', '2023-11-11', '1D, 'index')

Dữ liệu chỉ chạy đến ngày 5/11/2020. Lỗi này chỉ xảy ra với vnindex, các symbol khác vẫn có data cũ hơn.

FR: implement QA / test for vnstock

Yêu cầu tính năng có liên quan đến một vấn đề? Vui lòng mô tả.
Hiện ko thấy phần QA test cho vnstock. Phần này có thể giúp contributors chạy unit test, tăng độ tin cậy hơn khi đóng góp code

Mô tả giải pháp bạn muốn
Dùng pytest.
Folder structure:

vnstock
    |_ vnstock
    |_ docs
    |_ test

Mô tả các giải pháp hoặc tính năng thay thế bạn đã xem xét
N/A

Bổ sung thông tin
Nếu maintainer thông qua thì m có thể bắt đầu từ test case cho "funds.py" của issue này.

Báo lỗi cho tính năng

data lấy từ database không cùng đơn vị, có thể là đơn vị nghìn đồng hoặc đồng. Không lọc sạch được data vì có những cổ phiếu lên tới 1 triệu 1 cổ, có cổ chỉ vài trăm đồng. Nếu cổ có giá trị 900 thì k biết được là 900 đồng hay 900 nghìn. cách duy nhất lúc này là loại những cổ có giá trị quá thấp đi thì mới dùng được data.

retry when connection time out

Sometimes the request will be timeout. This is the way i fix it.
from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry session = requests.Session() retry = Retry(connect=3, backoff_factor=0.5) adapter = HTTPAdapter(max_retries=retry) session.mount('http://', adapter) session.mount('https://', adapter)
and then replace request.get() by session.get()

Dữ liệu data bị trùng

Mô tả lỗi
Một số trường hợp data dữ liệu trả về bị trùng, ví dụ

image

Đây là data của vjc, khi xuất ra csv thì có đến 2 dòng cùng 1 ngày

Báo lỗi cho tính năng

Mô tả lỗi
Số lượng khớp lệnh không đúng với thức tế.

Cách tái hiện lại lỗi để xử lý
Các bước để tái hiện sự cố:
Sử dụng hàm stock_historical_data:
image

Mong muốn đạt được
Số lượng khớp lệnh đúng với thực tế.

Ảnh chụp màn hình
image

Máy tính để bàn (vui lòng cung cấp thông tin sau):

Bổ sung thông tin

VNINDEX chỉ số ra số sai

Mô tả lỗi
2023-10-26,1081210,1083220,1049710,1055450,1171656703,VNINDEX
2023-10-27,1059570,1061870,1037460,1060620,675686016,VNINDEX
2023-11-01,1029430,1039660,1020010,1039660,674512192,VNINDEX
2023-11-02,1039859,1075470,1039859,1075470,767166720,VNINDEX
2023-11-03,1077640,1082230,1071110,1076780,739651904,VNINDEX

Chỉ số nên là 1077,64 ví dụ vậy, có vẻ như đã nhân thêm 1000 không hợp lý

Không thể import thư viện

Mô tả lỗi
Không thể import thư viện, báo lỗi TypeError: 'type' object is not subscriptable

Cách tái hiện lại lỗi để xử lý
Các bước để tái hiện sự cố:

  1. Chạy lệnh cài đặt: pip install vnstock
  2. Sử dụng Pycharm hoặc Jupyter Notebook, chạy code mẫu của tác giả (https://colab.research.google.com/github/thinh-vu/vnstock/blob/beta/docs/gen2_vnstock_demo_index_all_functions_testing_2023.ipynb#scrollTo=kfKcYDxc6wlu)
  3. Gặp lỗi

Mong muốn đạt được
Code chạy bình thường.

** Screenshot
image

Máy tính để bàn (vui lòng cung cấp thông tin sau):

  • Hệ điều hành: Ubuntu 20.04
  • Phiên bản: 0.2.8.7, nguồn Pypi

Discuss: Is it redundant to add column label translation in code?

By trying the docs format of openbb with vnstock, in this PR #102 , i wonder:

  • Is it redundant to add column label translation in code?
  • Or just leave the label as default and add description only in the appropriate docs page? Since mkdocs-material already support i18n

Benefits: much more concise and easier to read code

Another issue has also raised up while writing this docs page. vnstock does not have a proper data model for result output

  • Currently we use spaghetti code to handle exception/error and data validation. As a reference, openbb apply an OOP paradigm, with the use of pydantic package for data model.
  • Someone will review this in the future, when vnstock can expand beyond its current structure.

Enhance features & functions for vnstock v 1.0.6

  • Revised and categorized the usage of features and functions into 5 main pillars:
    1. Market Watch
    2. Fundamental Analysis
    3. Technical Analysis
    4. Stock Pick
    5. Trading Center
  • Improved the structure and usability of existing functions.
  • Added new functions to support enhanced capabilities in Fundamental Analysis and Stock Pick.

`financial_ratio_compare` trả về "Excel file format cannot be determined, you must specify an engine manually."

Mô tả lỗi
Hàm financial_ratio_compare không hoạt động. Dữ liệu trả về không phải định dạng Excel

Cách tái hiện lại lỗi để xử lý
Các bước để tái hiện sự cố:

  1. Sử dụng VSCode
  2. Sử dụng hàm 'financial_ratio_compare'
  3. Thực thi lệnh financial_ratio_compare(symbol_ls=["CTG", "TCB", "ACB"], industry_comparison=True, frequency='Yearly', start_year=2022) như trên docs.
  4. Gặp lỗi "Excel file format cannot be determined, you must specify an engine manually" giống financial_ratio trước đây.

Mong muốn đạt được
Fix lỗi như ver 0.2.8.8

Ảnh chụp màn hình
image

Máy tính để bàn (vui lòng cung cấp thông tin sau):

  • Hệ điều hành: Win 11

khá nhiều function hoạt động khi chạy không cho ra kết quả nhu document readme.md

@thinh-vu
ví dụ như hàm ,

pip install vnstock
from vnstock import *
df = stock_historical_data(symbol='VNM',
start_date="2021-01-01",
end_date='2022-02-25')
print(df.head())

result ,
[2 rows x 50 columns]
Open High Low Close Volume TradingDate
0 98565.0 98655.0 97936.0 98206.0 2299600 2021-01-04
1 98654.0 101556.0 98292.0 100468.0 4013900 2021-01-05
2 100649.0 100921.0 99561.0 99561.0 2823100 2021-01-06
3 99742.0 100468.0 99561.0 100105.0 2453000 2021-01-07
4 101103.0 102372.0 100559.0 101556.0 3323000 2021-01-08

Khi mình lấy cái quả , nó chỉ hiện 5 kết quả ra thôi :)))
Mình là dev ,mà khi cài lib . để sử dụng mà cug thấy khá khoai:)) ). Vẫn mất thời gian mò vào lib

 Cảm ơn bác vì cái api này vẫn chạy được :>>>

Dạo trước e vẫn lấy data trên investing.com, nhưng được cái bị chặn liên tục, hqua vô lại thì k vào được :> nay tìm được bác mừng quá. Cảm ơn ạ. Update cho mọi người là vẫn dùng được thôi :>

Thông tin sai lệch so với báo cáo tài chính

Chào a Thịnh, hiện tại em đang dùng vnstock api để lấy bản báo cáo tài chính của ngân hàng VCB thì tại mục tiền gửi tại ngân hàng nhà nước qua các năm đều bằng 0, khác với bản cáo tài chính được công bố. Mong nhận được phản hồi từ anh.
imgcap

the unit on price

When i get price of stock 'CET':

df =  stock_historical_data(symbol='CET',start_date="2023-06-30",end_date='2023-07-04')
df
                       time  open  high  low  close  volume
0 2023-06-30 09:00:00+07:00   9.1   9.1  8.6    8.6   13200
1 2023-07-03 09:00:00+07:00   9.0   9.1  8.4    8.5   15400

The unit is in 1000 VND or not?

Please add unit for financial report

from vnstock import *
df = financial_flow(symbol='pvc',report_type='incomestatement',report_range='yearly')
df['shareHolderIncome'].head(5)
index
2023    20
2022    12
2021     8
2020     5
2019    22

What is the unit for every year's data?trillion or billion or million?

Function price_board trả số liệu sai

Fuction price_board đang gọi đến api "https://apipubaws.tcbs.com.vn/stock-insight/v1/stock/second-tc-price?tickers=MWG"
Ngay lúc này api này trả về kết quả
{ "data": [ { "t": "MWG", "fv": 1.57, "mav": 3.84, "nstv": 268600, "nstp": 27.0, "rsi": 67.9774, "macdv": 0.00, "macdsignal": "Neutral", "tsignal": "Buy", "avgsignal": "Strong Buy", "ma20": 43002.5, "ma50": 40632.0, "ma100": 40334.5, "session": 1, "mw3d": 5.0, "mw1m": 8.9, "mw3m": 16.4, "mw1y": -28.9, "rs3d": 93.0, "rs1m": 80.0, "rs3m": 61.0, "rs1y": 9.0, "rsavg": 61.0, "hp1m": 45500, "hp3m": 45500, "hp1y": 74100, "lp1m": 40650, "lp3m": 37700, "lp1y": 37700, "hp1yp": -38.6, "lp1yp": 20.7, "pe": 24.9, "pb": 2.8, "roe": 0.117042, "oscore": 3.8, "av": 64800, "bv": 91200, "ev": 47892, "hmp": 44000, "mscore": 0.68, "delta1m": 6.2, "delta1y": -27.9, "seq": 1688716740, "vnid3d": 0.3, "vnid1m": 2.7, "vnid3m": 6.3, "vnid1y": -1.0, "cp": 45050.0, "vnipe": 13.6522, "vnipb": 1.65116 } ] }
Theo như kết quả này giá của cổ phiếu đang là 45050 nhưng giá trên bảng giá của tcbs đang là 45500.
photo_2023-07-08_17-40-44

Enhance vnstock v1.0.3

  • Enhance data output from existing functions
  • Update README and documentation
  • Add new functions related to financial analysis
  • Allow downloading VN INDEX data
  • Allow changing stock_historical_data data resolution from day as default into week, month

HTTP Error 404: Not Found

Hi, I am new to the packages and currently try to use but I get this error because of HTTP. I had tried on my PC and Colab with a different version (0.1.3 and 0.1.4) and still get the same error. Could you help me with this!

Thanks in advance

image

Dữ liệu data khung thời gian nhỏ có vấn đề

Lấy ví dụ như dữ liệu của NT2, khung thời gian 30p:

                    time   open   high    low  close  volume ticker
0    2024-02-15 09:00:00  25010  25010  25010  25010    1500    NT2
1    2024-02-15 09:30:00  24910  24910  24910  24910     200    NT2
2    2024-02-15 10:00:00  24960  24960  24960  24960     500    NT2
3    2024-02-15 10:30:00  24960  24960  24960  24960     200    NT2
4    2024-02-15 11:00:00  25010  25010  25010  25010     100    NT2
..                   ...    ...    ...    ...    ...     ...    ...
193  2024-03-15 11:00:00  25100  25100  25100  25100     100    NT2
194  2024-03-15 13:00:00  25150  25150  25000  25000  281000    NT2
195  2024-03-15 13:30:00  25000  25100  24950  25000  190900    NT2
196  2024-03-15 14:00:00  25100  25100  24950  25100  127600    NT2
197  2024-03-15 14:30:00  25100  25100  25100  25100   13800    NT2

Chúng ta có thể thấy là giá open, high, low, close của mỗi row hầu như là bằng nhau, điều này khá vô lý, chúng ta có thể mở chart của fireant sẽ thấy giá trong 30m có sự vận động lên xuống rất nhiều chs không đứng yên ở 1 chỗ.

image

Về volume cũng có vấn đề, ví dụ đây là volume ngày 15/3/2024:

2024-03-15 09:00:00 2024-03-15 09:00:00 25250 25250 25250 25250 3900 NT2
Ở đây data trả về là 3900, tuy nhiên nếu xem dữ liệu khớp lệnh trên fireant thì hơn con số này nhiều (chỉ tính đếnh phút 15 đã hơn con số này):

image

FR: crawl data related to mutual funds from https://fmarket.vn/

Yêu cầu tính năng có liên quan đến một vấn đề? Vui lòng mô tả.
Cào dữ liệu về quỹ mở (open-ended fund) từ https://fmarket.vn/

Mô tả giải pháp bạn muốn
thêm các hàm để truy xuất dữ liệu về quỹ mở

Mô tả các giải pháp hoặc tính năng thay thế bạn đã xem xét
N/A

Bổ sung thông tin
Status: WIP

Hàm `fund_details` vẫn hiển thị kết quả khi tên mã quỹ bị gõ thiếu

Cách tái hiện lại lỗi để xử lý
Các bước để tái hiện sự cố:

  1. Sử dụng hàm fund_details(symbol='VESA', type='nav_report')
  2. Vẫn hiển thị ra thông tin của quỹ VESAF

Mong muốn đạt được
Hàm trả về lỗi, hoặc thông báo chưa có thông tin quỹ nếu mã quỹ nhập vào không đúng

Ảnh chụp màn hình
Screenshot 2024-03-14 at 16 26 49
Máy tính để bàn (vui lòng cung cấp thông tin sau):

  • Hệ điều hành: Ubuntu 22.04
  • Phiên bản: 0.2.8.9

P/S: Mình có thể contribute vào code thông qua việc sửa lỗi này được không ạ?

Unsupported format, or corrupt file: Expected BOF record; found b'{"data":'

Calling:
AST = financial_report (symbol= "AST", report_type='BalanceSheet', frequency='yearly')

same with "FRT" as well

Error:

Traceback (most recent call last):
  File "main.py", line 247, in <module>
    getRate(retail_code)
  File "main.py", line 49, in getRate
    incomeData = financial_report (symbol= bank, report_type='IncomeStatement', frequency='yearly')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/vnstock/stock.py", line 172, in financial_report
    df = pd.read_excel(BytesIO(r.content), skiprows=7).dropna()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/util/_decorators.py", line 296, in wrapper
    return func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/excel/_base.py", line 304, in read_excel
    io = ExcelFile(io, engine=engine)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/excel/_base.py", line 867, in __init__
    self._reader = self._engines[engine](self._io)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/excel/_xlrd.py", line 22, in __init__
    super().__init__(filepath_or_buffer)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/excel/_base.py", line 351, in __init__
    self.book = self.load_workbook(filepath_or_buffer)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/excel/_xlrd.py", line 35, in load_workbook
    return open_workbook(file_contents=data)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlrd/__init__.py", line 157, in open_workbook
    ragged_rows=ragged_rows,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlrd/book.py", line 92, in open_workbook_xls
    biff_version = bk.getbof(XL_WORKBOOK_GLOBALS)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlrd/book.py", line 1278, in getbof
    bof_error('Expected BOF record; found %r' % self.mem[savpos:savpos+8])
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/xlrd/book.py", line 1272, in bof_error
    raise XLRDError('Unsupported format, or corrupt file: ' + msg)
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'{"data":'

Báo lỗi cho tính năng

Mô tả lỗi
Mô tả một cách rõ ràng và ngắn gọn về lỗi.

Cách tái hiện lại lỗi để xử lý
Các bước để tái hiện sự cố:

  1. Sử dụng VSCode '...'
  2. Sử dụng hàm 'industry_analysis'
  3. Thực thi lệnh 'industry_analysis("VNM", lang='vi')'
  4. Gặp lỗi không xuất được DataFrame phân tích ngành

Mong muốn đạt được
xuất ra được DataFrame phân tích ngành

Ảnh chụp màn hình
image

VNindex không hiển thị trước 2020

Mô tả lỗi
Code xuất dữ liệu VNindex

from vnstock import * #import all functions

#df = stock_historical_data(symbol='VNINDEX', start_date='2001-01-01', end_date='2023-10-10', resolution='1D', type='index')
df = stock_historical_data(symbol='VNINDEX', start_date= "2001-01-01", end_date= TODAY, resolution='1D', type='index')
fig = candlestick_chart(df,
title='VNINDEX Candlestick Chart with MA and Volume', x_label='Date', y_label='Price', ma_periods=[50,200],
show_volume=True, figure_size=(15, 8), reference_period=300,
colors=('lightgray', 'gray'), reference_colors=('black', 'blue'))
fig.show()

Kết quả
chỉ xuất được dữ liệu sau 2020

image
vnindex

Lỗi thiếu module requests

Chào anh Thịnh,
Đối với 1 số máy windows, sau khi cài python mới nhất, cài vnstock. thực hiện hàm ticker_overview sẽ báo lỗi thiếu module requests. Cách fix tạm là pip install requests
Nhờ team thêm requirements để khi cài đặt vnstock thì có cài theo module liên quan luôn nhé anh

Excel file format cannot be determined, you must specify an engine manually

Why financial_report can't be used in my python3?

from vnstock import *
df = financial_report (symbol='SSI', report_type='BalanceSheet', frequency='Quarterly')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/debian/.local/lib/python3.9/site-packages/vnstock/stock.py", line 172, in financial_report
    df = pd.read_excel(BytesIO(r.content), skiprows=7).dropna()
  File "/home/debian/.local/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)
  File "/home/debian/.local/lib/python3.9/site-packages/pandas/io/excel/_base.py", line 364, in read_excel
    io = ExcelFile(io, storage_options=storage_options, engine=engine)
  File "/home/debian/.local/lib/python3.9/site-packages/pandas/io/excel/_base.py", line 1195, in __init__
    raise ValueError(
ValueError: Excel file format cannot be determined, you must specify an engine manually.

Search the source code:

def financial_report (symbol, report_type, frequency, headers=headers): # Quarterly, Yearly
    """
    This function returns the balance sheet of a stock symbol by a Quarterly or Yearly range.
    Args:
        symbol (:obj:`str`, required): 3 digits name of the desired stock.
        report_type (:obj:`str`, required): BalanceSheet, IncomeStatement, CashFlow
        report_range (:obj:`str`, required): Yearly or Quarterly.
    """
    url = 'https://fiin-fundamental.ssi.com.vn/FinancialStatement/Download{}?language=vi&OrganCode={}&Skip=0&Frequency={}'.format(report_type, symbol, frequency)
    r = requests.get(url, headers=headers)
    df = pd.read_excel(BytesIO(r.content), skiprows=7).dropna()
    return df

Get the url as below:
https://fiin-fundamental.ssi.com.vn/FinancialStatement/DownloadBalanceSheet?language=vi&OrganCode=SSI&Skip=0&Frequency=Quarterly

Paste into browser:

data | null
-- | --
fileName | null
status | "Failed"
errors |  
0 | "Could not find file 'C:\\FiinTrade\\FiinTrade\\FiinTrade.Fundamental\\wwwroot\\Templates\\.xlsx'."

Maybe the api is broken!

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.