Giter Club home page Giter Club logo

vnquant's Introduction

vnquant package

0. NOTE

Note: Currently, price on VND are not supported because of changing website graphic. You change all data_source into CAFE

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.

2. Setting:

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.

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.

from vnquant import Plot
Plot._vnquant_candle_stick(data,
                          title=None,
                          xlab='Date', ylab='Price',
                          start_date=None, end_date=None,
                          colors=['blue', 'red'],
                          width=800, height=600,
                          show_vol=True,
                          data_source='cafe', # not support vnd
                          **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. In case data is symbol, title going to be default according to cloned data.
  • 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 800px
  • height: height of plot frame. Default 600px
  • show_vol: is show volume of stock price?
  • 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
Plot._vnquant_candle_stick(data='VND',
                           title='VND stock price data and volume from 2019-09-01 to 2019-11-01',
                           xlab='Date', ylab='Price',
                           start_date='2019-09-01',
                           end_date='2019-11-01',
                           show_vol=True)

You can suppress volume by set up show_vol=False. Result as below:

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']. In case your data frame have columns with the same function, you should accordingly rename its.

from vnquant import Plot
Plot._vnquant_candle_stick(data = data_vnd,
                      title='Your data',
                      ylab='Date', xlab='Price',
                      show_vol=True)

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.0.1)

You can load the prices of one or more stocks in specific time interval according to syntax as below.

from vnquant.DataLoader import DataLoader

DataLoader(symbols="VND",
           start="2018-01-10",
           end="2018-02-15",
           minimal=True,
           data_source="cafe")

Arguments

  • symbols: a string or list of strings indicate the stock names. The stock symbols in regular include 3 upper case letters except several special index such as: VN30INDEX, 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: start date time with format yyyy-mm-dd.
  • end: end date time with format yyyy-mm-dd.
  • minimal: default is True, we only clone high, low, open, close, adjust price, volume of stocks. In contrast, more information is added, for example volumn_reconcile, volumn_match,...
  • data_source: the source to clone the stock prices. Currently, there two main resources are Vndirect and Cafef showed by data_source = vnd and cafe, respectively. The default is vnd.

4.1. Clone one stock:

import vnquant.DataLoader as web
loader = web.DataLoader('VND', '2018-02-02','2018-04-02')
data = loader.download()
data.head()
Attributes high low open close avg volume
Symbols VND VND VND VND VND VND
date
2018-02-02 28.95 27.60 28.5 28.95 28.28 1700670.0
2018-02-05 28.45 26.95 28.1 26.95 27.68 2150120.0
2018-02-06 26.95 25.10 25.1 26.40 25.25 3129690.0
2018-02-07 28.20 27.50 27.5 28.20 27.99 1985120.0
2018-02-08 29.20 27.70 28.0 28.00 28.47 943260.0

4.2. Clone more stocks:

We need to set up symbols as a list.

loader = web.DataLoader(symbols=["VND", "VCB"], start="2018-01-10", end="2018-02-15", minimal=True, data_source="cafe")
data = loader.download()
data.head()
Attributes high low open close avg volume
Symbols VND VCB VND VCB VND VCB VND VCB VND VCB VND VCB
date
2018-01-10 27.75 59.2 27.10 57.3 27.55 58.3 27.50 58.0 27.52 58.08 1466780.0 2842830.0
2018-01-11 27.50 58.8 26.80 57.2 27.30 57.5 27.20 58.8 27.21 58.04 1260720.0 1766240.0
2018-01-12 28.20 59.4 27.35 58.0 27.45 58.8 27.60 58.0 27.76 58.63 1730170.0 2525840.0
2018-01-15 28.40 60.0 27.35 57.0 27.60 58.0 28.25 60.0 28.11 58.76 1273740.0 2217420.0
2018-01-16 28.40 60.3 27.90 58.8 28.10 59.3 28.25 60.0 28.14 59.64 1163350.0 2218380.0

4.3. Clone full information:

To get more the others information about volume and value beside basical fields, we need to declare minimal=False (default True).

loader = web.DataLoader(symbols=["VND"], start="2018-01-10", end="2018-02-15", minimal=False)
data = loader.download()
data.head()
Attributes change_perc1 change_perc2 open high low close avg volume_match volume_reconcile volume
Symbols VND VND VND VND VND VND VND VND VND VND
date
2018-01-10 0.00 0.000000 27.55 27.75 27.10 27.50 27.52 1382780.0 84000.0 1466780.0
2018-01-11 -0.30 0.010909 27.30 27.50 26.80 27.20 27.21 1260720.0 0.0 1260720.0
2018-01-12 0.40 0.014706 27.45 28.20 27.35 27.60 27.76 1730170.0 0.0 1730170.0
2018-01-15 0.65 0.023551 27.60 28.40 27.35 28.25 28.11 1273740.0 0.0 1273740.0
2018-01-16 0.00 0.000000 28.10 28.40 27.90 28.25 28.14 1077350.0 86000.0 1163350.0

Through this project, i hope you make your work being more covinient and easy by applying them. Though try hard, but there are many drawback, kindly comment and send me feed back to implement my project.

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.