Python API / native extension

CSV.gz readers

Exact parser signatures, every record field, binary packing, condition enums, and window aggregation for all supported instrument types.

Typed readers, raw fields, and lines

Pass a local gzip path to the parser for the file's dataset. parse skips the CSV header and empty rows and yields read-only record objects. parse_raw yields tuples of bytes in original CSV column order. Neither requires an extracted CSV or a database.

Every CSV.gz parser
ParserRecordOptional sortingRaw API
FlatFiles.Stock.TradeStockTradesort_by_participant_timestamp or sort_by_sip_timestampparse_raw, raw_lines
FlatFiles.Stock.QuoteStockQuotesort_by_participant_timestamp or sort_by_sip_timestampparse_raw, raw_lines
FlatFiles.Crypto.TradeCryptoTradesort_by_participant_timestampparse_raw, raw_lines
FlatFiles.currency.QuoteCurrencyQuotesort_by_participant_timestampparse_raw, raw_lines
FlatFiles.Indices.ValueIndexValuesort_by_timestampparse_raw, raw_lines
FlatFiles.Futures.TradeFuturesTradeNo sort argumentsTyped parse only
FlatFiles.Futures.QuoteFuturesQuoteNo sort argumentsTyped parse only
FlatFiles.Options.TradeOptionTradesort_by_sip_timestampparse_raw, raw_lines
FlatFiles.Options.QuoteOptionQuotesort_by_sip_timestampparse_raw, raw_lines
Read a compressed stock trade file
import os
from pathlib import Path
import massive_speedup as ms

path = Path(os.environ["MASSIVE_SPEEDUP_DOWNLOAD_PATH"])
path = path / "stock_trade" / "2026-09-11.csv.gz"
rows = ms.FlatFiles.Stock.Trade.parse(path, sort_by_sip_timestamp=True)
for trade in rows:
    if trade.ticker == "AAPL":
        print(trade.sip_timestamp, trade.price, trade.size)
        break

Unsorted readers preserve file order. A sorting flag loads the file's rows into memory before iteration and orders them by the selected timestamp. Stock flags are mutually exclusive. Currency's sort_by_sip_timestamp parameter must remain False; setting it raises ValueError. Futures readers accept only the path; use the database builder to sort futures tapes.

Paths must contain the expected dataset schema. Malformed fields or incorrect field counts raise errors. Integer timestamps preserve nanosecond precision; use SIP order for stock/option observations that model when the consolidated feed became available.

Gzip line API

ms.gzip_lines(path, parallelization=0, chunk_size=1048576)
ms.read_gzip_lines(path, parallelization=0, chunk_size=1048576)
ms.read_gzip_lines_bytes(path, parallelization=0, chunk_size=1048576)
Line reader behavior
FunctionReturnsHeader / empty lines
gzip_linesIterator of bytes; line endings removed.Includes the header and empty lines.
read_gzip_linesPython generator delegating to gzip_lines.Includes the header and empty lines.
read_gzip_lines_byteslist[bytes] materialized in memory.Includes the header and empty lines.
FlatFiles.… .raw_lines(path)Iterator of bytes with line endings removed; no CSV field conversion.Skips the first line and empty lines. Available only where listed in the reader table.

parallelization=0 selects the decoder's automatic parallelism; a positive integer supplies a decoder thread count. chunk_size is the read chunk size in bytes (default 1 MiB). Only the currency typed/raw field readers expose a parallelization keyword directly; other typed parsers use their internal defaults.

The asset-level convenience names FlatFiles.Stock.parse_trades, FlatFiles.Stock.parse_quotes, FlatFiles.Crypto.parse_trades, FlatFiles.currency.parse_quotes, FlatFiles.Indices.parse_values, and the corresponding option/futures parse_trades / parse_quotes call the same typed readers. Where supported, parse_raw_trades, parse_raw_quotes, and parse_raw_values mirror parse_raw.

StockTrade

ms.FlatFiles.Stock.Trade yields ms.StockTrade. Primary database/aggregation time key: sip_timestamp.

ms.FlatFiles.Stock.Trade.parse(path: str | os.PathLike, *, sort_by_participant_timestamp: bool = False, sort_by_sip_timestamp: bool = False) -> Iterator[StockTrade]
ms.FlatFiles.Stock.Trade.parse_raw(path: str | os.PathLike, *, sort_by_participant_timestamp: bool = False, sort_by_sip_timestamp: bool = False) -> Iterator[tuple[bytes, ...]]
ms.FlatFiles.Stock.Trade.raw_lines(path: str | os.PathLike) -> Iterator[bytes]

CSV column order:

ticker,conditions,correction,exchange,id,participant_timestamp,price,sequence_number,sip_timestamp,size,tape,trf_id,trf_timestamp

StockTrade read-only fields
FieldPython typeMeaning
tickerstrInstrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout.
conditionsfrozenset[StockTradeCondition | int]Condition codes attached to the record. Known stock codes use the corresponding condition enum; unrecognized stock codes and crypto/option codes remain integers.
correctionintSource correction code, as an integer.
exchangeintSource exchange identifier, as an integer.
idintSource trade identifier, parsed as an integer.
participant_timestampintParticipant/exchange timestamp, in nanoseconds since Unix epoch.
pricefloatReported trade price.
sequence_numberintSource sequence number.
sip_timestampintSIP receipt timestamp, in nanoseconds since Unix epoch; the stock/option database sort key.
sizefloatReported trade quantity. Stock and crypto trades expose a float; futures and option trades expose an int.
tapeintSource tape identifier.
trf_idintTrade reporting facility identifier.
trf_timestampintTrade reporting facility timestamp, in nanoseconds; zero is retained when supplied.
decimal_sizestrExact stock-trade size represented as a decimal string, without the float conversion.
size_coefficientintInteger coefficient for the stock-trade size's stored decimal representation.
size_scaleintDecimal scale; exact size is size_coefficient × 10^(-size_scale).

decimal_size, size_coefficient, and size_scale are derived accessors, not additional CSV columns. Use them when exact fractional-share quantities matter.

Open StockTrade records from a database →

StockQuote

ms.FlatFiles.Stock.Quote yields ms.StockQuote. Primary database/aggregation time key: sip_timestamp.

ms.FlatFiles.Stock.Quote.parse(path: str | os.PathLike, *, sort_by_participant_timestamp: bool = False, sort_by_sip_timestamp: bool = False) -> Iterator[StockQuote]
ms.FlatFiles.Stock.Quote.parse_raw(path: str | os.PathLike, *, sort_by_participant_timestamp: bool = False, sort_by_sip_timestamp: bool = False) -> Iterator[tuple[bytes, ...]]
ms.FlatFiles.Stock.Quote.raw_lines(path: str | os.PathLike) -> Iterator[bytes]

CSV column order:

ticker,ask_exchange,ask_price,ask_size,bid_exchange,bid_price,bid_size,conditions,indicators,participant_timestamp,sequence_number,sip_timestamp,tape,trf_timestamp

StockQuote read-only fields
FieldPython typeMeaning
tickerstrInstrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout.
ask_exchangeintExchange identifier for the ask.
ask_pricefloatReported ask price. A blank futures quote price is represented as NaN.
ask_sizeintReported ask size, as an integer; source units are preserved.
bid_exchangeintExchange identifier for the bid.
bid_pricefloatReported bid price. A blank futures quote price is represented as NaN.
bid_sizeintReported bid size, as an integer; source units are preserved.
conditionsfrozenset[StockQuoteCondition | int]Condition codes attached to the record. Known stock codes use the corresponding condition enum; unrecognized stock codes and crypto/option codes remain integers.
indicatorsfrozenset[int]Quote indicator codes as a frozenset of integers. Included with conditions when evaluating the stock quote update helpers.
participant_timestampintParticipant/exchange timestamp, in nanoseconds since Unix epoch.
sequence_numberintSource sequence number.
sip_timestampintSIP receipt timestamp, in nanoseconds since Unix epoch; the stock/option database sort key.
tapeintSource tape identifier.
trf_timestampintTrade reporting facility timestamp, in nanoseconds; zero is retained when supplied.

Open StockQuote records from a database →

CryptoTrade

ms.FlatFiles.Crypto.Trade yields ms.CryptoTrade. Primary database/aggregation time key: participant_timestamp.

ms.FlatFiles.Crypto.Trade.parse(path: str | os.PathLike, *, sort_by_participant_timestamp: bool = False) -> Iterator[CryptoTrade]
ms.FlatFiles.Crypto.Trade.parse_raw(path: str | os.PathLike, *, sort_by_participant_timestamp: bool = False) -> Iterator[tuple[bytes, ...]]
ms.FlatFiles.Crypto.Trade.raw_lines(path: str | os.PathLike) -> Iterator[bytes]

CSV column order:

ticker,conditions,exchange,id,participant_timestamp,price,size

CryptoTrade read-only fields
FieldPython typeMeaning
tickerstrInstrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout.
conditionsfrozenset[int]Condition codes attached to the record. Known stock codes use the corresponding condition enum; unrecognized stock codes and crypto/option codes remain integers.
exchangeintSource exchange identifier, as an integer.
idintSource trade identifier, parsed as an integer.
participant_timestampintParticipant/exchange timestamp, in nanoseconds since Unix epoch.
pricefloatReported trade price.
sizefloatReported trade quantity. Stock and crypto trades expose a float; futures and option trades expose an int.

Open CryptoTrade records from a database →

CurrencyQuote

ms.FlatFiles.currency.Quote yields ms.CurrencyQuote. Primary database/aggregation time key: participant_timestamp.

ms.FlatFiles.currency.Quote.parse(path: str | os.PathLike, *, sort_by_participant_timestamp: bool = False, sort_by_sip_timestamp: bool = False, parallelization: int = 0) -> Iterator[CurrencyQuote]
ms.FlatFiles.currency.Quote.parse_raw(path: str | os.PathLike, *, sort_by_participant_timestamp: bool = False, sort_by_sip_timestamp: bool = False, parallelization: int = 0) -> Iterator[tuple[bytes, ...]]
ms.FlatFiles.currency.Quote.raw_lines(path: str | os.PathLike) -> Iterator[bytes]

CSV column order:

ticker,ask_exchange,ask_price,bid_exchange,bid_price,participant_timestamp

CurrencyQuote read-only fields
FieldPython typeMeaning
tickerstrInstrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout.
ask_exchangeintExchange identifier for the ask.
ask_pricefloatReported ask price. A blank futures quote price is represented as NaN.
bid_exchangeintExchange identifier for the bid.
bid_pricefloatReported bid price. A blank futures quote price is represented as NaN.
participant_timestampintParticipant/exchange timestamp, in nanoseconds since Unix epoch.
tickerstuple[str, str]Derived pair of strings. Removes a prefix through ":" and splits at "-": C:EUR-USD becomes ("EUR", "USD"). Without "-", the second string is empty.

tickers is derived and does not add a CSV column. parallelization=0 uses automatic decoder parallelism; supply a positive count to cap it.

Open CurrencyQuote records from a database →

IndexValue

ms.FlatFiles.Indices.Value yields ms.IndexValue. Primary database/aggregation time key: timestamp.

ms.FlatFiles.Indices.Value.parse(path: str | os.PathLike, *, sort_by_timestamp: bool = False) -> Iterator[IndexValue]
ms.FlatFiles.Indices.Value.parse_raw(path: str | os.PathLike, *, sort_by_timestamp: bool = False) -> Iterator[tuple[bytes, ...]]
ms.FlatFiles.Indices.Value.raw_lines(path: str | os.PathLike) -> Iterator[bytes]

CSV column order:

ticker,value,timestamp

IndexValue read-only fields
FieldPython typeMeaning
tickerstrInstrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout.
valuefloatReported index value.
timestampintPrimary event timestamp, in nanoseconds since Unix epoch.

Open IndexValue records from a database →

FuturesTrade

ms.FlatFiles.Futures.Trade yields ms.FuturesTrade. Primary database/aggregation time key: timestamp.

ms.FlatFiles.Futures.Trade.parse(path: str | os.PathLike) -> Iterator[FuturesTrade]

CSV column order:

ticker,timestamp,sequence_number,report_sequence,price,size,correction,exchange,session_end_date

FuturesTrade read-only fields
FieldPython typeMeaning
tickerstrInstrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout.
timestampintPrimary event timestamp, in nanoseconds since Unix epoch.
sequence_numberintSource sequence number.
report_sequenceintSource report sequence number.
pricefloatReported trade price.
sizeintReported trade quantity. Stock and crypto trades expose a float; futures and option trades expose an int.
correctionintSource correction code, as an integer.
exchangeintSource exchange identifier, as an integer.
session_end_datestrFutures session ending date, as YYYY-MM-DD.

Open FuturesTrade records from a database →

FuturesQuote

ms.FlatFiles.Futures.Quote yields ms.FuturesQuote. Primary database/aggregation time key: timestamp.

ms.FlatFiles.Futures.Quote.parse(path: str | os.PathLike) -> Iterator[FuturesQuote]

CSV column order:

ticker,timestamp,sequence_number,report_sequence,ask_timestamp,ask_price,ask_size,bid_timestamp,bid_price,bid_size,exchange,session_end_date

FuturesQuote read-only fields
FieldPython typeMeaning
tickerstrInstrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout.
timestampintPrimary event timestamp, in nanoseconds since Unix epoch.
sequence_numberintSource sequence number.
report_sequenceintSource report sequence number.
ask_timestampintTimestamp of the ask component, in nanoseconds since Unix epoch.
ask_pricefloatReported ask price. A blank futures quote price is represented as NaN.
ask_sizeintReported ask size, as an integer; source units are preserved.
bid_timestampintTimestamp of the bid component, in nanoseconds since Unix epoch.
bid_pricefloatReported bid price. A blank futures quote price is represented as NaN.
bid_sizeintReported bid size, as an integer; source units are preserved.
exchangeintSource exchange identifier, as an integer.
session_end_datestrFutures session ending date, as YYYY-MM-DD.

Open FuturesQuote records from a database →

OptionTrade

ms.FlatFiles.Options.Trade yields ms.OptionTrade. Primary database/aggregation time key: sip_timestamp.

ms.FlatFiles.Options.Trade.parse(path: str | os.PathLike, *, sort_by_sip_timestamp: bool = False) -> Iterator[OptionTrade]
ms.FlatFiles.Options.Trade.parse_raw(path: str | os.PathLike, *, sort_by_sip_timestamp: bool = False) -> Iterator[tuple[bytes, ...]]
ms.FlatFiles.Options.Trade.raw_lines(path: str | os.PathLike) -> Iterator[bytes]

CSV column order:

ticker,conditions,correction,exchange,price,sip_timestamp,size

The raw CSV ticker is decoded into root, expiration, right, and strike. Typed option records have no ticker attribute. list(record) starts with those four fields, followed by the remaining CSV columns.

OptionTrade read-only fields
FieldPython typeMeaning
rootstrUnderlying/root symbol decoded from the option ticker.
expirationstrOption expiration date, as YYYY-MM-DD.
rightstrOption right: "C" for call or "P" for put.
strikefloatOption strike price, decoded from thousandths in the source symbol.
conditionsfrozenset[int]Condition codes attached to the record. Known stock codes use the corresponding condition enum; unrecognized stock codes and crypto/option codes remain integers.
correctionintSource correction code, as an integer.
exchangeintSource exchange identifier, as an integer.
pricefloatReported trade price.
sip_timestampintSIP receipt timestamp, in nanoseconds since Unix epoch; the stock/option database sort key.
sizeintReported trade quantity. Stock and crypto trades expose a float; futures and option trades expose an int.

Open OptionTrade records from a database →

OptionQuote

ms.FlatFiles.Options.Quote yields ms.OptionQuote. Primary database/aggregation time key: sip_timestamp.

ms.FlatFiles.Options.Quote.parse(path: str | os.PathLike, *, sort_by_sip_timestamp: bool = False) -> Iterator[OptionQuote]
ms.FlatFiles.Options.Quote.parse_raw(path: str | os.PathLike, *, sort_by_sip_timestamp: bool = False) -> Iterator[tuple[bytes, ...]]
ms.FlatFiles.Options.Quote.raw_lines(path: str | os.PathLike) -> Iterator[bytes]

CSV column order:

ticker,ask_exchange,ask_price,ask_size,bid_exchange,bid_price,bid_size,sequence_number,sip_timestamp

The raw CSV ticker is decoded into root, expiration, right, and strike. Typed option records have no ticker attribute. list(record) starts with those four fields, followed by the remaining CSV columns.

OptionQuote read-only fields
FieldPython typeMeaning
rootstrUnderlying/root symbol decoded from the option ticker.
expirationstrOption expiration date, as YYYY-MM-DD.
rightstrOption right: "C" for call or "P" for put.
strikefloatOption strike price, decoded from thousandths in the source symbol.
ask_exchangeintExchange identifier for the ask.
ask_pricefloatReported ask price. A blank futures quote price is represented as NaN.
ask_sizeintReported ask size, as an integer; source units are preserved.
bid_exchangeintExchange identifier for the bid.
bid_pricefloatReported bid price. A blank futures quote price is represented as NaN.
bid_sizeintReported bid size, as an integer; source units are preserved.
sequence_numberintSource sequence number.
sip_timestampintSIP receipt timestamp, in nanoseconds since Unix epoch; the stock/option database sort key.

Open OptionQuote records from a database →

Record construction, packing, and comparison

record = ms.StockTrade(fields)  # sequence of CSV field strings
packed = record.pack()
restored = ms.StockTrade.from_packed(packed, record.ticker)

Every record class accepts fields: Sequence[str] in its CSV schema order, supports pack() -> bytes, from_packed(...), list(record), equality, hashing, and text representation. Fields are read-only. For options, iteration replaces the source ticker with the four decoded contract fields. All other record iteration follows CSV field order; derived accessors are not appended.

Row.from_packed(packed: bytes, ticker: str) -> Row
# OptionTrade / OptionQuote use contract identity instead:
Row.from_packed(packed: bytes, root: str, expiration: str,
                right: str, strike: float) -> Row

These packed arguments also work as constructor overloads on every record class except CryptoTrade, which exposes only the from_packed method for restoration. Pass exactly Row.packed_size bytes. Ticker/contract identity is supplied separately because it is not in the packed bytes.

Packed record sizes and timestamp extractors
RecordBytesStatic extraction methods
StockTrade78participant_timestamp_from_packed(packed)
sip_timestamp_from_packed(packed)
StockQuote83participant_timestamp_from_packed(packed)
sip_timestamp_from_packed(packed)
CryptoTrade46participant_timestamp_from_packed(packed)
CurrencyQuote26participant_timestamp_from_packed(packed)
IndexValue16timestamp_from_packed(packed)
FuturesTrade42timestamp_from_packed(packed)
FuturesQuote66timestamp_from_packed(packed)
OptionTrade32sip_timestamp_from_packed(packed)
OptionQuote44sip_timestamp_from_packed(packed)
All packed layout constants
Read-only class constants (byte offsets)
ClassConstantValue
StockTradepacked_participant_timestamp_offset33
StockTradepacked_sip_timestamp_offset0
StockTradepacked_size78
StockTradepacked_size_offset57
StockTradepacked_size_scale_offset65
StockQuotepacked_participant_timestamp_offset58
StockQuotepacked_sip_timestamp_offset0
StockQuotepacked_size83
CryptoTradepacked_participant_timestamp_offset0
CryptoTradepacked_size46
CryptoTradepacked_size_offset24
CurrencyQuotepacked_participant_timestamp_offset0
CurrencyQuotepacked_size26
IndexValuepacked_size16
IndexValuepacked_timestamp_offset0
IndexValuepacked_value_offset8
FuturesTradepacked_session_end_date_offset38
FuturesTradepacked_size42
FuturesTradepacked_size_offset28
FuturesTradepacked_timestamp_offset0
FuturesQuotepacked_session_end_date_offset62
FuturesQuotepacked_size66
FuturesQuotepacked_timestamp_offset0
OptionTradepacked_sip_timestamp_offset0
OptionTradepacked_size32
OptionQuotepacked_sip_timestamp_offset0
OptionQuotepacked_size44

Stock, crypto, and currency record ordering operators compare participant timestamps; options compare SIP timestamps; index values compare their timestamp. Futures records do not define ordering operators: sort explicitly with key=lambda row: row.timestamp. Equality compares the record fields, not merely the time.

StockQuotes is an alias of StockQuote. Record classes are also exposed under FlatFiles for stock, crypto, currency, option, and index records; the reader APIs remain the nested Trade, Quote, and Value namespaces. Asset serialize() returns parser metadata as a string and processor_name() returns its processor label. FlatFiles.Forex is a legacy payload-summary parser, not an alias for FlatFiles.currency.Quote.

Stock condition enums and update rules

StockTrade.conditions and StockQuote.conditions are frozensets of the corresponding IntEnum members when a code is known, and integers otherwise. Stock quote indicators remain integers. Enum members compare to integers; members from different condition enum classes compare unequal and cannot be ordered against each other.

StockTrade and StockQuote methods
MethodReturnsRule
updates_high_low()boolWhether all active known condition rules permit high/low updates.
updates_open_close()boolWhether all active known condition rules permit open/close updates.
updates_volume()boolWhether all active known condition rules permit volume updates.

For quotes these helpers evaluate the union of conditions and indicators. With no exclusion rule present, the corresponding helper returns true. StockTradeAggregator uses these eligibility rules for price and size calculations. Quote aggregators consume the supplied quote values directly; use the quote helper methods to filter first if your calculation requires that policy.

StockTradeCondition — 55 named members
StockTradeCondition members
MemberInteger code
ACQUISITION1
AVERAGE_PRICE_TRADE2
AUTOMATIC_EXECUTION3
BUNCHED_TRADE4
BUNCHED_SOLD_TRADE5
CAP_ELECTION6
CASH_SALE7
CLOSING_PRINTS8
CROSS_TRADE9
DERIVATIVELY_PRICED10
DISTRIBUTION11
FORM_T_EXTENDED_HOURS12
EXTENDED_HOURS_SOLD_OUT_OF_SEQUENCE13
INTERMARKET_SWEEP14
MARKET_CENTER_OFFICIAL_CLOSE15
MARKET_CENTER_OFFICIAL_OPEN16
MARKET_CENTER_OPENING_TRADE17
MARKET_CENTER_REOPENING_TRADE18
MARKET_CENTER_CLOSING_TRADE19
NEXT_DAY20
PRICE_VARIATION_TRADE21
PRIOR_REFERENCE_PRICE22
RULE_155_TRADE_AMEX23
RULE_127_NYSE_ONLY24
OPENING_PRINTS25
STOPPED_STOCK_REGULAR_TRADE27
RE_OPENING_PRINTS28
SELLER29
SOLD_LAST30
SOLD_LAST_AND_STOPPED_STOCK31
SOLD_OUT_OF_SEQUENCE32
SOLD_OUT_OF_SEQUENCE_AND_STOPPED_STOCK33
SPLIT_TRADE34
STOCK_OPTION35
YELLOW_FLAG_REGULAR_TRADE36
ODD_LOT_TRADE37
CORRECTED_CONSOLIDATED_CLOSE_PER_LISTING_MARKET38
TRADE_THRU_EXEMPT41
CONTINGENT_TRADE52
QUALIFIED_CONTINGENT_TRADE53
OPENING_REOPENING_TRADE_DETAIL55
SHORT_SALE_RESTRICTION_ACTIVATED57
SHORT_SALE_RESTRICTION_CONTINUED58
SHORT_SALE_RESTRICTION_DEACTIVATED59
SHORT_SALE_RESTRICTION_IN_EFFECT60
FINANCIAL_STATUS_BANKRUPT62
FINANCIAL_STATUS_DEFICIENT63
FINANCIAL_STATUS_DELINQUENT64
FINANCIAL_STATUS_BANKRUPT_AND_DEFICIENT65
FINANCIAL_STATUS_BANKRUPT_AND_DELINQUENT66
FINANCIAL_STATUS_DEFICIENT_AND_DELINQUENT67
FINANCIAL_STATUS_DEFICIENT_DELINQUENT_AND_BANKRUPT68
FINANCIAL_STATUS_LIQUIDATION69
FINANCIAL_STATUS_CREATIONS_SUSPENDED70
FINANCIAL_STATUS_REDEMPTIONS_SUSPENDED71
StockQuoteCondition — 38 named members
StockQuoteCondition members
MemberInteger code
REGULAR_TWO_SIDED_OPEN1
REGULAR_ONE_SIDED_OPEN2
SLOW_ASK3
SLOW_BID4
SLOW_BID_AND_ASK5
SLOW_DUE_LRP_BID6
SLOW_DUE_LRP_ASK7
SLOW_DUE_SET_SLOW_LIST_BID_ASK9
MANUAL_ASK_AUTOMATED_BID10
MANUAL_BID_AUTOMATED_ASK11
MANUAL_BID_AND_ASK12
OPENING13
CLOSING14
CLOSED15
RESUME16
FAST_TRADING17
TRADING_RANGE_INDICATION18
MARKET_MAKER_QUOTES_CLOSED19
NON_FIRM20
NEWS_DISSEMINATION21
ORDER_INFLUX22
ORDER_IMBALANCE23
ADDITIONAL_INFORMATION26
NEWS_PENDING27
ADDITIONAL_INFORMATION_DUE_TO_RELATED_SECURITY28
DUE_TO_RELATED_SECURITY29
IN_VIEW_OF_COMMON30
NO_OPEN_NO_RESUME32
ON_DEMAND_AUCTION40
CASH_ONLY_SETTLEMENT41
NEXT_DAY_SETTLEMENT42
LULD_TRADING_PAUSE43
SLOW_DUE_LRP_BID_AND_ASK71
CORRECTED_PRICE_INDICATION81
SIP_GENERATED82
CROSSED_MARKET84
LOCKED_MARKET85
CQS_GENERATED94

Window aggregators for every record type

Aggregator(rows, interval_seconds: float, *, start_timestamp=None)
# Stock trades can also attach a broker:
ms.StockTradeAggregator(rows, interval_seconds, *, start_timestamp=None,
                        quotes=None, trade_emulator=None)

rows can be the matching native daily database or an iterable of matching record objects. interval_seconds must be positive and finite and resolve to at least one nanosecond; fractional seconds are supported. start_timestamp excludes earlier rows and anchors window boundaries; None anchors at epoch zero. A matching daily database also accepts datetime.time with the database date; other iterables require numeric nanoseconds.

Aggregation combines consecutive (instrument, window) groups. Use per-instrument, time-ordered input; globally interleaved symbols can produce multiple partial bars for the same window. Windows are [start, start + interval), empty windows are not emitted, and the last nonempty partial window is emitted at EOF. A completed bar belongs at the end of its window, never at its opening timestamp.

Aggregator classes and results
Reader aliasPublic constructorResult classTime key
FlatFiles.Stock.Trade.AggregatorStockTradeAggregatorStockTradeAggregationsip_timestamp
FlatFiles.Stock.Quote.AggregatorStockQuoteAggregatorStockQuoteAggregationsip_timestamp
FlatFiles.Crypto.Trade.AggregatorCryptoTradeAggregatorCryptoTradeAggregationparticipant_timestamp
FlatFiles.currency.Quote.AggregatorCurrencyQuoteAggregatorCurrencyQuoteAggregationparticipant_timestamp
FlatFiles.Indices.Value.AggregatorIndexValueAggregatorIndexValueAggregationtimestamp
FlatFiles.Futures.Trade.AggregatorFuturesTradeAggregatorFuturesTradeAggregationtimestamp
FlatFiles.Futures.Quote.AggregatorFuturesQuoteAggregatorFuturesQuoteAggregationtimestamp
FlatFiles.Options.Trade.AggregatorOptionTradeAggregatorOptionTradeAggregationsip_timestamp
FlatFiles.Options.Quote.AggregatorOptionQuoteAggregatorOptionQuoteAggregationsip_timestamp

Crypto, futures, and option trade result classes alias StockTradeAggregation. Futures and option quote results alias StockQuoteAggregation. IndexValueAggregation aliases ValueAggregation. Only StockTradeAggregator accepts quotes and trade_emulator; provide both together. Its broker and trade_emulator accessors are documented in the bar broker section.

Build one-minute bars from a database
import massive_speedup as ms

trades = ms.StockTradeDatabase("2026-09-11", "AAPL")
bars = ms.StockTradeAggregator(
    trades, interval_seconds=60, start_timestamp=trades.market_open
)
for bar in bars:
    print(bar.window_start, bar.close, bar.volume_weighted_avg)

Result attributes are read-only and lazily converted to Python values. Non-finite observations are excluded from price statistics; undefined means, returns, or weighted means can be NaN. Standard deviation is population standard deviation. Quote volume fields sum displayed sizes across updates, not executed share volume.

StockTradeAggregation

Trade-result fields shared by stock, crypto, futures, and options. Stock condition rules can select different rows for OHLC and volume.

StockTradeAggregation fields
FieldTypeMeaning
tickerstrInstrument key. Option aggregates use the expanded contract key.
openfloatFirst eligible finite value.
closefloatLast eligible finite value.
highfloatHighest eligible finite value.
lowfloatLowest eligible finite value.
avgfloatArithmetic mean of eligible finite observations.
volume_weighted_avgfloatΣ(price × positive eligible size) / Σ(positive eligible size).
volumefloatSum of included trade sizes.
window_startintWindow start in nanoseconds since epoch.
transactionsintNumber of input rows in the group, including rows whose condition excludes a price or volume update.
stddevfloatPopulation standard deviation of eligible finite observations.
dollar_volumefloatSum of finite price × positive eligible trade size.
avg_trade_sizefloatvolume / transactions.
min_trade_sizefloatSmallest included per-row size; a filtered or nonpositive stock size contributes zero.
max_trade_sizefloatLargest included per-row size.
price_changefloatclose − open.
return_bpsfloat(close / open − 1) × 10,000; NaN when undefined or open is zero.
price_rangefloathigh − low.
range_bpsfloat(high − low) / open × 10,000; NaN when undefined or open is zero.
first_timestampintTimestamp of the first row in the group (nanoseconds).
last_timestampintTimestamp of the last row in the group (nanoseconds).
duration_nsintlast_timestamp − first_timestamp; observed span, not the configured window width.

StockQuoteAggregation

Quote-result fields. Spread = ask − bid; mid = (ask + bid) / 2. Currency quotes have no size, volume, or size-weighted fields.

StockQuoteAggregation fields
FieldTypeMeaning
tickerstrInstrument key. Option aggregates use the expanded contract key.
ask_openfloatAsk : First eligible finite value.
ask_closefloatAsk : Last eligible finite value.
ask_highfloatAsk : Highest eligible finite value.
ask_lowfloatAsk : Lowest eligible finite value.
ask_avgfloatAsk : Arithmetic mean of eligible finite observations.
ask_volume_weighted_avgfloatAsk : Mean price weighted by positive reported size on this side.
ask_volumeintAsk : Sum of reported sizes for this side.
ask_stddevfloatAsk : Population standard deviation of eligible finite observations.
bid_openfloatBid : First eligible finite value.
bid_closefloatBid : Last eligible finite value.
bid_highfloatBid : Highest eligible finite value.
bid_lowfloatBid : Lowest eligible finite value.
bid_avgfloatBid : Arithmetic mean of eligible finite observations.
bid_volume_weighted_avgfloatBid : Mean price weighted by positive reported size on this side.
bid_volumeintBid : Sum of reported sizes for this side.
bid_stddevfloatBid : Population standard deviation of eligible finite observations.
window_startintWindow start in nanoseconds since epoch.
transactionsintNumber of input rows in the group, including rows whose condition excludes a price or volume update.
ask_changefloatAsk : close − open.
ask_return_bpsfloatAsk : (close / open − 1) × 10,000; NaN when undefined or open is zero.
ask_rangefloatAsk : high − low.
ask_range_bpsfloatAsk : (high − low) / open × 10,000; NaN when undefined or open is zero.
bid_changefloatBid : close − open.
bid_return_bpsfloatBid : (close / open − 1) × 10,000; NaN when undefined or open is zero.
bid_rangefloatBid : high − low.
bid_range_bpsfloatBid : (high − low) / open × 10,000; NaN when undefined or open is zero.
spread_openfloatSpread : First eligible finite value.
spread_closefloatSpread : Last eligible finite value.
spread_highfloatSpread : Highest eligible finite value.
spread_lowfloatSpread : Lowest eligible finite value.
spread_avgfloatSpread : Arithmetic mean of eligible finite observations.
spread_stddevfloatSpread : Population standard deviation of eligible finite observations.
spread_changefloatSpread : close − open.
spread_return_bpsfloatSpread : (close / open − 1) × 10,000; NaN when undefined or open is zero.
spread_rangefloatSpread : high − low.
spread_range_bpsfloatSpread : (high − low) / open × 10,000; NaN when undefined or open is zero.
mid_openfloatMid : First eligible finite value.
mid_closefloatMid : Last eligible finite value.
mid_highfloatMid : Highest eligible finite value.
mid_lowfloatMid : Lowest eligible finite value.
mid_avgfloatMid : Arithmetic mean of eligible finite observations.
mid_stddevfloatMid : Population standard deviation of eligible finite observations.
mid_changefloatMid : close − open.
mid_return_bpsfloatMid : (close / open − 1) × 10,000; NaN when undefined or open is zero.
mid_rangefloatMid : high − low.
mid_range_bpsfloatMid : (high − low) / open × 10,000; NaN when undefined or open is zero.
locked_countintNumber of rows with ask equal to bid.
crossed_countintNumber of rows with bid greater than ask.
zero_ask_size_countintNumber of rows with zero ask size.
zero_bid_size_countintNumber of rows with zero bid size.
size_imbalance_avgfloatMean of (bid_size − ask_size) / (bid_size + ask_size) for nonzero combined size.
microprice_avgfloatMean of (ask_price × bid_size + bid_price × ask_size) / (bid_size + ask_size) for nonzero combined size.
time_weighted_ask_avgfloatTime-weighted ask price/spread, holding each observed value until the next update or window end; no weight before the first observation.
time_weighted_bid_avgfloatTime-weighted bid price/spread, holding each observed value until the next update or window end; no weight before the first observation.
time_weighted_mid_avgfloatTime-weighted mid price/spread, holding each observed value until the next update or window end; no weight before the first observation.
time_weighted_spread_avgfloatTime-weighted spread price/spread, holding each observed value until the next update or window end; no weight before the first observation.
first_timestampintTimestamp of the first row in the group (nanoseconds).
last_timestampintTimestamp of the last row in the group (nanoseconds).
duration_nsintlast_timestamp − first_timestamp; observed span, not the configured window width.

CurrencyQuoteAggregation

Quote-result fields. Spread = ask − bid; mid = (ask + bid) / 2. Currency quotes have no size, volume, or size-weighted fields.

CurrencyQuoteAggregation fields
FieldTypeMeaning
tickerstrInstrument identifier.
ask_openfloatAsk : First eligible finite value.
ask_closefloatAsk : Last eligible finite value.
ask_highfloatAsk : Highest eligible finite value.
ask_lowfloatAsk : Lowest eligible finite value.
ask_avgfloatAsk : Arithmetic mean of eligible finite observations.
ask_stddevfloatAsk : Population standard deviation of eligible finite observations.
bid_openfloatBid : First eligible finite value.
bid_closefloatBid : Last eligible finite value.
bid_highfloatBid : Highest eligible finite value.
bid_lowfloatBid : Lowest eligible finite value.
bid_avgfloatBid : Arithmetic mean of eligible finite observations.
bid_stddevfloatBid : Population standard deviation of eligible finite observations.
window_startintWindow start in nanoseconds since epoch.
transactionsintNumber of input rows in the group, including rows whose condition excludes a price or volume update.
ask_changefloatAsk : close − open.
ask_return_bpsfloatAsk : (close / open − 1) × 10,000; NaN when undefined or open is zero.
ask_rangefloatAsk : high − low.
ask_range_bpsfloatAsk : (high − low) / open × 10,000; NaN when undefined or open is zero.
bid_changefloatBid : close − open.
bid_return_bpsfloatBid : (close / open − 1) × 10,000; NaN when undefined or open is zero.
bid_rangefloatBid : high − low.
bid_range_bpsfloatBid : (high − low) / open × 10,000; NaN when undefined or open is zero.
spread_openfloatSpread : First eligible finite value.
spread_closefloatSpread : Last eligible finite value.
spread_highfloatSpread : Highest eligible finite value.
spread_lowfloatSpread : Lowest eligible finite value.
spread_avgfloatSpread : Arithmetic mean of eligible finite observations.
spread_stddevfloatSpread : Population standard deviation of eligible finite observations.
spread_changefloatSpread : close − open.
spread_return_bpsfloatSpread : (close / open − 1) × 10,000; NaN when undefined or open is zero.
spread_rangefloatSpread : high − low.
spread_range_bpsfloatSpread : (high − low) / open × 10,000; NaN when undefined or open is zero.
mid_openfloatMid : First eligible finite value.
mid_closefloatMid : Last eligible finite value.
mid_highfloatMid : Highest eligible finite value.
mid_lowfloatMid : Lowest eligible finite value.
mid_avgfloatMid : Arithmetic mean of eligible finite observations.
mid_stddevfloatMid : Population standard deviation of eligible finite observations.
mid_changefloatMid : close − open.
mid_return_bpsfloatMid : (close / open − 1) × 10,000; NaN when undefined or open is zero.
mid_rangefloatMid : high − low.
mid_range_bpsfloatMid : (high − low) / open × 10,000; NaN when undefined or open is zero.
locked_countintNumber of rows with ask equal to bid.
crossed_countintNumber of rows with bid greater than ask.
time_weighted_ask_avgfloatTime-weighted ask price/spread, holding each observed value until the next update or window end; no weight before the first observation.
time_weighted_bid_avgfloatTime-weighted bid price/spread, holding each observed value until the next update or window end; no weight before the first observation.
time_weighted_mid_avgfloatTime-weighted mid price/spread, holding each observed value until the next update or window end; no weight before the first observation.
first_timestampintTimestamp of the first row in the group (nanoseconds).
last_timestampintTimestamp of the last row in the group (nanoseconds).
duration_nsintlast_timestamp − first_timestamp; observed span, not the configured window width.

ValueAggregation

Index-value result fields; no trade size or volume is present.

ValueAggregation fields
FieldTypeMeaning
tickerstrInstrument identifier.
openfloatFirst eligible finite value.
closefloatLast eligible finite value.
highfloatHighest eligible finite value.
lowfloatLowest eligible finite value.
avgfloatArithmetic mean of eligible finite observations.
stddevfloatPopulation standard deviation of eligible finite observations.
window_startintWindow start in nanoseconds since epoch.
transactionsintNumber of input rows in the group, including rows whose condition excludes a price or volume update.
value_changefloatclose − open.
return_bpsfloat(close / open − 1) × 10,000; NaN when undefined or open is zero.
value_rangefloathigh − low.
range_bpsfloat(high − low) / open × 10,000; NaN when undefined or open is zero.
first_timestampintTimestamp of the first row in the group (nanoseconds).
last_timestampintTimestamp of the last row in the group (nanoseconds).
duration_nsintlast_timestamp − first_timestamp; observed span, not the configured window width.