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.
| Parser | Record | Optional sorting | Raw API |
|---|---|---|---|
FlatFiles.Stock.Trade | StockTrade | sort_by_participant_timestamp or sort_by_sip_timestamp | parse_raw, raw_lines |
FlatFiles.Stock.Quote | StockQuote | sort_by_participant_timestamp or sort_by_sip_timestamp | parse_raw, raw_lines |
FlatFiles.Crypto.Trade | CryptoTrade | sort_by_participant_timestamp | parse_raw, raw_lines |
FlatFiles.currency.Quote | CurrencyQuote | sort_by_participant_timestamp | parse_raw, raw_lines |
FlatFiles.Indices.Value | IndexValue | sort_by_timestamp | parse_raw, raw_lines |
FlatFiles.Futures.Trade | FuturesTrade | No sort arguments | Typed parse only |
FlatFiles.Futures.Quote | FuturesQuote | No sort arguments | Typed parse only |
FlatFiles.Options.Trade | OptionTrade | sort_by_sip_timestamp | parse_raw, raw_lines |
FlatFiles.Options.Quote | OptionQuote | sort_by_sip_timestamp | parse_raw, raw_lines |
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)
breakUnsorted 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)| Function | Returns | Header / empty lines |
|---|---|---|
gzip_lines | Iterator of bytes; line endings removed. | Includes the header and empty lines. |
read_gzip_lines | Python generator delegating to gzip_lines. | Includes the header and empty lines. |
read_gzip_lines_bytes | list[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
| Field | Python type | Meaning |
|---|---|---|
ticker | str | Instrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout. |
conditions | frozenset[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. |
correction | int | Source correction code, as an integer. |
exchange | int | Source exchange identifier, as an integer. |
id | int | Source trade identifier, parsed as an integer. |
participant_timestamp | int | Participant/exchange timestamp, in nanoseconds since Unix epoch. |
price | float | Reported trade price. |
sequence_number | int | Source sequence number. |
sip_timestamp | int | SIP receipt timestamp, in nanoseconds since Unix epoch; the stock/option database sort key. |
size | float | Reported trade quantity. Stock and crypto trades expose a float; futures and option trades expose an int. |
tape | int | Source tape identifier. |
trf_id | int | Trade reporting facility identifier. |
trf_timestamp | int | Trade reporting facility timestamp, in nanoseconds; zero is retained when supplied. |
decimal_size | str | Exact stock-trade size represented as a decimal string, without the float conversion. |
size_coefficient | int | Integer coefficient for the stock-trade size's stored decimal representation. |
size_scale | int | Decimal 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.
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
| Field | Python type | Meaning |
|---|---|---|
ticker | str | Instrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout. |
ask_exchange | int | Exchange identifier for the ask. |
ask_price | float | Reported ask price. A blank futures quote price is represented as NaN. |
ask_size | int | Reported ask size, as an integer; source units are preserved. |
bid_exchange | int | Exchange identifier for the bid. |
bid_price | float | Reported bid price. A blank futures quote price is represented as NaN. |
bid_size | int | Reported bid size, as an integer; source units are preserved. |
conditions | frozenset[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. |
indicators | frozenset[int] | Quote indicator codes as a frozenset of integers. Included with conditions when evaluating the stock quote update helpers. |
participant_timestamp | int | Participant/exchange timestamp, in nanoseconds since Unix epoch. |
sequence_number | int | Source sequence number. |
sip_timestamp | int | SIP receipt timestamp, in nanoseconds since Unix epoch; the stock/option database sort key. |
tape | int | Source tape identifier. |
trf_timestamp | int | Trade reporting facility timestamp, in nanoseconds; zero is retained when supplied. |
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
| Field | Python type | Meaning |
|---|---|---|
ticker | str | Instrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout. |
conditions | frozenset[int] | Condition codes attached to the record. Known stock codes use the corresponding condition enum; unrecognized stock codes and crypto/option codes remain integers. |
exchange | int | Source exchange identifier, as an integer. |
id | int | Source trade identifier, parsed as an integer. |
participant_timestamp | int | Participant/exchange timestamp, in nanoseconds since Unix epoch. |
price | float | Reported trade price. |
size | float | Reported trade quantity. Stock and crypto trades expose a float; futures and option trades expose an int. |
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
| Field | Python type | Meaning |
|---|---|---|
ticker | str | Instrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout. |
ask_exchange | int | Exchange identifier for the ask. |
ask_price | float | Reported ask price. A blank futures quote price is represented as NaN. |
bid_exchange | int | Exchange identifier for the bid. |
bid_price | float | Reported bid price. A blank futures quote price is represented as NaN. |
participant_timestamp | int | Participant/exchange timestamp, in nanoseconds since Unix epoch. |
tickers | tuple[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.
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
| Field | Python type | Meaning |
|---|---|---|
ticker | str | Instrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout. |
value | float | Reported index value. |
timestamp | int | Primary event timestamp, in nanoseconds since Unix epoch. |
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
| Field | Python type | Meaning |
|---|---|---|
ticker | str | Instrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout. |
timestamp | int | Primary event timestamp, in nanoseconds since Unix epoch. |
sequence_number | int | Source sequence number. |
report_sequence | int | Source report sequence number. |
price | float | Reported trade price. |
size | int | Reported trade quantity. Stock and crypto trades expose a float; futures and option trades expose an int. |
correction | int | Source correction code, as an integer. |
exchange | int | Source exchange identifier, as an integer. |
session_end_date | str | Futures session ending date, as YYYY-MM-DD. |
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
| Field | Python type | Meaning |
|---|---|---|
ticker | str | Instrument identifier from the CSV. Database filenames retain this identifier except for the expanded option contract layout. |
timestamp | int | Primary event timestamp, in nanoseconds since Unix epoch. |
sequence_number | int | Source sequence number. |
report_sequence | int | Source report sequence number. |
ask_timestamp | int | Timestamp of the ask component, in nanoseconds since Unix epoch. |
ask_price | float | Reported ask price. A blank futures quote price is represented as NaN. |
ask_size | int | Reported ask size, as an integer; source units are preserved. |
bid_timestamp | int | Timestamp of the bid component, in nanoseconds since Unix epoch. |
bid_price | float | Reported bid price. A blank futures quote price is represented as NaN. |
bid_size | int | Reported bid size, as an integer; source units are preserved. |
exchange | int | Source exchange identifier, as an integer. |
session_end_date | str | Futures session ending date, as YYYY-MM-DD. |
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.
| Field | Python type | Meaning |
|---|---|---|
root | str | Underlying/root symbol decoded from the option ticker. |
expiration | str | Option expiration date, as YYYY-MM-DD. |
right | str | Option right: "C" for call or "P" for put. |
strike | float | Option strike price, decoded from thousandths in the source symbol. |
conditions | frozenset[int] | Condition codes attached to the record. Known stock codes use the corresponding condition enum; unrecognized stock codes and crypto/option codes remain integers. |
correction | int | Source correction code, as an integer. |
exchange | int | Source exchange identifier, as an integer. |
price | float | Reported trade price. |
sip_timestamp | int | SIP receipt timestamp, in nanoseconds since Unix epoch; the stock/option database sort key. |
size | int | Reported trade quantity. Stock and crypto trades expose a float; futures and option trades expose an int. |
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.
| Field | Python type | Meaning |
|---|---|---|
root | str | Underlying/root symbol decoded from the option ticker. |
expiration | str | Option expiration date, as YYYY-MM-DD. |
right | str | Option right: "C" for call or "P" for put. |
strike | float | Option strike price, decoded from thousandths in the source symbol. |
ask_exchange | int | Exchange identifier for the ask. |
ask_price | float | Reported ask price. A blank futures quote price is represented as NaN. |
ask_size | int | Reported ask size, as an integer; source units are preserved. |
bid_exchange | int | Exchange identifier for the bid. |
bid_price | float | Reported bid price. A blank futures quote price is represented as NaN. |
bid_size | int | Reported bid size, as an integer; source units are preserved. |
sequence_number | int | Source sequence number. |
sip_timestamp | int | SIP receipt timestamp, in nanoseconds since Unix epoch; the stock/option database sort key. |
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) -> RowThese 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.
| Record | Bytes | Static extraction methods |
|---|---|---|
StockTrade | 78 | participant_timestamp_from_packed(packed)sip_timestamp_from_packed(packed) |
StockQuote | 83 | participant_timestamp_from_packed(packed)sip_timestamp_from_packed(packed) |
CryptoTrade | 46 | participant_timestamp_from_packed(packed) |
CurrencyQuote | 26 | participant_timestamp_from_packed(packed) |
IndexValue | 16 | timestamp_from_packed(packed) |
FuturesTrade | 42 | timestamp_from_packed(packed) |
FuturesQuote | 66 | timestamp_from_packed(packed) |
OptionTrade | 32 | sip_timestamp_from_packed(packed) |
OptionQuote | 44 | sip_timestamp_from_packed(packed) |
All packed layout constants
| Class | Constant | Value |
|---|---|---|
StockTrade | packed_participant_timestamp_offset | 33 |
StockTrade | packed_sip_timestamp_offset | 0 |
StockTrade | packed_size | 78 |
StockTrade | packed_size_offset | 57 |
StockTrade | packed_size_scale_offset | 65 |
StockQuote | packed_participant_timestamp_offset | 58 |
StockQuote | packed_sip_timestamp_offset | 0 |
StockQuote | packed_size | 83 |
CryptoTrade | packed_participant_timestamp_offset | 0 |
CryptoTrade | packed_size | 46 |
CryptoTrade | packed_size_offset | 24 |
CurrencyQuote | packed_participant_timestamp_offset | 0 |
CurrencyQuote | packed_size | 26 |
IndexValue | packed_size | 16 |
IndexValue | packed_timestamp_offset | 0 |
IndexValue | packed_value_offset | 8 |
FuturesTrade | packed_session_end_date_offset | 38 |
FuturesTrade | packed_size | 42 |
FuturesTrade | packed_size_offset | 28 |
FuturesTrade | packed_timestamp_offset | 0 |
FuturesQuote | packed_session_end_date_offset | 62 |
FuturesQuote | packed_size | 66 |
FuturesQuote | packed_timestamp_offset | 0 |
OptionTrade | packed_sip_timestamp_offset | 0 |
OptionTrade | packed_size | 32 |
OptionQuote | packed_sip_timestamp_offset | 0 |
OptionQuote | packed_size | 44 |
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.
| Method | Returns | Rule |
|---|---|---|
updates_high_low() | bool | Whether all active known condition rules permit high/low updates. |
updates_open_close() | bool | Whether all active known condition rules permit open/close updates. |
updates_volume() | bool | Whether 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
| Member | Integer code |
|---|---|
ACQUISITION | 1 |
AVERAGE_PRICE_TRADE | 2 |
AUTOMATIC_EXECUTION | 3 |
BUNCHED_TRADE | 4 |
BUNCHED_SOLD_TRADE | 5 |
CAP_ELECTION | 6 |
CASH_SALE | 7 |
CLOSING_PRINTS | 8 |
CROSS_TRADE | 9 |
DERIVATIVELY_PRICED | 10 |
DISTRIBUTION | 11 |
FORM_T_EXTENDED_HOURS | 12 |
EXTENDED_HOURS_SOLD_OUT_OF_SEQUENCE | 13 |
INTERMARKET_SWEEP | 14 |
MARKET_CENTER_OFFICIAL_CLOSE | 15 |
MARKET_CENTER_OFFICIAL_OPEN | 16 |
MARKET_CENTER_OPENING_TRADE | 17 |
MARKET_CENTER_REOPENING_TRADE | 18 |
MARKET_CENTER_CLOSING_TRADE | 19 |
NEXT_DAY | 20 |
PRICE_VARIATION_TRADE | 21 |
PRIOR_REFERENCE_PRICE | 22 |
RULE_155_TRADE_AMEX | 23 |
RULE_127_NYSE_ONLY | 24 |
OPENING_PRINTS | 25 |
STOPPED_STOCK_REGULAR_TRADE | 27 |
RE_OPENING_PRINTS | 28 |
SELLER | 29 |
SOLD_LAST | 30 |
SOLD_LAST_AND_STOPPED_STOCK | 31 |
SOLD_OUT_OF_SEQUENCE | 32 |
SOLD_OUT_OF_SEQUENCE_AND_STOPPED_STOCK | 33 |
SPLIT_TRADE | 34 |
STOCK_OPTION | 35 |
YELLOW_FLAG_REGULAR_TRADE | 36 |
ODD_LOT_TRADE | 37 |
CORRECTED_CONSOLIDATED_CLOSE_PER_LISTING_MARKET | 38 |
TRADE_THRU_EXEMPT | 41 |
CONTINGENT_TRADE | 52 |
QUALIFIED_CONTINGENT_TRADE | 53 |
OPENING_REOPENING_TRADE_DETAIL | 55 |
SHORT_SALE_RESTRICTION_ACTIVATED | 57 |
SHORT_SALE_RESTRICTION_CONTINUED | 58 |
SHORT_SALE_RESTRICTION_DEACTIVATED | 59 |
SHORT_SALE_RESTRICTION_IN_EFFECT | 60 |
FINANCIAL_STATUS_BANKRUPT | 62 |
FINANCIAL_STATUS_DEFICIENT | 63 |
FINANCIAL_STATUS_DELINQUENT | 64 |
FINANCIAL_STATUS_BANKRUPT_AND_DEFICIENT | 65 |
FINANCIAL_STATUS_BANKRUPT_AND_DELINQUENT | 66 |
FINANCIAL_STATUS_DEFICIENT_AND_DELINQUENT | 67 |
FINANCIAL_STATUS_DEFICIENT_DELINQUENT_AND_BANKRUPT | 68 |
FINANCIAL_STATUS_LIQUIDATION | 69 |
FINANCIAL_STATUS_CREATIONS_SUSPENDED | 70 |
FINANCIAL_STATUS_REDEMPTIONS_SUSPENDED | 71 |
StockQuoteCondition — 38 named members
| Member | Integer code |
|---|---|
REGULAR_TWO_SIDED_OPEN | 1 |
REGULAR_ONE_SIDED_OPEN | 2 |
SLOW_ASK | 3 |
SLOW_BID | 4 |
SLOW_BID_AND_ASK | 5 |
SLOW_DUE_LRP_BID | 6 |
SLOW_DUE_LRP_ASK | 7 |
SLOW_DUE_SET_SLOW_LIST_BID_ASK | 9 |
MANUAL_ASK_AUTOMATED_BID | 10 |
MANUAL_BID_AUTOMATED_ASK | 11 |
MANUAL_BID_AND_ASK | 12 |
OPENING | 13 |
CLOSING | 14 |
CLOSED | 15 |
RESUME | 16 |
FAST_TRADING | 17 |
TRADING_RANGE_INDICATION | 18 |
MARKET_MAKER_QUOTES_CLOSED | 19 |
NON_FIRM | 20 |
NEWS_DISSEMINATION | 21 |
ORDER_INFLUX | 22 |
ORDER_IMBALANCE | 23 |
ADDITIONAL_INFORMATION | 26 |
NEWS_PENDING | 27 |
ADDITIONAL_INFORMATION_DUE_TO_RELATED_SECURITY | 28 |
DUE_TO_RELATED_SECURITY | 29 |
IN_VIEW_OF_COMMON | 30 |
NO_OPEN_NO_RESUME | 32 |
ON_DEMAND_AUCTION | 40 |
CASH_ONLY_SETTLEMENT | 41 |
NEXT_DAY_SETTLEMENT | 42 |
LULD_TRADING_PAUSE | 43 |
SLOW_DUE_LRP_BID_AND_ASK | 71 |
CORRECTED_PRICE_INDICATION | 81 |
SIP_GENERATED | 82 |
CROSSED_MARKET | 84 |
LOCKED_MARKET | 85 |
CQS_GENERATED | 94 |
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.
| Reader alias | Public constructor | Result class | Time key |
|---|---|---|---|
FlatFiles.Stock.Trade.Aggregator | StockTradeAggregator | StockTradeAggregation | sip_timestamp |
FlatFiles.Stock.Quote.Aggregator | StockQuoteAggregator | StockQuoteAggregation | sip_timestamp |
FlatFiles.Crypto.Trade.Aggregator | CryptoTradeAggregator | CryptoTradeAggregation | participant_timestamp |
FlatFiles.currency.Quote.Aggregator | CurrencyQuoteAggregator | CurrencyQuoteAggregation | participant_timestamp |
FlatFiles.Indices.Value.Aggregator | IndexValueAggregator | IndexValueAggregation | timestamp |
FlatFiles.Futures.Trade.Aggregator | FuturesTradeAggregator | FuturesTradeAggregation | timestamp |
FlatFiles.Futures.Quote.Aggregator | FuturesQuoteAggregator | FuturesQuoteAggregation | timestamp |
FlatFiles.Options.Trade.Aggregator | OptionTradeAggregator | OptionTradeAggregation | sip_timestamp |
FlatFiles.Options.Quote.Aggregator | OptionQuoteAggregator | OptionQuoteAggregation | sip_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.
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.
| Field | Type | Meaning |
|---|---|---|
ticker | str | Instrument key. Option aggregates use the expanded contract key. |
open | float | First eligible finite value. |
close | float | Last eligible finite value. |
high | float | Highest eligible finite value. |
low | float | Lowest eligible finite value. |
avg | float | Arithmetic mean of eligible finite observations. |
volume_weighted_avg | float | Σ(price × positive eligible size) / Σ(positive eligible size). |
volume | float | Sum of included trade sizes. |
window_start | int | Window start in nanoseconds since epoch. |
transactions | int | Number of input rows in the group, including rows whose condition excludes a price or volume update. |
stddev | float | Population standard deviation of eligible finite observations. |
dollar_volume | float | Sum of finite price × positive eligible trade size. |
avg_trade_size | float | volume / transactions. |
min_trade_size | float | Smallest included per-row size; a filtered or nonpositive stock size contributes zero. |
max_trade_size | float | Largest included per-row size. |
price_change | float | close − open. |
return_bps | float | (close / open − 1) × 10,000; NaN when undefined or open is zero. |
price_range | float | high − low. |
range_bps | float | (high − low) / open × 10,000; NaN when undefined or open is zero. |
first_timestamp | int | Timestamp of the first row in the group (nanoseconds). |
last_timestamp | int | Timestamp of the last row in the group (nanoseconds). |
duration_ns | int | last_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.
| Field | Type | Meaning |
|---|---|---|
ticker | str | Instrument key. Option aggregates use the expanded contract key. |
ask_open | float | Ask : First eligible finite value. |
ask_close | float | Ask : Last eligible finite value. |
ask_high | float | Ask : Highest eligible finite value. |
ask_low | float | Ask : Lowest eligible finite value. |
ask_avg | float | Ask : Arithmetic mean of eligible finite observations. |
ask_volume_weighted_avg | float | Ask : Mean price weighted by positive reported size on this side. |
ask_volume | int | Ask : Sum of reported sizes for this side. |
ask_stddev | float | Ask : Population standard deviation of eligible finite observations. |
bid_open | float | Bid : First eligible finite value. |
bid_close | float | Bid : Last eligible finite value. |
bid_high | float | Bid : Highest eligible finite value. |
bid_low | float | Bid : Lowest eligible finite value. |
bid_avg | float | Bid : Arithmetic mean of eligible finite observations. |
bid_volume_weighted_avg | float | Bid : Mean price weighted by positive reported size on this side. |
bid_volume | int | Bid : Sum of reported sizes for this side. |
bid_stddev | float | Bid : Population standard deviation of eligible finite observations. |
window_start | int | Window start in nanoseconds since epoch. |
transactions | int | Number of input rows in the group, including rows whose condition excludes a price or volume update. |
ask_change | float | Ask : close − open. |
ask_return_bps | float | Ask : (close / open − 1) × 10,000; NaN when undefined or open is zero. |
ask_range | float | Ask : high − low. |
ask_range_bps | float | Ask : (high − low) / open × 10,000; NaN when undefined or open is zero. |
bid_change | float | Bid : close − open. |
bid_return_bps | float | Bid : (close / open − 1) × 10,000; NaN when undefined or open is zero. |
bid_range | float | Bid : high − low. |
bid_range_bps | float | Bid : (high − low) / open × 10,000; NaN when undefined or open is zero. |
spread_open | float | Spread : First eligible finite value. |
spread_close | float | Spread : Last eligible finite value. |
spread_high | float | Spread : Highest eligible finite value. |
spread_low | float | Spread : Lowest eligible finite value. |
spread_avg | float | Spread : Arithmetic mean of eligible finite observations. |
spread_stddev | float | Spread : Population standard deviation of eligible finite observations. |
spread_change | float | Spread : close − open. |
spread_return_bps | float | Spread : (close / open − 1) × 10,000; NaN when undefined or open is zero. |
spread_range | float | Spread : high − low. |
spread_range_bps | float | Spread : (high − low) / open × 10,000; NaN when undefined or open is zero. |
mid_open | float | Mid : First eligible finite value. |
mid_close | float | Mid : Last eligible finite value. |
mid_high | float | Mid : Highest eligible finite value. |
mid_low | float | Mid : Lowest eligible finite value. |
mid_avg | float | Mid : Arithmetic mean of eligible finite observations. |
mid_stddev | float | Mid : Population standard deviation of eligible finite observations. |
mid_change | float | Mid : close − open. |
mid_return_bps | float | Mid : (close / open − 1) × 10,000; NaN when undefined or open is zero. |
mid_range | float | Mid : high − low. |
mid_range_bps | float | Mid : (high − low) / open × 10,000; NaN when undefined or open is zero. |
locked_count | int | Number of rows with ask equal to bid. |
crossed_count | int | Number of rows with bid greater than ask. |
zero_ask_size_count | int | Number of rows with zero ask size. |
zero_bid_size_count | int | Number of rows with zero bid size. |
size_imbalance_avg | float | Mean of (bid_size − ask_size) / (bid_size + ask_size) for nonzero combined size. |
microprice_avg | float | Mean of (ask_price × bid_size + bid_price × ask_size) / (bid_size + ask_size) for nonzero combined size. |
time_weighted_ask_avg | float | Time-weighted ask price/spread, holding each observed value until the next update or window end; no weight before the first observation. |
time_weighted_bid_avg | float | Time-weighted bid price/spread, holding each observed value until the next update or window end; no weight before the first observation. |
time_weighted_mid_avg | float | Time-weighted mid price/spread, holding each observed value until the next update or window end; no weight before the first observation. |
time_weighted_spread_avg | float | Time-weighted spread price/spread, holding each observed value until the next update or window end; no weight before the first observation. |
first_timestamp | int | Timestamp of the first row in the group (nanoseconds). |
last_timestamp | int | Timestamp of the last row in the group (nanoseconds). |
duration_ns | int | last_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.
| Field | Type | Meaning |
|---|---|---|
ticker | str | Instrument identifier. |
ask_open | float | Ask : First eligible finite value. |
ask_close | float | Ask : Last eligible finite value. |
ask_high | float | Ask : Highest eligible finite value. |
ask_low | float | Ask : Lowest eligible finite value. |
ask_avg | float | Ask : Arithmetic mean of eligible finite observations. |
ask_stddev | float | Ask : Population standard deviation of eligible finite observations. |
bid_open | float | Bid : First eligible finite value. |
bid_close | float | Bid : Last eligible finite value. |
bid_high | float | Bid : Highest eligible finite value. |
bid_low | float | Bid : Lowest eligible finite value. |
bid_avg | float | Bid : Arithmetic mean of eligible finite observations. |
bid_stddev | float | Bid : Population standard deviation of eligible finite observations. |
window_start | int | Window start in nanoseconds since epoch. |
transactions | int | Number of input rows in the group, including rows whose condition excludes a price or volume update. |
ask_change | float | Ask : close − open. |
ask_return_bps | float | Ask : (close / open − 1) × 10,000; NaN when undefined or open is zero. |
ask_range | float | Ask : high − low. |
ask_range_bps | float | Ask : (high − low) / open × 10,000; NaN when undefined or open is zero. |
bid_change | float | Bid : close − open. |
bid_return_bps | float | Bid : (close / open − 1) × 10,000; NaN when undefined or open is zero. |
bid_range | float | Bid : high − low. |
bid_range_bps | float | Bid : (high − low) / open × 10,000; NaN when undefined or open is zero. |
spread_open | float | Spread : First eligible finite value. |
spread_close | float | Spread : Last eligible finite value. |
spread_high | float | Spread : Highest eligible finite value. |
spread_low | float | Spread : Lowest eligible finite value. |
spread_avg | float | Spread : Arithmetic mean of eligible finite observations. |
spread_stddev | float | Spread : Population standard deviation of eligible finite observations. |
spread_change | float | Spread : close − open. |
spread_return_bps | float | Spread : (close / open − 1) × 10,000; NaN when undefined or open is zero. |
spread_range | float | Spread : high − low. |
spread_range_bps | float | Spread : (high − low) / open × 10,000; NaN when undefined or open is zero. |
mid_open | float | Mid : First eligible finite value. |
mid_close | float | Mid : Last eligible finite value. |
mid_high | float | Mid : Highest eligible finite value. |
mid_low | float | Mid : Lowest eligible finite value. |
mid_avg | float | Mid : Arithmetic mean of eligible finite observations. |
mid_stddev | float | Mid : Population standard deviation of eligible finite observations. |
mid_change | float | Mid : close − open. |
mid_return_bps | float | Mid : (close / open − 1) × 10,000; NaN when undefined or open is zero. |
mid_range | float | Mid : high − low. |
mid_range_bps | float | Mid : (high − low) / open × 10,000; NaN when undefined or open is zero. |
locked_count | int | Number of rows with ask equal to bid. |
crossed_count | int | Number of rows with bid greater than ask. |
time_weighted_ask_avg | float | Time-weighted ask price/spread, holding each observed value until the next update or window end; no weight before the first observation. |
time_weighted_bid_avg | float | Time-weighted bid price/spread, holding each observed value until the next update or window end; no weight before the first observation. |
time_weighted_mid_avg | float | Time-weighted mid price/spread, holding each observed value until the next update or window end; no weight before the first observation. |
first_timestamp | int | Timestamp of the first row in the group (nanoseconds). |
last_timestamp | int | Timestamp of the last row in the group (nanoseconds). |
duration_ns | int | last_timestamp − first_timestamp; observed span, not the configured window width. |
ValueAggregation
Index-value result fields; no trade size or volume is present.
| Field | Type | Meaning |
|---|---|---|
ticker | str | Instrument identifier. |
open | float | First eligible finite value. |
close | float | Last eligible finite value. |
high | float | Highest eligible finite value. |
low | float | Lowest eligible finite value. |
avg | float | Arithmetic mean of eligible finite observations. |
stddev | float | Population standard deviation of eligible finite observations. |
window_start | int | Window start in nanoseconds since epoch. |
transactions | int | Number of input rows in the group, including rows whose condition excludes a price or volume update. |
value_change | float | close − open. |
return_bps | float | (close / open − 1) × 10,000; NaN when undefined or open is zero. |
value_range | float | high − low. |
range_bps | float | (high − low) / open × 10,000; NaN when undefined or open is zero. |
first_timestamp | int | Timestamp of the first row in the group (nanoseconds). |
last_timestamp | int | Timestamp of the last row in the group (nanoseconds). |
duration_ns | int | last_timestamp − first_timestamp; observed span, not the configured window width. |