Skip to main content

Intro

Takes a DataFrames containing information for multiple future contracts and creates a corresponding continuous contract (ratio back-adjusted, on highest volume).

Installation

Use pip install continuous_futures

Example

from continuous_futures import create_continuous_contract
import pandas as pd

contract1 = pd.DataFrame([
    ['2023-01-01', 15.2, 13.8, 128, '2023F'],
    ['2023-01-02', 15.1, 13.9, 133, '2023F'],
    ['2023-01-03', 14.8, 14.1, 125, '2023F'],
], columns=['Date', 'Open', 'Close', 'Volume', 'Contract'])

contract2 = pd.DataFrame([
    ['2023-01-02', 15.0, 13.2, 129, '2023G'],
    ['2023-01-04', 14.0, 13.1, 130, '2023G'],
    ['2023-01-05', 14.2, 14.0, 140, '2023G'],
], columns=['Date', 'Open', 'Close', 'Volume', 'Contract'])

merged = pd.concat([contract1, contract2])

continuous = create_continuous_contract(merged, 'Date', 'Volume', 'Contract', ['Open', 'Close'], ['Open'])

Parameters

  • data: DataFrame Order must be chronological: first by contract, then by date. Oldest date of oldest contract first. Must contain all columns whose names are passed to this function as parameters.
  • date_column_name: str Name of the column that contains the date
  • volume_column_name: str Name of the column that contains the volume; used to determine rollovers (on highest volume)
  • contract_column_name: str Name of the column that contains the contract name; used determine where contracts change within the DataFrame
  • adjustment_factor_columns_names: list of str Names of the columns to calculate the ratio from; usually only ['close']; if multiple are passed, their mean is used.
  • adjustment_column_names: list of str Names of the columns to adjust by the ratio on rollovers.

Metadata

Release files for continuous-futures 0.0.2

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

Source distribution (sdist)

Source distribution for continuous-futures 0.0.2
File Size Uploaded Provenance
continuous_futures-0.0.2.tar.gz 6.8 kB Without provenance Details

Release files / continuous_futures-0.0.2.tar.gz

Download URL continuous_futures-0.0.2.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c4686258dc5ff615dea1e018343a9b5783b9dc63dac35588dc668bb40baeb360
BLAKE2b-256 checksum
How to use checksums
66145938240e8e44efa61219ddba087e3c63de48a14ea5f5fb0ebaae88cd6b25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.2

Security for continuous-futures 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

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