AHL Research Versioned TimeSeries and Tick store for high-performance financial data storage and analysis
npx @tessl/cli install tessl/pypi-arctic@1.82.0A high-performance versioned TimeSeries and tick database designed for financial data storage and analysis. Arctic provides multiple storage engines including VersionStore for versioned key-value TimeSeries data with pandas support, TickStore for column-oriented tick data, and ChunkStore for customizable chunk-based storage.
pip install arcticimport arcticCommon usage pattern:
from arctic import Arctic, VERSION_STORE, TICK_STORE, CHUNK_STOREfrom arctic import Arctic, VERSION_STORE
import pandas as pd
import numpy as np
# Connect to Arctic
arctic_conn = Arctic('mongodb://localhost:27017')
# Initialize a library
arctic_conn.initialize_library('my_data', VERSION_STORE)
# Get library
library = arctic_conn['my_data']
# Create sample data
data = pd.DataFrame({
'price': np.random.randn(1000),
'volume': np.random.randint(100, 1000, 1000)
}, index=pd.date_range('2020-01-01', periods=1000, freq='min'))
# Write data
library.write('AAPL', data)
# Read data back
retrieved_data = library.read('AAPL')
print(retrieved_data.data.head())Arctic uses a multi-layered architecture optimized for financial time series data:
Core functionality for connecting to MongoDB, managing libraries, and handling authentication. Provides the main entry point for all Arctic operations including library lifecycle management and quota control.
class Arctic:
def __init__(self, mongo_host, app_name='arctic', allow_secondary=False,
socketTimeoutMS=600000, connectTimeoutMS=2000,
serverSelectionTimeoutMS=30000, **kwargs): ...
def list_libraries(self, newer_than_secs=None): ...
def initialize_library(self, library, lib_type=VERSION_STORE, **kwargs): ...
def get_library(self, library): ...
def delete_library(self, library): ...
def register_library_type(name, type_): ...Versioned storage for pandas DataFrames and Series with complete audit trails, point-in-time snapshots, and efficient data retrieval. Supports temporal data access, metadata management, and multi-version data handling.
class VersionStore:
def read(self, symbol, as_of=None, date_range=None, from_version=None, **kwargs): ...
def write(self, symbol, data, metadata=None, prune_previous_version=True, **kwargs): ...
def append(self, symbol, data, metadata=None, prune_previous_version=True, **kwargs): ...
def list_versions(self, symbol=None, snapshot=None, latest_only=False): ...
def snapshot(self, snap_name, metadata=None, skip_symbols=None, versions=None): ...High-frequency tick data storage with efficient columnar compression and time-based partitioning. Optimized for financial tick data with support for initial images, metadata persistence, and date range queries.
class TickStore:
def __init__(self, arctic_lib, chunk_size=100000): ...
def read(self, symbol, date_range=None, columns=None, include_images=False, **kwargs): ...
def write(self, symbol, data, initial_image=None, metadata=None): ...
def max_date(self, symbol): ...
def min_date(self, symbol): ...Configurable chunked storage for large datasets with custom serialization strategies and date-based chunking. Supports append/update operations, audit trails, and flexible data organization patterns.
class ChunkStore:
def read(self, symbol, chunk_range=None, filter_data=True, **kwargs): ...
def write(self, symbol, item, metadata=None, chunker=DateChunker(), **kwargs): ...
def append(self, symbol, item, upsert=False, metadata=None, **kwargs): ...
def update(self, symbol, item, chunk_range=None, upsert=False, **kwargs): ...
def get_chunk_ranges(self, symbol, chunk_range=None, reverse=False): ...Raw MongoDB document storage providing full PyMongo interface for direct database operations. Enables custom document structures, aggregation pipelines, and advanced MongoDB features within Arctic's framework.
class BSONStore:
def find(self, *args, **kwargs): ...
def insert_one(self, document, **kwargs): ...
def update_one(self, filter, update, **kwargs): ...
def aggregate(self, pipeline, **kwargs): ...
def create_index(self, keys, **kwargs): ...Comprehensive date/time handling for financial data including timezone management, date range operations, and time series utilities. Provides robust datetime conversion and time-based data filtering capabilities.
class DateRange:
def __init__(self, start, end, step=None): ...
def mktz(timezone): ...
def datetime_to_ms(dt): ...
def ms_to_datetime(ms): ...
def to_pandas_closed_closed(date_range): ...Asynchronous execution framework for Arctic operations enabling concurrent data processing and improved performance for batch operations. Provides thread pool management and request tracking.
def async_arctic_submit(store, fun, is_modifier, *args, **kwargs): ...
def async_wait_request(request, timeout=None): ...
def async_wait_requests(requests, timeout=None): ...
def async_shutdown(timeout=None): ...class Arctic:
"""Main Arctic database connection and library manager."""
class ArcticLibraryBinding:
"""Library-specific interface for Arctic operations."""
class VersionedItem:
"""Container for versioned data with metadata."""
def __init__(self, symbol, library, data, version, metadata, host=None): ...
def metadata_dict(self): ...
class DateRange:
"""Date/time range specification for queries and operations."""
def __init__(self, start, end, step=None): ...VERSION_STORE = "VersionStore"
TICK_STORE = "TickStoreV3"
CHUNK_STORE = "ChunkStoreV1"
METADATA_STORE = "MetadataStore"
BSON_STORE = "BSONStore"class ArcticException(Exception):
"""Base exception for all Arctic errors."""
class NoDataFoundException(ArcticException):
"""Raised when requested data doesn't exist."""
class LibraryNotFoundException(ArcticException):
"""Raised when library doesn't exist."""
class QuotaExceededException(ArcticException):
"""Raised when storage quota exceeded."""
class UnhandledDtypeException(ArcticException):
"""Raised for unsupported data types."""
class OverlappingDataException(ArcticException):
"""Raised when data ranges overlap improperly."""
class UnorderedDataException(ArcticException):
"""Raised when data isn't properly time-ordered."""