jquants-pairs-trading is a python library for backtest with japanese stock pairs trading using kalman filter, J-Quants on Python 3.8 and above.
Project description
jquants-pairs-trading
jquants-pairs-trading is a python library for backtest with japanese stock pairs trading using kalman filter, J-Quants on Python 3.8 and above.
Installation
$ pip install jquants-pairs-trading
Usage
find pairs
from jquants_pairs_trading import JquantsPairsTrading
import pprint
jpt = JquantsPairsTrading(
mail_address="<your J-Quants mail address>",
password="<your J-Quants password>",
)
pprint.pprint(jpt.find_pairs([3382, 4063, 4502]))
[('3382', '4502')]
backtest
from jquants_pairs_trading import JquantsPairsTrading
import pprint
jpt = JquantsPairsTrading(
mail_address="<your J-Quants mail address>",
password="<your J-Quants password>",
)
pprint.pprint(jpt.backtest((3382, 4502)))
{'cointegration': '0.016',
'correlation': '0.814',
'maximum_drawdown': '443.000',
'profit_factor': '1.654',
'riskreward_ratio': '1.081',
'sharpe_ratio': '0.183',
'total_profit': '2184.000',
'total_trades': '86.000',
'win_rate': '0.605'}
latest signal
from jquants_pairs_trading import JquantsPairsTrading
import pprint
jpt = JquantsPairsTrading(
mail_address="<your J-Quants mail address>",
password="<your J-Quants password>",
)
pprint.pprint(jpt.latest_signal((6954, 6981)))
{'6954 buy': True,
'6954 close': '4348.000',
'6954 long': False,
'6954 sell': False,
'6954 short': False,
'6981 buy': False,
'6981 close': '2775.000',
'6981 long': False,
'6981 sell': True,
'6981 short': False,
'date': '2023-07-31'}
advanced
from jquants_pairs_trading import JquantsPairsTrading
import pprint
jpt = JquantsPairsTrading(
mail_address="<your J-Quants mail address>",
password="<your J-Quants password>",
window=1,
transition_covariance=0.01,
pvalues=0.05,
zscore=0.5,
)
pprint.pprint(jpt.find_pairs([3382, 4063, 4502]))
pprint.pprint(jpt.backtest((3382, 4502)))
pprint.pprint(jpt.latest_signal((6954, 6981)))
Getting started
For help getting started with J-Quants, view our online documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for jquants-pairs-trading-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6a7e164f7ad6bd816c438287dafc0d20fa9af45bd26005182515eb10b5ddd4d |
|
MD5 | 2a1fc9ff66c1e3baff8ed394fb98f84c |
|
BLAKE2b-256 | e3f0c12f06ca47832dbcb17d9d8770e57feae5f98ed73fe2e5f196f5954e567a |
Close
Hashes for jquants_pairs_trading-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32f35e9d6c31994b7f9f05086eb5ac63a5730a4c0cfdc73004a46cb2e03d3030 |
|
MD5 | 3639348bd29640fdeaa3863ea70064f8 |
|
BLAKE2b-256 | 2e60d0b39728b633027ab2d3adcd59c814ee54a192f69a7d4e307c8cd494caed |