Skip to main content

risk calc

Project description

RQRISK

simple and fast indicator calculator

Install

pip install rqrisk [--upgrade]

Usage

import packages

import rqrisk

  • create Risk object

risk = rqrisk.Risk(portfolio_returns, benchmark_returns, risk_free_rate, period)

  • get result

result = risk.all() # dict

Example

In [1]: import rqrisk

In [2]: import numpy

In [3]: risk = rqrisk.Risk(
   ...:     # 组合日收益率
   ...:     daily_returns=numpy.array([0.0006, 0.0213, -0.0155, -0.017, -0.0025, -0.0173, -0.0006, -0.0094, 0.0108, -0.0151]),
   ...:     # 基准日收益率
   ...:     benchmark_daily_returns=numpy.array([0.0024, 0.0048, -0.0036, -0.013, 0.0107, -0.0203, 0.0097, 0.0018, 0.0083, -0.0089]),
   ...:     # 无风险利率
   ...:     risk_free_rate=0.02
   ...: )
   
In [4]: risk.all()
Out[4]: 
{'return_rate': -0.04454119145160703,
 'annual_return': -0.6827938423763955,
 'benchmark_return': -0.008557443372075783,
 'benchmark_annual_return': -0.19472831925009826,
 'alpha': -0.9467029842994686,
 'beta': 0.8912056741947679,
 'volatility': 0.013005985801417234,
 'annual_volatility': 0.2064636239147226,
 'benchmark_volatility': 0.010414781162687322,
 'benchmark_annual_volatility': 0.1653295254937847,
 'max_drawdown': 0.06502900516774743,
 'tracking_error': 0.009180922248518028,
 'annual_tracking_error': 0.14574262245479186,
 'information_ratio': -0.4113963917368945,
 'sharpe': -5.55274570048971,
 'excess_sharpe': -6.328416385440682,
 'downside_risk': 0.011371747671783752,
 'annual_downside_risk': 0.1805208978703054,
 'sortino': -6.350732870959105,
 'calmar': -10.499835275275627,
 'excess_return_rate': -0.036369224165807304,
 'excess_annual_return': -0.6068586934419611,
 'excess_volatility': 0.009180922248518028,
 'excess_annual_volatility': 0.14574262245479186,
 'excess_max_drawdown': 0.050301584825935344,
 'var': 0.025161857442751474,
 'win_rate': 0.3,
 'correlation': 0.7136492542281812}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rqrisk-1.0.13.tar.gz (12.1 kB view details)

Uploaded Source

File details

Details for the file rqrisk-1.0.13.tar.gz.

File metadata

  • Download URL: rqrisk-1.0.13.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for rqrisk-1.0.13.tar.gz
Algorithm Hash digest
SHA256 f6d1aa74e5dbff5ea695990b425a7451bdb863be33c0ced2bb37d139ff686faf
MD5 31808ce0ea38caa4e70a6e918d4b5966
BLAKE2b-256 64ec3a754b612823cc41115c6d5ea84356df3ef5f367255ab756ec5194a04dc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page