Vnquant
VietNam Data Stock Market Price
Install / Use
/learn @phamdinhkhanh/VnquantREADME
vnquant package
<img src="./vnquant/imgs/stock_1.png" style="display: block;margin-left: auto;margin-right: auto;width:50%;" />1. Introduction
This project offers comprehensive financial information and advanced visualization tools for the Vietnam stock market to researchers. Specifically, it provides extensive data, including historical prices, finacial, business, and cashflow reports for individual or multiple symbols over the same period. This enables investors to conduct in-depth quantitative analyses and forecasting. Additionally, the available stock prices can be utilized to create visualizations with advanced metrics such as Bollinger Bands and Relative Strength Index (RSI), aiding in identifying optimal buying and selling points.
2. Setting:
2.1. Setup on local machine
This project is in developing process, So it is only distributed on github channel. To install requiring you open the command line and type the below commands:
git clone https://github.com/phamdinhkhanh/vnquant
cd vnquant
python setup.py install
you must install git command line in your computer to run above command.
2.2. Google colab
To use package in google colab, you have to mount point to google drive folder first and setup the same as in local machine. Reference to google colab - vnquant example for detail.
3. Visualization: (0.0.2)
from version 0.0.2 vnquant enable to you visualize stock price from any symbols code at source cafe or vnd or pandas data frame which have OHLC type. OHLC type meaning that your data frame columns is enough ['open', 'high', 'low', 'close'] list. Below is general syntax of visualization function supported on vnquant package.
import vnquant.plot as pl
pl.vnquant_candle_stick(data,
title=None,
xlab='Date', ylab='Price',
start_date=None, end_date=None,
colors=['blue', 'red'],
width=800, height=600,
show_advanced=[],
data_source='cafe',
**kargs)
Arguments
data: is pandas data frame of OHLC type or OHLCV type, or string symbol of any VietNam stock index. in case symbol, data is automatically cloned from open source.title: General title of candle stick chart. If data is a symbol, title is going to be created based on symbol and cloned datetime interval.xlab: x label. Default Date.ylab: y label. Default Price.start_date: start date. Default None. Must to be declared when data is symbol.end_date: end date. Default None. Must to be declared when data is symbol.colors: list colors defines increasing and decreasing color stick candle in order.width: with of plot frame. Default 800pxheight: height of plot frame. Default 600pxshow_advanced: list of advanced stock index to show up. Each element belongs to ['volume', 'macd', 'rsi'].data_source: invalid when use symbol intead of data frame. Source to clone data, 'VND' or 'CAFE'.
3.1. Visualization from source VND or CAFE
In this way, you can visualize stock price clone from VND or CAFE source by pass symbol, start_date, end_date into module as below:
from vnquant import plot as plt
plt.vnquant_candle_stick(
data='VND',
title='VND symbol from 2019-09-01 to 2019-11-01',
xlab='Date', ylab='Price',
start_date='2019-09-01',
end_date='2019-11-01',
data_source='CAFE',
show_advanced=['volume', 'macd', 'rsi'],
width=1600,
height=800
)
<img src="./vnquant/imgs/stock_2.png" style="display: block;margin-left: auto;margin-right: auto;width:50%;" />
You can suppress volume by set up show_vol=False. Result as below:
<img src="./vnquant/imgs/stock_3.png" style="display: block;margin-left: auto;margin-right: auto;width:50%;" />3.2. Visualization from data frame
Data frame must be OHLC or OHLCV type. OHLC type when it includes ['open','high','low','close'] and OHLCV is ['open','high','low','close','volume'] or ['open','high','low','close','volume_match'] and index is DateTime. In case your data frame have columns with the same function, you should accordingly rename its.
from vnquant import plot as plt
plt.vnquant_candle_stick(
data = data,
title='Your data',
ylab='Date', xlab='Price',
show_advanced=['volume', 'macd', 'rsi']
)
<img src="./vnquant/imgs/stock_4.png" style="display: block;margin-left: auto;margin-right: auto;width:50%;" />
To check whether data_vnd frame is OHLC or OHLCV type you can try:
from vnquant import utils
print(utils._isOHLC(data_vnd))
print(utils._isOHLCV(data_vnd))
Return True mean data frame is adapted types.
4. Clone Stock Prices: (0.1.2)
You can load the prices of one or more stocks in specific time interval according to syntax as below.
import vnquant.data as dt
loader = dt.DataLoader(
symbols: Union[str, list],
start: Optional[Union[str, datetime]]=None,
end: Optional[Union[str, datetime]]=None,
data_source: str='CAFE',
minimal: bool=True,
table_style: str='levels')
For example:
loader = DataLoader(
symbols='VND',
start='2018-01-10', end='2018-02-15',
data_source='CAFE',
minimal=True,
table_style='levels')
loader.download()
Arguments
symbols(Union[str, list]): A single stock symbol as a string or multiple stock symbols as a list of strings. The stock symbols regularly include 3 upper case letters except several special index such as:E1VFVN30, FUEVN100for both data_sourcecafe and vnd,HNX-INDEX, HNX30-INDEX, UPCOM-INDEXforcafe.start(Optional[Union[str, datetime]], default=None): The start date for the data. Can be a string in the format 'YYYY-MM-DD' or a datetime object.end(Optional[Union[str, datetime]], default=None): The end date for the data. Can be a string in the format 'YYYY-MM-DD' or a datetime object.data_source(str, default='CAFE'): The data source to be used for downloading stock data. Currently supports 'CAFE' and 'VND'.minimal(bool, default=True): If True, returns a minimal set of columns. If False, returns all available columns.table_style(str, default='levels'): The style of the returned table. Options are 'levels', 'prefix', and 'stack'.
- 'levels': Returns the DataFrame with multi-level colums of symbols and list of basic arguments like
['high', 'low', 'open', 'close', 'adjust', 'volume', 'value'] - 'prefix': Adds the stock symbol as a prefix to each column name.
- 'stack': Returns the DataFrame and add one column 'code' to clarify each record belong to what stock symbol.
4.1. Clone one stock:
There are three return formats supported in the latest version 0.1.2.
- Multiple-level: It will return a table with mutilple column indexes with two main levels Arguments (including many basical stock indexes) and Symbols (including list of stock codes).
import vnquant.data as dt
loader = dt.DataLoader('VND', '2018-02-02','2018-04-02')
data = loader.download()
data.head()
<table border="1" class="dataframe">
<thead>
<tr>
<th>Attributes</th>
<th>high</th>
<th>low</th>
<th>open</th>
<th>close</th>
<th>avg</th>
<th>volume</th>
</tr>
<tr>
<th>Symbols</th>
<th>VND</th>
<th>VND</th>
<th>VND</th>
<th>VND</th>
<th>VND</th>
<th>VND</th>
</tr>
<tr>
<th>date</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>2018-02-02</th>
<td>28.95</td>
<td>27.60</td>
<td>28.5</td>
<td>28.95</td>
<td>28.28</td>
<td>1700670.0</td>
</tr>
<tr>
<th>2018-02-05</th>
<td>28.45</td>
<td>26.95</td>
<td>28.1</td>
<td>26.95</td>
<td>27.68</td>
<td>2150120.0</td>
</tr>
<tr>
<th>2018-02-06</th>
<td>26.95</td>
<td>25.10</td>
<td>25.1</td>
<td>26.40</td>
<td>25.25</td>
<td>3129690.0</td>
</tr>
<tr>
<th>2018-02-07</th>
<td>28.20</td>
<td>27.50</td>
<td>27.5</td>
<td>28.20</td>
<td>27.99</td>
<td>1985120.0</td>
</tr>
<tr>
<th>2018-02-08</th>
<td>29.20</td>
<td>27.70</td>
<td>28.0</td>
<td>28.00</td>
<td>28.47</td>
<td>943260.0</td>
</tr>
</tbody>
</table>
- Prefix: The stock code is appended before each index to become a column name.
import vnquant.data as dt
loader = dt.DataLoader(['VND', 'FPT'], '2018-02-02','2018-04-02', table_style='prefix')
data = loader.download()
data.head()
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>VND_code</th>
<th>FPT_code</th>
<th>VND_high</th>
<th>FPT_high</th>
<th>VND_low</th>
<th>FPT_low</th>
<th>VND_open</th>
<th>FPT_open</th>
<th>VND_close</th>
<th>FPT_close</th>
<th>VND_adjust</th>
<th>FPT_adjust</th>
<th>VND_volume_match</th>
<th>FPT_volume_match</th>
<th>VND_value_match</th>
<th>FPT_value_match</th>
</tr>
<tr>
<th>date</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>2018-04-02</th>
<td>VND</td>
<td>FPT</td>
<td>29.80</td>
<td>61.7</td>
<td>29.10</td>
<td>61.0</td>
<td>29.10</td>
<td>61.5</td>
<td>29.55</td>
<td>61.5</td>
<td>6.52</td>
<td>21.98</td>
<td>Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
110.4kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
350.8kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
