Skip to main content

Lightweight library for backtesting factor strategies

Project description

pqr

pqr is a python library for backtesting factor strategies. It is built in top of numpy, so it is fast and memory efficient, but provides pandas interface to make usage more convenient and verbose.

Installation

Use the package manager pip to install pqr.

pip install pqr

Quickstart

import pandas as pd
import pqr

prices = pd.read_csv("prices.csv", parse_dates=True)

momentum = pqr.compose(
    # picking
    pqr.freeze(pqr.filter, universe=prices > 10),
    pqr.freeze(pqr.look_back, period=12, agg="pct"),
    pqr.freeze(pqr.lag, period=1),
    pqr.freeze(pqr.hold, period=12),
    pqr.freeze(pqr.quantiles, min_q=0.7, max_q=1),
    # allocation
    pqr.ew,
    # evaluation
    pqr.freeze(pqr.evaluate, universe_returns=pqr.to_returns(prices)),
)

# returns series of returns of 30% ew momentum 12-1-12 strategy for stocks > 10$
momentum(prices)

Documentation

The official documentation is hosted on readthedocs.org: https://pqr.readthedocs.io/en/latest/

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests and documentation as appropriate.

License

MIT

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

pqr-1.0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

pqr-1.0.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file pqr-1.0.1.tar.gz.

File metadata

  • Download URL: pqr-1.0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.13.0-44-generic

File hashes

Hashes for pqr-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2634dafb5b96e66fb2a2b393a91d44495c6adc97025fe2482f03c92cfce16ae1
MD5 9622803654a9f6c00df9cb340fb6b877
BLAKE2b-256 f706468afd25cb2690c03546241f03e4d796fed042eb982fa857e4842e848436

See more details on using hashes here.

File details

Details for the file pqr-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pqr-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.13.0-44-generic

File hashes

Hashes for pqr-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a39f952e93138ef1c9e41d2268077a8873d6704f17ef61cfbb2302fd65c44eb
MD5 689b12889220af27c08712a59f70dece
BLAKE2b-256 70f420ab221bba9f0cf43a58306778d0785ec1d22972a5fd9c29d651fdb696d0

See more details on using hashes here.

Supported by

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