Skip to main content

Utility methods for common tasks in QuantRocket.

Project description

QuantRocket Utility Library

Utility methods for common tasks in QuantRocket.


quantrocket-utils can be installed via pip:

$ pip install quantrocket-utils


This project uses poetry for development and release management.

$ git clone
$ 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


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


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

# 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
>> 756733
>> "SPY"
>> "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

Project details

Download files

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

Files for quantrocket-utils, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size quantrocket_utils-0.2.0-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size quantrocket-utils-0.2.0.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page