Skip to main content

QuantRocket Utility Library

Utility methods for common tasks in QuantRocket.

Installation

quantrocket-utils can be installed via pip:

$ pip install quantrocket-utils

Development

This project uses poetry for development and release management.

$ git clone git@github.com:boosting-alpha-bv/quantrocket-utils.git
$ cd quantrocket-utils/
$ poetry install

Running Tests

$ poetry run coverage run --branch --source quantrocket_utils -m pytest

Generating Coverage Reports

$ poetry run coverage html

Running flake8

$ poetry run flake8 quantrocket_utils tests

Deploying

$ poetry publish --build --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" --no-interaction

Usage

This library requires an external file that contains the listing information for the stocks it should translate. This is typically exported from QuantRocket and then supplied at initialization time of the library. Work is currently under way to remove the dependency on QuantRocket for obtaining this listings file.

# Import the library and initialize the ConID resolution
from quantrocket_utils import initialize as assets_init, Asset
assets_init("<path>/<to>/listings.csv")

# Create an Asset using the symbol name
spy = Asset("SPY")
# The exchange is optional, unless two symbols of the same name exist on different exchanges
spy = Asset("SPY", "ARCA")

# Create an Asset using the ConID
# In this case the exchange can be inferred from the ConID, so it is always otpional
spy = Asset(756733)
# ConID's can be strings as well, so don't worry about type conversion
spy = Asset("756733")

# Access data on the object
spy.conid
>> 756733
spy.symbol
>> "SPY"
spy.exchange
>> "ARCA"

# Check trading times
spy.can_trade("2019-03-04", "10:34:02")
>> True

# Assets also support equality and comparison operations based on the ConID
# However, this is mostly just useful for guaranteeing sorting order
# Assets are also hashable and can thus be utilized in set operations
Asset("SPY") < Asset("AAPL")
>> True

Metadata

Release files for quantrocket-utils 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quantrocket-utils 0.2.0
File Size Uploaded
quantrocket-utils-0.2.0.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for quantrocket-utils 0.2.0
File Interpreter ABI Platform
quantrocket_utils-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / quantrocket-utils-0.2.0.tar.gz

Download URL quantrocket-utils-0.2.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5a29b3249348aefd9b53146d919679821436ab5b08dcf5e00ff91e98a9eb4672
BLAKE2b-256 checksum
How to use checksums
4ed6b63fa9b95b6c8b8ea9df55008f6df00a10aa8e441f9cc432edf4bf7489e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.4 Darwin/18.7.0

Release files / quantrocket_utils-0.2.0-py3-none-any.whl

Download URL quantrocket_utils-0.2.0-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f11bb61065a17797233c7fae7bf96d30bdc1bd25c8734ad63d541cc418c7e73
BLAKE2b-256 checksum
How to use checksums
28eeaf579b207c36a874d97a3cfbf82742cc5af48994870a0324b735525fc21d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.4 Darwin/18.7.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page