markowitzvn


Namemarkowitzvn JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/nguyenbinh0807/profilevn.git
SummaryViet Nam stock profile
upload_time2022-12-15 05:56:50
maintainer
docs_urlNone
authornguyenthebinh
requires_python
licenseMIT
keywords markowitzvn python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # markowitzvn
*markowitzvn* is a program for financial **portfolio management, analysis and optimisation**.

## Table of contents
 - [Motivation](#Motivation)
 - [Automatically generating an instance of](#DataLoad)
 - [LinePlot](#LinePlot)
- [Portfolio Management](#Portfolio-Management)
 - [Installation](#Installation)
 - [Contact Information](#Contact-Information)
## Motivation
*markowitzvn* có thể tạo một đối tượng giữ giá cổ phiếu của danh mục đầu tư tài chính bạn mong muốn, phân tích nó và có thể tạo các biểu đồ gồm các loại *Returns*, *Moving Averages*, *Line Plot*. Nó cũng cho phép tối ưu hóa dựa trên *Efficient Frontier* hoặc danh mục đầu tư tài chính chạy *Monte Carlo* trong một vài dòng mã. Một số kết quả được hiển thị ở đây.
Dựa trên lý thuyết tối đa hóa danh mục đầu tư của markowitz và những yêu cầu để phù hợp với thị trường Việt Nam nên tôi đã đưa mô hình về với Việt Nam giúp cho nhà đầu tư trong việc phân tích và phân bổ danh mục tối đa lợi nhuận và giảm thiểu rủi ro

### Automatically generating an instance of `DataLoad`
`DataLoad()` là một hàm đầu vào là *symbols* *start*  *end* sẽ trả về kết quả một dataframe giá cổ phiếu trong khoảng thời gian đầu vào .
```
import markowitzvn.data as dt
names=['STB', 'CMG', 'VGC', 'VHC', 'FPT']
start_date = '2019-11-15'
end_date = '2022-11-15'
loader=dt.DataLoad(symbols=symbols_list, start=start_date, end=end_date)
```
`loader` chứa giá cổ phiếu trong danh mục đầu tư của bạn, sau đó...
```
price_stock=loader.download()
>>price_stock
```
Results
```
 			                  STB      CMG      VGC      VHC      FPT
TradingDate
2019-11-18   10600.0  24944.0  15989.0  35666.0  33409.0
2019-11-19   10600.0  24944.0  15904.0  35620.0  33874.0
2019-11-20   10400.0  24588.0  15861.0  35440.0  33003.0
2019-11-21   10200.0  24717.0  15904.0  35440.0  32538.0
2019-11-22   10250.0  24588.0  15818.0  34988.0  32538.0
...              ...      ...      ...      ...      ...
2022-11-09   16250.0  35400.0  35300.0  74900.0  74000.0
2022-11-10   15150.0  33950.0  32850.0  74900.0  73000.0
2022-11-11   15600.0  35000.0  30600.0  75500.0  72800.0
2022-11-14   15850.0  35000.0  28500.0  74500.0  70800.0
2022-11-15   15100.0  32550.0  26550.0  74900.0  65900.0
```
Nếu đầu vào của bạn là một cổ phiếu
```
import markowitzvn.data as dt
names=['STB', 'CMG', 'VGC', 'VHC', 'FPT']
start_date = '2019-11-15'
end_date = '2022-11-15'
loader=dt.DataLoad(symbols=symbols_list, start=start_date, end=end_date)
price_stock=loader.download()
>>price_stock
```
Results

```
 			Open     High      Low    Close   Volume
TradingDate
2019-11-18   33932.0  34165.0  33177.0  33409.0  2794920
2019-11-19   33409.0  33874.0  33409.0  33874.0  1059770
2019-11-20   33816.0  33816.0  32886.0  33003.0  2291760
2019-11-21   33003.0  33177.0  32480.0  32538.0  3303950
2019-11-22   32712.0  33177.0  32247.0  32538.0  1625820
...              ...      ...      ...      ...      ...
2022-11-09   73300.0  74300.0  73300.0  74000.0   699349
2022-11-10   73500.0  73700.0  69100.0  73000.0  1598605
2022-11-11   73100.0  73600.0  72000.0  72800.0  1004524
2022-11-14   72000.0  72400.0  70000.0  70800.0  1642109
2022-11-15   70000.0  70000.0  65900.0  65900.0  3123365
```
### Line plot
trực quan giá cổ phiếu bằng các đường
```
loader.lineplot(permanent=False)
  """this is a vizual pirce close

        Args:
            permanent (bool, optional): if True permanent start else . Defaults to False.
        """
```
yields
<p align="center">
  <img src="markowitzvn\images\lineplot.png" width="60%">
</p>

### Portfolio properties
In ra các thuộc tính danh mục đầu tư, yêu cầu đầu vào phải năm cổ phiếu mới thực hiện được hàm này 
```
 """this is a properties 

        Args:
            num_portfolios (int, optional): number portfolios. Defaults to 6000.
            risk_free_rate (float, optional): _description_. Defaults to 0.07.
            vizual (bool, optional): if True vizual camp. Defaults to False.

        Returns:
            _type_: weights, returns, vol
        """
      
loader.properties(vizual=True)
```
results

```
Maximum Sharpe Ratio Portfolio Allocation

Annualised Return: 0.15
Annualised Volatility: 0.29


                  CTG     MBB   FMC   CMG   FPT
allocation  28.99     0.01      21.0    20.0     30.0
--------------------------------------------------------------------------------
Minimum Volatility Portfolio Allocation

Annualised Return: 0.13
Annualised Volatility: 0.28


                 CTG    MBB   FMC   CMG     FPT
allocation  9.35    19.65    21.0     20.0      30.0
```
Notes:
Maximum Sharpe Ratio Portfolio Allocation: Tối đa lợi nhuận.
Minimum Volatility Portfolio Allocation: Giảm thiểu rủi ro.
Annualised Return: Lợi nhuận.
Annualised Volatility: Biến động
allocation: tỷ trọng các cổ phiếu

<p align="center">
  <img src="markowitzvn\images\profolios.png" width="60%">
</p>
## Installation
As it is common for open-source projects, there are several ways to get hold of the code. Choose whichever suits you and your purposes best.

### Dependencies
*markowitzvn* depends on the following Python packages:
 - numpy>=1.20.2
 - pandas>=0.19.2
 - plotly>=4.2.1
 - scipy>=1.2.0
 - vnstock
 - requests

### From PyPI
*markowitzvn* can be obtained from PyPI

```pip install markowitzvn```

# III. 🙋‍♂️ Contact Information
Hiện tại tôi đang học ngành kinh tế năm 3 tại đại học mở và tự học thêm kỹ năng lập trình để có thể áp dụng vào lĩnh vực kinh tế. Đây là thư viện đầu tiên tôi viết và nếu muốn ủng hộ các thư viện trong việc phân tích thị trường chứng khoán thì qua ngân hàng agribank. Cảm ơn mọi người rất nhiều.

<p align="center">
  <img src="markowitzvn\images\37d24aebd151080f5140.jpg" width="60%">
</p>

<div id="badges" align="center">
Nếu ai muốn cùng tôi phát triển các dự án sau này và cùng nhau học hỏi kinh nghiệm. Mọi người có thể liên hệ tôi qua FaceBook. Cảm ơn mọi người 
  <a href="https://www.facebook.com/binh.nguyenthe.5815255/">
    <img src="https://img.shields.io/badge/Messenger-00B2FF?style=for-the-badge&logo=messenger&logoColor=white" alt="Messenger Badge"/>
  </a>
</div>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nguyenbinh0807/profilevn.git",
    "name": "markowitzvn",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "markowitzvn,python",
    "author": "nguyenthebinh",
    "author_email": "2054022009binh@ou.edu.vn",
    "download_url": "",
    "platform": null,
    "description": "# markowitzvn\r\n*markowitzvn* is a program for financial **portfolio management, analysis and optimisation**.\r\n\r\n## Table of contents\r\n - [Motivation](#Motivation)\r\n - [Automatically generating an instance of](#DataLoad)\r\n - [LinePlot](#LinePlot)\r\n- [Portfolio Management](#Portfolio-Management)\r\n - [Installation](#Installation)\r\n - [Contact Information](#Contact-Information)\r\n## Motivation\r\n*markowitzvn* c\u00f3 th\u1ec3 t\u1ea1o m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng gi\u1eef gi\u00e1 c\u1ed5 phi\u1ebfu c\u1ee7a danh m\u1ee5c \u0111\u1ea7u t\u01b0 t\u00e0i ch\u00ednh b\u1ea1n mong mu\u1ed1n, ph\u00e2n t\u00edch n\u00f3 v\u00e0 c\u00f3 th\u1ec3 t\u1ea1o c\u00e1c bi\u1ec3u \u0111\u1ed3 g\u1ed3m c\u00e1c lo\u1ea1i *Returns*, *Moving Averages*, *Line Plot*. N\u00f3 c\u0169ng cho ph\u00e9p t\u1ed1i \u01b0u h\u00f3a d\u1ef1a tr\u00ean *Efficient Frontier* ho\u1eb7c danh m\u1ee5c \u0111\u1ea7u t\u01b0 t\u00e0i ch\u00ednh ch\u1ea1y *Monte Carlo* trong m\u1ed9t v\u00e0i d\u00f2ng m\u00e3. M\u1ed9t s\u1ed1 k\u1ebft qu\u1ea3 \u0111\u01b0\u1ee3c hi\u1ec3n th\u1ecb \u1edf \u0111\u00e2y.\r\nD\u1ef1a tr\u00ean l\u00fd thuy\u1ebft t\u1ed1i \u0111a h\u00f3a danh m\u1ee5c \u0111\u1ea7u t\u01b0 c\u1ee7a markowitz v\u00e0 nh\u1eefng y\u00eau c\u1ea7u \u0111\u1ec3 ph\u00f9 h\u1ee3p v\u1edbi th\u1ecb tr\u01b0\u1eddng Vi\u1ec7t Nam n\u00ean t\u00f4i \u0111\u00e3 \u0111\u01b0a m\u00f4 h\u00ecnh v\u1ec1 v\u1edbi Vi\u1ec7t Nam gi\u00fap cho nh\u00e0 \u0111\u1ea7u t\u01b0 trong vi\u1ec7c ph\u00e2n t\u00edch v\u00e0 ph\u00e2n b\u1ed5 danh m\u1ee5c t\u1ed1i \u0111a l\u1ee3i nhu\u1eadn v\u00e0 gi\u1ea3m thi\u1ec3u r\u1ee7i ro\r\n\r\n### Automatically generating an instance of `DataLoad`\r\n`DataLoad()` l\u00e0 m\u1ed9t h\u00e0m \u0111\u1ea7u v\u00e0o l\u00e0 *symbols* *start*  *end* s\u1ebd tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3 m\u1ed9t dataframe gi\u00e1 c\u1ed5 phi\u1ebfu trong kho\u1ea3ng th\u1eddi gian \u0111\u1ea7u v\u00e0o .\r\n```\r\nimport markowitzvn.data as dt\r\nnames=['STB', 'CMG', 'VGC', 'VHC', 'FPT']\r\nstart_date = '2019-11-15'\r\nend_date = '2022-11-15'\r\nloader=dt.DataLoad(symbols=symbols_list, start=start_date, end=end_date)\r\n```\r\n`loader` ch\u1ee9a gi\u00e1 c\u1ed5 phi\u1ebfu trong danh m\u1ee5c \u0111\u1ea7u t\u01b0 c\u1ee7a b\u1ea1n, sau \u0111\u00f3...\r\n```\r\nprice_stock=loader.download()\r\n>>price_stock\r\n```\r\nResults\r\n```\r\n \t\t\t                  STB      CMG      VGC      VHC      FPT\r\nTradingDate\r\n2019-11-18   10600.0  24944.0  15989.0  35666.0  33409.0\r\n2019-11-19   10600.0  24944.0  15904.0  35620.0  33874.0\r\n2019-11-20   10400.0  24588.0  15861.0  35440.0  33003.0\r\n2019-11-21   10200.0  24717.0  15904.0  35440.0  32538.0\r\n2019-11-22   10250.0  24588.0  15818.0  34988.0  32538.0\r\n...              ...      ...      ...      ...      ...\r\n2022-11-09   16250.0  35400.0  35300.0  74900.0  74000.0\r\n2022-11-10   15150.0  33950.0  32850.0  74900.0  73000.0\r\n2022-11-11   15600.0  35000.0  30600.0  75500.0  72800.0\r\n2022-11-14   15850.0  35000.0  28500.0  74500.0  70800.0\r\n2022-11-15   15100.0  32550.0  26550.0  74900.0  65900.0\r\n```\r\nN\u1ebfu \u0111\u1ea7u v\u00e0o c\u1ee7a b\u1ea1n l\u00e0 m\u1ed9t c\u1ed5 phi\u1ebfu\r\n```\r\nimport markowitzvn.data as dt\r\nnames=['STB', 'CMG', 'VGC', 'VHC', 'FPT']\r\nstart_date = '2019-11-15'\r\nend_date = '2022-11-15'\r\nloader=dt.DataLoad(symbols=symbols_list, start=start_date, end=end_date)\r\nprice_stock=loader.download()\r\n>>price_stock\r\n```\r\nResults\r\n\r\n```\r\n \t\t\tOpen     High      Low    Close   Volume\r\nTradingDate\r\n2019-11-18   33932.0  34165.0  33177.0  33409.0  2794920\r\n2019-11-19   33409.0  33874.0  33409.0  33874.0  1059770\r\n2019-11-20   33816.0  33816.0  32886.0  33003.0  2291760\r\n2019-11-21   33003.0  33177.0  32480.0  32538.0  3303950\r\n2019-11-22   32712.0  33177.0  32247.0  32538.0  1625820\r\n...              ...      ...      ...      ...      ...\r\n2022-11-09   73300.0  74300.0  73300.0  74000.0   699349\r\n2022-11-10   73500.0  73700.0  69100.0  73000.0  1598605\r\n2022-11-11   73100.0  73600.0  72000.0  72800.0  1004524\r\n2022-11-14   72000.0  72400.0  70000.0  70800.0  1642109\r\n2022-11-15   70000.0  70000.0  65900.0  65900.0  3123365\r\n```\r\n### Line plot\r\ntr\u1ef1c quan gi\u00e1 c\u1ed5 phi\u1ebfu b\u1eb1ng c\u00e1c \u0111\u01b0\u1eddng\r\n```\r\nloader.lineplot(permanent=False)\r\n  \"\"\"this is a vizual pirce close\r\n\r\n        Args:\r\n            permanent (bool, optional): if True permanent start else . Defaults to False.\r\n        \"\"\"\r\n```\r\nyields\r\n<p align=\"center\">\r\n  <img src=\"markowitzvn\\images\\lineplot.png\" width=\"60%\">\r\n</p>\r\n\r\n### Portfolio properties\r\nIn ra c\u00e1c thu\u1ed9c t\u00ednh danh m\u1ee5c \u0111\u1ea7u t\u01b0, y\u00eau c\u1ea7u \u0111\u1ea7u v\u00e0o ph\u1ea3i n\u0103m c\u1ed5 phi\u1ebfu m\u1edbi th\u1ef1c hi\u1ec7n \u0111\u01b0\u1ee3c h\u00e0m n\u00e0y \r\n```\r\n \"\"\"this is a properties \r\n\r\n        Args:\r\n            num_portfolios (int, optional): number portfolios. Defaults to 6000.\r\n            risk_free_rate (float, optional): _description_. Defaults to 0.07.\r\n            vizual (bool, optional): if True vizual camp. Defaults to False.\r\n\r\n        Returns:\r\n            _type_: weights, returns, vol\r\n        \"\"\"\r\n      \r\nloader.properties(vizual=True)\r\n```\r\nresults\r\n\r\n```\r\nMaximum Sharpe Ratio Portfolio Allocation\r\n\r\nAnnualised Return: 0.15\r\nAnnualised Volatility: 0.29\r\n\r\n\r\n                  CTG     MBB   FMC   CMG   FPT\r\nallocation  28.99     0.01      21.0    20.0     30.0\r\n--------------------------------------------------------------------------------\r\nMinimum Volatility Portfolio Allocation\r\n\r\nAnnualised Return: 0.13\r\nAnnualised Volatility: 0.28\r\n\r\n\r\n                 CTG    MBB   FMC   CMG     FPT\r\nallocation  9.35    19.65    21.0     20.0      30.0\r\n```\r\nNotes:\r\nMaximum Sharpe Ratio Portfolio Allocation: T\u1ed1i \u0111a l\u1ee3i nhu\u1eadn.\r\nMinimum Volatility Portfolio Allocation: Gi\u1ea3m thi\u1ec3u r\u1ee7i ro.\r\nAnnualised Return: L\u1ee3i nhu\u1eadn.\r\nAnnualised Volatility: Bi\u1ebfn \u0111\u1ed9ng\r\nallocation: t\u1ef7 tr\u1ecdng c\u00e1c c\u1ed5 phi\u1ebfu\r\n\r\n<p align=\"center\">\r\n  <img src=\"markowitzvn\\images\\profolios.png\" width=\"60%\">\r\n</p>\r\n## Installation\r\nAs it is common for open-source projects, there are several ways to get hold of the code. Choose whichever suits you and your purposes best.\r\n\r\n### Dependencies\r\n*markowitzvn* depends on the following Python packages:\r\n - numpy>=1.20.2\r\n - pandas>=0.19.2\r\n - plotly>=4.2.1\r\n - scipy>=1.2.0\r\n - vnstock\r\n - requests\r\n\r\n### From PyPI\r\n*markowitzvn* can be obtained from PyPI\r\n\r\n```pip install markowitzvn```\r\n\r\n# III. \ud83d\ude4b\u200d\u2642\ufe0f Contact Information\r\nHi\u1ec7n t\u1ea1i t\u00f4i \u0111ang h\u1ecdc ng\u00e0nh kinh t\u1ebf n\u0103m 3 t\u1ea1i \u0111\u1ea1i h\u1ecdc m\u1edf v\u00e0 t\u1ef1 h\u1ecdc th\u00eam k\u1ef9 n\u0103ng l\u1eadp tr\u00ecnh \u0111\u1ec3 c\u00f3 th\u1ec3 \u00e1p d\u1ee5ng v\u00e0o l\u0129nh v\u1ef1c kinh t\u1ebf. \u0110\u00e2y l\u00e0 th\u01b0 vi\u1ec7n \u0111\u1ea7u ti\u00ean t\u00f4i vi\u1ebft v\u00e0 n\u1ebfu mu\u1ed1n \u1ee7ng h\u1ed9 c\u00e1c th\u01b0 vi\u1ec7n trong vi\u1ec7c ph\u00e2n t\u00edch th\u1ecb tr\u01b0\u1eddng ch\u1ee9ng kho\u00e1n th\u00ec qua ng\u00e2n h\u00e0ng agribank. C\u1ea3m \u01a1n m\u1ecdi ng\u01b0\u1eddi r\u1ea5t nhi\u1ec1u.\r\n\r\n<p align=\"center\">\r\n  <img src=\"markowitzvn\\images\\37d24aebd151080f5140.jpg\" width=\"60%\">\r\n</p>\r\n\r\n<div id=\"badges\" align=\"center\">\r\nN\u1ebfu ai mu\u1ed1n c\u00f9ng t\u00f4i ph\u00e1t tri\u1ec3n c\u00e1c d\u1ef1 \u00e1n sau n\u00e0y v\u00e0 c\u00f9ng nhau h\u1ecdc h\u1ecfi kinh nghi\u1ec7m. M\u1ecdi ng\u01b0\u1eddi c\u00f3 th\u1ec3 li\u00ean h\u1ec7 t\u00f4i qua FaceBook. C\u1ea3m \u01a1n m\u1ecdi ng\u01b0\u1eddi \r\n  <a href=\"https://www.facebook.com/binh.nguyenthe.5815255/\">\r\n    <img src=\"https://img.shields.io/badge/Messenger-00B2FF?style=for-the-badge&logo=messenger&logoColor=white\" alt=\"Messenger Badge\"/>\r\n  </a>\r\n</div>\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Viet Nam stock profile",
    "version": "0.0.5",
    "split_keywords": [
        "markowitzvn",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "7ff0c1bd00b580086ac521764e9fe467",
                "sha256": "34f0628b05659e1aac24e51104314e3c4f86127874d0d885019747781bb38dd1"
            },
            "downloads": -1,
            "filename": "markowitzvn-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7ff0c1bd00b580086ac521764e9fe467",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9123,
            "upload_time": "2022-12-15T05:56:50",
            "upload_time_iso_8601": "2022-12-15T05:56:50.777345Z",
            "url": "https://files.pythonhosted.org/packages/d3/2f/56c0127e40da5ca73b6fdb56fd9c76a45e6ff79b8be700f2e04c9f5e9294/markowitzvn-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-15 05:56:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "nguyenbinh0807",
    "github_project": "profilevn.git",
    "lcname": "markowitzvn"
}
        
Elapsed time: 0.02813s