System Constants & Enums
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The hyperdrive library utilizes a centralized system for managing constants and path configurations to ensure consistency across its data collection, quantitative research, and automated trading modules. These constants define core data schemas for market indicators, social sentiment, and economic statistics, while also providing a standardized interface for interacting with various third-party data providers like IEXCloud, Polygon.io, and Glassnode.
This centralized approach allows the library to maintain uniform column naming conventions (e.g., Time, Open, Close, Vol) regardless of the source API's native format. It also facilitates environment-aware pathing, enabling the system to switch between production and development storage buckets seamlessly during testing and CI/CD pipelines.
Sources: hyperdrive/Constants.py, hyperdrive/DataSource.py:15-25, README.md
Data Schema Constants
The system defines a set of standardized keys used throughout the application to reference specific data columns in DataFrames and CSV files. This abstraction allows the library to map diverse API responses into a common internal representation.
Core Market & Financial Keys
These constants represent standard OHLCV (Open, High, Low, Close, Volume) data and corporate actions.
| Constant | Value (Commonly Used As) | Description |
|---|---|---|
TIME | 'Time' | Standard timestamp column |
OPEN | 'Open' | Opening price of the period |
HIGH | 'High' | Highest price of the period |
LOW | 'Low' | Lowest price of the period |
CLOSE | 'Close' | Closing price of the period |
VOL | 'Vol' | Trading volume |
DIV | 'Amount' | Dividend payment amount |
EX | 'Ex-Date' | Dividend or split ex-date |
Sources: hyperdrive/Constants.py, hyperdrive/DataSource.py:100-115, test/test_DataSource.py:65-75
Quantitative & Sentiment Keys
The library includes specific constants for technical indicators, social media sentiment from StockTwits, and blockchain metrics from Glassnode.
| Constant | Description | Usage Context |
|---|---|---|
POS | Bullish sentiment score | Social Sentiment Data |
NEG | Bearish sentiment score | Social Sentiment Data |
DELTA | Change in volume/sentiment | Social Volume Analysis |
RATIO | Stock-to-Flow or Split ratio | Glassnode / Corporate Actions |
MAs | Moving Average identifiers | Difficulty Ribbon metrics |
SOPR | Spent Output Profit Ratio | Bitcoin blockchain analytics |
Sources: hyperdrive/DataSource.py:228-240, hyperdrive/DataSource.py:440-455, test/test_DataSource.py:130-145
Path Management Logic
The PathFinder class serves as the primary engine for generating file paths within the storage hierarchy. It categorizes data by provider and symbol, ensuring a structured layout for both cached data and API outputs.
Path Resolution Flow
The following diagram illustrates how the PathFinder resolves paths for different types of market data.
The system ensures that symbol names are consistently capitalized in paths, even if provided in lowercase, and supports multi-provider structures (e.g., iexcloud vs polygon).
Sources: test/test_Constants.py:15-60, hyperdrive/DataSource.py:140-150
API & Provider Configurations
The library defines constants for API interaction, including retry logic and provider-specific limits.
- Default Retries:
DEFAULT_RETRIESandDEFAULT_DELAYare used in thetry_againwrapper to handle transient network errors. - Polygon.io Limits:
POLY_FREE_DELAYensures compliance with the free tier rate limits of the Polygon API by enforcing a delay between calls. - Date Formats:
DATE_FMT('%Y-%m-%d') andTIME_FMTare defined to standardize string-to-datetime conversions.
Sources: hyperdrive/DataSource.py:27-45, hyperdrive/DataSource.py:380-388, test/test_DataSource.py:365-375
Operational & Environment Constants
The system uses specific flags to differentiate between execution environments:
- CI Flag:
C.CIis a boolean used to detect if the code is running in a Continuous Integration environment (like GitHub Actions). - Dev Storage: When
C.CIis false, the system often reassigns storage buckets to a developer-specific S3 bucket (S3_DEV_BUCKET) to prevent polluting production data. - Testnet Flag:
C.TESTdetermines whether orders are executed against a live exchange (Binance) or a sandbox/testnet environment.
Summary
The constants and enums in the hyperdrive repository form the backbone of its data-agnostic architecture. By abstracting file paths through PathFinder and standardizing data keys in Constants.py, the system allows for the integration of diverse data sources while maintaining a clean, unified internal API for quant research and order execution.
Sources: hyperdrive/Constants.py, hyperdrive/DataSource.py, README.md