Skip to content

Commit

Permalink
Update README.md for version 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
phamdinhkhanh committed May 27, 2024
1 parent a95e545 commit 222a7c2
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 23 deletions.
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


## 1. Introduction
This project provide the financial information and useful visualization instrument about Vietnam stock market to researcher. Particularly, there are many aspect of data relating to any stock being able to store and clone. The official version are built on both machine learning language Python and R.
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:

Expand Down Expand Up @@ -35,7 +35,7 @@ pl.vnquant_candle_stick(data,
colors=['blue', 'red'],
width=800, height=600,
show_advanced=[],
data_source='cafe', # not support vnd
data_source='cafe',
**kargs)
```

Expand Down Expand Up @@ -105,22 +105,41 @@ You can load the prices of one or more stocks in specific time interval accordin
```{python}
import vnquant.data as dt
dt.DataLoader(symbols="VND",
start="2018-01-10",
end="2018-02-15",
minimal=True,
data_source="cafe")
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')
```
**Arguments**

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, VN100-INDEX, HNX-INDEX, HNX30-INDEX, UPCOM-INDEX` in case your `data_source = "cafe"` and `VN30, HNX30, UPCOM` in case your `data_source = "vnd"`.
* `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:

```{python}
import vnquant.data as dt
loader = dt.DataLoader('VND', '2018-02-02','2018-04-02')
Expand Down
4 changes: 2 additions & 2 deletions vnquant/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Copyright (c) general_backbone. All rights reserved.
__version__ = '0.1.1'
# Copyright (c) vnquant. All rights reserved.
__version__ = '0.1.2'
15 changes: 8 additions & 7 deletions vnquant/data/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ def download(self):
loader = DataLoaderCAFE(self.symbols, self.start, self.end)
stock_data = loader.download()

if self.minimal:
if str.lower(self.data_source) == 'vnd':
stock_data = stock_data[['high', 'low', 'open', 'close', 'adjust_close', 'volume_match', 'value_match']]
else:
stock_data = stock_data[['high', 'low', 'open', 'close', 'adjust_price', 'volume_match', 'value_match']]
stock_data.columns = ['high', 'low', 'open', 'close', 'adjust', 'volume', 'value']
if self.table_style == 'levels':
return stock_data

Expand All @@ -71,8 +65,15 @@ def download(self):
stock_data.columns = new_column_names

if self.table_style == 'stack':
stock_data = stock_data.stack('Symbols').reset_index()
stock_data = stock_data.stack('Symbols').reset_index().set_index('date')
stock_data.pop('Symbols')
new_columns = [col if col!='Symbols' else 'code' for col in list(stock_data.columns)]
stock_data.columns = new_columns

if self.minimal:
if str.lower(self.data_source) == 'vnd':
stock_data = stock_data[['code', 'high', 'low', 'open', 'close', 'adjust_close', 'volume_match', 'value_match']]
else:
stock_data = stock_data[['code', 'high', 'low', 'open', 'close', 'adjust_price', 'volume_match', 'value_match']]
stock_data.columns = ['code', 'high', 'low', 'open', 'close', 'adjust', 'volume', 'value']
return stock_data
32 changes: 27 additions & 5 deletions vnquant/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def vnquant_candle_stick_source(
)
'''

loader = DataLoader(symbol, start_date, end_date, minimal=True, data_source=data_source, table_style='levels')
loader = DataLoader(symbol, start_date, end_date, minimal=True, data_source=data_source, table_style='minimal')
data = loader.download()
data = data[['high', 'low', 'open', 'close', 'adjust', 'volume']]
title = '{} stock price & volume from {} to {}'.format(symbol, start_date, end_date)
Expand All @@ -96,25 +96,45 @@ def vnquant_candle_stick_source(
w_rsi = 1
row_heights = [0.3, 0.3, 0.15, 0.15]

if 'macd' not in show_advanced:
if show_advanced==['rsi', 'volume']:
r_price = 1
r_volume = 2
r_rsi = 3
w_rsi = 1
row_heights = [0.5, 0.3, 0.2]

if 'rsi' not in show_advanced:
if show_advanced==['volume', 'macd']:
r_price = 1
r_volume = 2
r_macd = 3
w_macd = 1
row_heights = [0.5, 0.3, 0.2]

if ('rsi' not in show_advanced) and ('macd' not in show_advanced):
if show_advanced==['macd', 'rsi']:
r_price = 1
r_macd = 3
w_macd = 1
r_rsi = 3
w_rsi = 1
row_heights = [0.5, 0.3, 0.2]

if show_advanced==['volume']:
r_price = 1
r_volume = 2
row_heights = [0.6, 0.4]

if show_advanced==['macd']:
r_price = 1
r_macd = 2
w_macd = 1
row_heights = [0.6, 0.4]

if show_advanced==['rsi']:
r_price = 1
r_rsi = 2
w_rsi = 1
row_heights = [0.6, 0.4]

fig = make_subplots(rows=num_indices + 1, cols=1, shared_xaxes=True, vertical_spacing=0.02,
# subplot_titles=('Price', 'Volume'),
row_heights=row_heights)
Expand All @@ -125,7 +145,8 @@ def vnquant_candle_stick_source(
open=data['open'], high=data['high'],
low=data['low'], close=data['close'],
increasing_line_color=colors[0],
decreasing_line_color=colors[1]
decreasing_line_color=colors[1],
name='price'
),
row=r_price, col=1
)
Expand Down Expand Up @@ -216,6 +237,7 @@ def vnquant_candle_stick_source(
go.Bar(
x=data.index,
y=data['volume'],
marker=dict(color='red'),
name='Volume'
),
row=r_volume, col=1)
Expand Down
2 changes: 1 addition & 1 deletion vnquant/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) general_backbone. All rights reserved.
# Copyright (c) vnquant. All rights reserved.
from datetime import datetime
import pytz
import re
Expand Down

0 comments on commit 222a7c2

Please sign in to comment.