jquants-ml


Namejquants-ml JSON
Version 0.1.4 PyPI version JSON
download
home_page
Summaryjquants-ml is a python library for machine learning with japanese stock trade using J-Quants on Python 3.8 and above.
upload_time2023-10-24 13:19:31
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords machine learning python japanese stock trade j-quants jquants
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # jquants-ml

[![PyPI](https://img.shields.io/pypi/v/jquants-ml)](https://pypi.org/project/jquants-ml/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![codecov](https://codecov.io/gh/10mohi6/jquants-ml-python/graph/badge.svg?token=X8QKKFK6AL)](https://codecov.io/gh/10mohi6/jquants-ml-python)
[![Python package](https://github.com/10mohi6/jquants-ml-python/actions/workflows/python-package.yml/badge.svg)](https://github.com/10mohi6/jquants-ml-python/actions/workflows/python-package.yml)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/jquants-ml)](https://pypi.org/project/jquants-ml/)
[![Downloads](https://pepy.tech/badge/jquants-ml)](https://pepy.tech/project/jquants-ml)

jquants-ml is a python library for machine learning with japanese stock trade using J-Quants on Python 3.8 and above.

## Installation

    $ pip install jquants-ml

## Usage

### backtest

```python
from jquants_ml import Ml
import pprint

class MyMl(Ml):
    def features(self):
        self.X["close"] = self.df.Close
        self.X["ror"] = self.df.Close.pct_change(1)
        self.X["sma"] = self.sma(period=5)

ml = MyMl(
    mail_address="<your J-Quants mail address>",
    password="<your J-Quants password>",
    ticker="7203",  # TOYOTA
    size=100,  # 100 shares
)
pprint.pprint(ml.backtest())
```

![7203.png](https://raw.githubusercontent.com/10mohi6/jquants-ml-python/main/tests/7203.p.png)

```python
{'long': {'maximum drawdown': '15250.000',
          'profit': '12700.000',
          'profit factor': '1.183',
          'riskreward ratio': '1.213',
          'sharpe ratio': '0.063',
          'trades': '81.000',
          'win rate': '0.494'},
 'short': {'maximum drawdown': '50100.000',
           'profit': '-43800.000',
           'profit factor': '0.413',
           'riskreward ratio': '0.478',
           'sharpe ratio': '0.298',
           'trades': '41.000',
           'win rate': '0.463'},
 'total': {'maximum drawdown': '47200.000',
           'profit': '-31100.000',
           'profit factor': '0.784',
           'riskreward ratio': '0.837',
           'sharpe ratio': '0.149',
           'trades': '122.000',
           'win rate': '0.484'}}
```

### predict

```python
from jquants_ml import Ml
import pprint

class MyMl(Ml):
    def features(self):
        self.X["close"] = self.df.Close
        self.X["ror"] = self.df.Close.pct_change(1)
        self.X["sma"] = self.sma(period=5)

ml = MyMl(
    mail_address="<your J-Quants mail address>",
    password="<your J-Quants password>",
    ticker="7203",  # TOYOTA
    size=100,  # 100 shares
)
pprint.pprint(ml.predict())
```

```python
{'Date': '2023-08-01', 'Price': 2445.5, 'Sign': 'short'}
```

### advanced

```python
from jquants_ml import Ml

class MyMl(Ml):
    # Awesome Oscillator
    def ao(self, *, fast_period: int = 5, slow_period: int = 34):
        return ((self.df.H + self.df.L) / 2).rolling(fast_period).mean() - (
            (self.df.H + self.df.L) / 2
        ).rolling(slow_period).mean()

    def features(self):
        self.X["ao"] = self.ao(fast_period=5, slow_period=34)
        self.X["close"] = self.df.Close
        self.X["ror"] = self.df.Close.pct_change(1)
        self.X["sma"] = self.sma(period=5)
        self.X["ema"] = self.ema(period=5)
        self.X["upper"], self.X["mid"], self.X["lower"] = self.bbands(
            period=20, band=2
        )
        self.X["macd"], self.X["signal"] = self.macd(
            fast_period=12, slow_period=26, signal_period=9
        )
        self.X["k"], self.X["d"] = self.stoch(k_period=5, d_period=3)
        self.X["rsi"] = self.rsi(period=14)
        self.X["atr"] = self.atr(period=14)
        self.X["mom"] = self.mom(period=10)

ml = MyMl(
    mail_address="<your J-Quants mail address>",
    password="<your J-Quants password>",
    ticker="7203",  # TOYOTA
    size=100,  # 100 shares
    outputs_dir_path="outputs",
    model_dir_path="model",
    data_dir_path="data",
)
pprint.pprint(ml.backtest())
pprint.pprint(ml.predict())
```

## Supported indicators

- Simple Moving Average 'sma'
- Exponential Moving Average 'ema'
- Moving Average Convergence Divergence 'macd'
- Relative Strenght Index 'rsi'
- Bollinger Bands 'bbands'
- Market Momentum 'mom'
- Stochastic Oscillator 'stoch'
- Average True Range 'atr'

## Getting started

For help getting started with J-Quants, view our online [documentation](https://jpx-jquants.com/).

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "jquants-ml",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "machine learning,python,japanese stock,trade,J-Quants,jquants",
    "author": "",
    "author_email": "10mohi6 <10.mohi.6.y@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/29/7f/4d765a6bb8fc8c3269832ae87d7c4ef95146958afcba5277f2b89dcbdea9/jquants-ml-0.1.4.tar.gz",
    "platform": null,
    "description": "# jquants-ml\n\n[![PyPI](https://img.shields.io/pypi/v/jquants-ml)](https://pypi.org/project/jquants-ml/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/gh/10mohi6/jquants-ml-python/graph/badge.svg?token=X8QKKFK6AL)](https://codecov.io/gh/10mohi6/jquants-ml-python)\n[![Python package](https://github.com/10mohi6/jquants-ml-python/actions/workflows/python-package.yml/badge.svg)](https://github.com/10mohi6/jquants-ml-python/actions/workflows/python-package.yml)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/jquants-ml)](https://pypi.org/project/jquants-ml/)\n[![Downloads](https://pepy.tech/badge/jquants-ml)](https://pepy.tech/project/jquants-ml)\n\njquants-ml is a python library for machine learning with japanese stock trade using J-Quants on Python 3.8 and above.\n\n## Installation\n\n    $ pip install jquants-ml\n\n## Usage\n\n### backtest\n\n```python\nfrom jquants_ml import Ml\nimport pprint\n\nclass MyMl(Ml):\n    def features(self):\n        self.X[\"close\"] = self.df.Close\n        self.X[\"ror\"] = self.df.Close.pct_change(1)\n        self.X[\"sma\"] = self.sma(period=5)\n\nml = MyMl(\n    mail_address=\"<your J-Quants mail address>\",\n    password=\"<your J-Quants password>\",\n    ticker=\"7203\",  # TOYOTA\n    size=100,  # 100 shares\n)\npprint.pprint(ml.backtest())\n```\n\n![7203.png](https://raw.githubusercontent.com/10mohi6/jquants-ml-python/main/tests/7203.p.png)\n\n```python\n{'long': {'maximum drawdown': '15250.000',\n          'profit': '12700.000',\n          'profit factor': '1.183',\n          'riskreward ratio': '1.213',\n          'sharpe ratio': '0.063',\n          'trades': '81.000',\n          'win rate': '0.494'},\n 'short': {'maximum drawdown': '50100.000',\n           'profit': '-43800.000',\n           'profit factor': '0.413',\n           'riskreward ratio': '0.478',\n           'sharpe ratio': '0.298',\n           'trades': '41.000',\n           'win rate': '0.463'},\n 'total': {'maximum drawdown': '47200.000',\n           'profit': '-31100.000',\n           'profit factor': '0.784',\n           'riskreward ratio': '0.837',\n           'sharpe ratio': '0.149',\n           'trades': '122.000',\n           'win rate': '0.484'}}\n```\n\n### predict\n\n```python\nfrom jquants_ml import Ml\nimport pprint\n\nclass MyMl(Ml):\n    def features(self):\n        self.X[\"close\"] = self.df.Close\n        self.X[\"ror\"] = self.df.Close.pct_change(1)\n        self.X[\"sma\"] = self.sma(period=5)\n\nml = MyMl(\n    mail_address=\"<your J-Quants mail address>\",\n    password=\"<your J-Quants password>\",\n    ticker=\"7203\",  # TOYOTA\n    size=100,  # 100 shares\n)\npprint.pprint(ml.predict())\n```\n\n```python\n{'Date': '2023-08-01', 'Price': 2445.5, 'Sign': 'short'}\n```\n\n### advanced\n\n```python\nfrom jquants_ml import Ml\n\nclass MyMl(Ml):\n    # Awesome Oscillator\n    def ao(self, *, fast_period: int = 5, slow_period: int = 34):\n        return ((self.df.H + self.df.L) / 2).rolling(fast_period).mean() - (\n            (self.df.H + self.df.L) / 2\n        ).rolling(slow_period).mean()\n\n    def features(self):\n        self.X[\"ao\"] = self.ao(fast_period=5, slow_period=34)\n        self.X[\"close\"] = self.df.Close\n        self.X[\"ror\"] = self.df.Close.pct_change(1)\n        self.X[\"sma\"] = self.sma(period=5)\n        self.X[\"ema\"] = self.ema(period=5)\n        self.X[\"upper\"], self.X[\"mid\"], self.X[\"lower\"] = self.bbands(\n            period=20, band=2\n        )\n        self.X[\"macd\"], self.X[\"signal\"] = self.macd(\n            fast_period=12, slow_period=26, signal_period=9\n        )\n        self.X[\"k\"], self.X[\"d\"] = self.stoch(k_period=5, d_period=3)\n        self.X[\"rsi\"] = self.rsi(period=14)\n        self.X[\"atr\"] = self.atr(period=14)\n        self.X[\"mom\"] = self.mom(period=10)\n\nml = MyMl(\n    mail_address=\"<your J-Quants mail address>\",\n    password=\"<your J-Quants password>\",\n    ticker=\"7203\",  # TOYOTA\n    size=100,  # 100 shares\n    outputs_dir_path=\"outputs\",\n    model_dir_path=\"model\",\n    data_dir_path=\"data\",\n)\npprint.pprint(ml.backtest())\npprint.pprint(ml.predict())\n```\n\n## Supported indicators\n\n- Simple Moving Average 'sma'\n- Exponential Moving Average 'ema'\n- Moving Average Convergence Divergence 'macd'\n- Relative Strenght Index 'rsi'\n- Bollinger Bands 'bbands'\n- Market Momentum 'mom'\n- Stochastic Oscillator 'stoch'\n- Average True Range 'atr'\n\n## Getting started\n\nFor help getting started with J-Quants, view our online [documentation](https://jpx-jquants.com/).\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "jquants-ml is a python library for machine learning with japanese stock trade using J-Quants on Python 3.8 and above.",
    "version": "0.1.4",
    "project_urls": {
        "Documentation": "https://github.com/10mohi6/jquants-ml-python",
        "Homepage": "https://github.com/10mohi6/jquants-ml-python",
        "Repository": "https://github.com/10mohi6/jquants-ml-python.git"
    },
    "split_keywords": [
        "machine learning",
        "python",
        "japanese stock",
        "trade",
        "j-quants",
        "jquants"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef603f6afcdbca90b8bf491d700523929fb89684e8dd430eb3372cd9df253278",
                "md5": "572a060ccd2c328e296a8a3fdcf322c4",
                "sha256": "55eb24e0891ac5d26cda397bf30a34281ab47c400e249741de10a868ffc7e1b3"
            },
            "downloads": -1,
            "filename": "jquants_ml-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "572a060ccd2c328e296a8a3fdcf322c4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6765,
            "upload_time": "2023-10-24T13:19:27",
            "upload_time_iso_8601": "2023-10-24T13:19:27.272889Z",
            "url": "https://files.pythonhosted.org/packages/ef/60/3f6afcdbca90b8bf491d700523929fb89684e8dd430eb3372cd9df253278/jquants_ml-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "297f4d765a6bb8fc8c3269832ae87d7c4ef95146958afcba5277f2b89dcbdea9",
                "md5": "faa5f7692f086a1b917af027135fc00c",
                "sha256": "83241eb992dcf1c80cd1f684b8592ce6409eea0cf6588eecb002d62534081df5"
            },
            "downloads": -1,
            "filename": "jquants-ml-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "faa5f7692f086a1b917af027135fc00c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7387,
            "upload_time": "2023-10-24T13:19:31",
            "upload_time_iso_8601": "2023-10-24T13:19:31.176226Z",
            "url": "https://files.pythonhosted.org/packages/29/7f/4d765a6bb8fc8c3269832ae87d7c4ef95146958afcba5277f2b89dcbdea9/jquants-ml-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-24 13:19:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "10mohi6",
    "github_project": "jquants-ml-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "jquants-ml"
}
        
Elapsed time: 2.37003s