Skip to main content

Nanobind/C++ parsers for polygon, bulk S3, and websocket market data.

Project description

massive-speedup

Native C++/nanobind readers for Polygon/Massive flat-file market data.

See INSTALL.md for installation details and DEVELOPMENT.md for release and PyPI publishing notes.

CSV Gzip Files

Install/build the native extension:

pip3 install -e .

Iterate parsed records directly from a .csv.gz file:

import massive_speedup

for trade in massive_speedup.FlatFiles.Stock.Trade.parse("trades.csv.gz"):
    print(trade.ticker, trade.sip_timestamp, trade.price)

for quote in massive_speedup.FlatFiles.Stock.Quote.parse("quotes.csv.gz"):
    print(quote.ticker, quote.bid_price, quote.ask_price)

for quote in massive_speedup.FlatFiles.currency.Quote.parse("currency_quotes.csv.gz"):
    print(quote.ticker, quote.participant_timestamp)

You can also iterate raw CSV fields as bytes tuples:

for row in massive_speedup.FlatFiles.Stock.Trade.parse_raw("trades.csv.gz"):
    print(row[0], row[8])

Example scripts:

Record Access

Parsed records expose read-only attributes and are iterable in CSV field order:

trade = next(massive_speedup.FlatFiles.Stock.Trade.parse("trades.csv.gz"))

print(trade.ticker)
print(trade.conditions)
print(trade.sip_timestamp)
print(trade.pack())
print(list(trade))

Packed records do not include the ticker. Reconstruct with the ticker from the file name:

packed = trade.pack()
trade2 = massive_speedup.StockTrade.from_packed(packed, trade.ticker)

Window Aggregation

The native aggregators consume iterables of parsed records and yield C++ result objects exposed through nanobind. Result attributes are read-only and lazily converted to Python objects on first access. The aggregation interval and offset are expressed in seconds; the returned window_start is still nanoseconds since epoch.

import massive_speedup

trades = massive_speedup.FlatFiles.Stock.Trade.parse("trades.csv.gz")

for bar in massive_speedup.FlatFiles.Stock.Trade.Aggregator(
    trades,
    interval_seconds=60,
):
    print(
        bar.ticker,
        bar.window_start,
        bar.open,
        bar.close,
        bar.high,
        bar.low,
        bar.avg,
        bar.volume_weighted_avg,
        bar.volume,
        bar.transactions,
        bar.stddev,
    )

Available aggregators:

  • massive_speedup.StockTradeAggregator / FlatFiles.Stock.Trade.Aggregator
  • massive_speedup.StockQuoteAggregator / FlatFiles.Stock.Quote.Aggregator
  • massive_speedup.CurrencyQuoteAggregator / FlatFiles.currency.Quote.Aggregator

Stock trades aggregate price and use size for volume and volume_weighted_avg. Stock quotes aggregate ask and bid prices separately and use ask/bid sizes for ask/bid volume-weighted averages. Currency quotes aggregate ask and bid prices separately and omit volume and volume-weighted averages because the source rows have no size field.

quotes = massive_speedup.StockQuoteDatabase("/data/massive-db", "2026-01-23", "A")

for quote_bar in massive_speedup.StockQuoteAggregator(
    quotes,
    interval_seconds=1,
    offset_seconds=0,
):
    print(quote_bar.ask_open, quote_bar.ask_close, quote_bar.bid_avg)

Aggregators stream consecutive (ticker, window_start) groups. Use input ordered by ticker and timestamp, such as the native database iterators or default Massive/Polygon flat-file order. stddev is population standard deviation.

Build Database Files

Build fixed-length binary database files from one or more input .csv.gz files:

massive-speedup-build-database --database /data/massive-db 2026-01-23.csv.gz

The input type is inferred from the CSV header. Output layout is:

{database}/{stock_trade|stock_quote|currency_quote}/{YYYY-MM-DD}/{ticker}

Existing ticker files are not overwritten by default. The builder keeps reading the input until the next ticker and only writes missing ticker files. Use --force to rebuild existing ticker files, which is useful after a binary record format change:

massive-speedup-build-database --force --database /data/massive-db 2026-01-23.csv.gz

Date-level idempotency uses an .incomplete marker in {database}/{type}/{YYYY-MM-DD}. If the date directory exists without .incomplete, the input file is skipped. If the directory is new, .incomplete is created before processing and removed only after successful completion. Use --force to process a date even when .incomplete is absent.

Use --benchmark to print throughput:

massive-speedup-build-database --benchmark --database /data/massive-db *.csv.gz

Database Files

Open a fixed-length binary file through mmap and iterate records:

records = massive_speedup.StockTradeDatabase(
    "/data/massive-db",
    "2026-01-23",
    "A",
)

for trade in records:
    print(trade.sip_timestamp, trade.price)

Merge stock trades and quotes for one date and ticker in SIP timestamp order:

for trade, quote in massive_speedup.stock_trade_quote_timeline(
    "/data/massive-db",
    "2026-01-23",
    "A",
):
    if trade:
        print("trade", trade.sip_timestamp, trade.price, quote)
    else:
        print("quote", quote.sip_timestamp, quote.bid_price, quote.ask_price)

Quote rows yield (None, current_quote). Trade rows yield (trade, last_quote), where last_quote is None until the first quote has appeared. When a trade and quote have the same SIP timestamp, the quote is yielded first.

Database files support indexing and timestamp search:

first = records[0]
last = records[-1]

index = records.index_before_timestamp(1769161728012983416)
near_open = records.index_before_timestamp(1769161728012983416, galloping=0)
next_index = records.index_after_timestamp(1769161728012983416, galloping=index + 1)

Timestamp arguments are nanoseconds since epoch. Database readers also accept datetime.time values, which are resolved using the reader's date:

import datetime as dt

index = records.index_before_timestamp(dt.time(9, 30))

Find the closest record before or after a participant timestamp:

before = records.find_before_participant_timestamp(
    1769161728012624580,
)
after = records.find_after_participant_timestamp(
    1769161728012624580,
    fuzz=250_000_000,
    galloping=True,
)
strict_before = records.find_before_participant_timestamp(
    1769161728012624580,
    on=False,
)

find_before_participant_timestamp returns the record with the highest participant timestamp less than or equal to the target. find_after_participant_timestamp returns the record with the lowest participant timestamp greater than or equal to the target. Set on=False for strict < or > comparisons. fuzz is a nanosecond scan window around the searched timestamp and defaults to one second (1_000_000_000). Both methods return records, not indexes.

Stock database readers also expose NYSE market session timestamps in nanoseconds:

print(records.market_open)
print(records.market_close)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

massive_speedup-0.1.2.tar.gz (58.6 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

massive_speedup-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

massive_speedup-0.1.2-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (977.4 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

massive_speedup-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

massive_speedup-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (984.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

massive_speedup-0.1.2-cp313-cp313t-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ x86-64

massive_speedup-0.1.2-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (977.4 kB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

massive_speedup-0.1.2-cp313-cp313-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

massive_speedup-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (984.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

massive_speedup-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

massive_speedup-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (984.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

massive_speedup-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

massive_speedup-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

massive_speedup-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

massive_speedup-0.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

massive_speedup-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

massive_speedup-0.1.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file massive_speedup-0.1.2.tar.gz.

File metadata

  • Download URL: massive_speedup-0.1.2.tar.gz
  • Upload date:
  • Size: 58.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for massive_speedup-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4193d21d9bd4703a828d2b7e531552c180fd0571bb42d8a4f8dd1432a6112e2d
MD5 5866fd7aff40474f21456d24abce80aa
BLAKE2b-256 b77e29e5b330a85890e4d965e127666db859bd18e30d6e9ebc70c94b46ab16e7

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3b8460302a83afde15cbdd98f60a3e5953f1af7c7412b580a65c873d58453785
MD5 71135a96066c3cfaf0a11e24c7283911
BLAKE2b-256 c63d396485ab1d8457d39bb8c0f1f8690183b2d73b2e609a0adf21fe4decec78

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d4d168613ea350a872909aa2bc3fb4e36443386b91e1638280b999e50c40b04
MD5 e078593bd1804c48c0b5a0be242618e1
BLAKE2b-256 23e72884a1138855837304acfb3c006fae19e7ce84ac6ae38f395a55c37af55b

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e695007a38cbab0be5b529db318deb6f0d1946af6480ff6b34142111e120faac
MD5 2e015b69489e1561618688cd42b1c947
BLAKE2b-256 ce8e9f9b33e5e780a8b7e849171bdaee4b3046dae1fa947ec7de1e3fda540874

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5e3c6767acaf56215cc0d9e3210e93f3f9d91bec0ba6e46a87ac4da7830c7b71
MD5 1657effea3bb0b03ee1989fddf3fbfb5
BLAKE2b-256 046c2fd401ce6e0f2ce9622aa1411252e870e6226e5fc8777ed8c0cb0cf61890

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp313-cp313t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b4fb4efece9a50d38643c99ee1006165bc0a2613a515b74b34df55e296699de0
MD5 1612351e698e348986ada13afcc0b7b1
BLAKE2b-256 49eeca56ad698cf73580d68cb2f4057093292753312b2af68b1dfac2eb153490

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 119a00455daca6a4212155026d8ec079bf9ea242ce47757165c217970f832982
MD5 79982fb57e06d41cf3664d491aabd4bc
BLAKE2b-256 4f11c2744ab2eb37ace2c55dbe2f7f541574ec198ff48613d474061979bebf0c

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9f294413e47b58c09283f9e60acdfd207ddf5fcac5c4507ba90e436e9a786171
MD5 9d794c7ec3f2252c4092f3e1319e9156
BLAKE2b-256 f7e7f3b7f3ba572660beabe0ed29bff8c51b2b22a0999a3526f2978bbe93cec6

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc840f64d01bb2a1c3c759e30e916bb3b97e3d0176265991281def922f190543
MD5 02dab4a2f175c8eeb063a0a71bcf9324
BLAKE2b-256 b6628674fb25a39d56b327d976a4a8927818a05da42ec5317d95dfa421312c03

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 48a594d3891f907df891cf33efd89c1b5063ecfdd5af41aefc5e554a6839199c
MD5 200d1fd989d60e6c36412c7b264bf7bf
BLAKE2b-256 c64c239372c4bef4ded53ee401a7636ff1cb4cf227c2f9fc52df79b5af6bc1bc

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00718b6c020a2c1041af642373f12e51b82cc6adefa080dc54fa394ad5cd865a
MD5 a5cd107bf10ab54594e183f93c82bb48
BLAKE2b-256 6e84268554899c37497abcc8a016735725a4ba1f51a446125f48ca3979c5f2bf

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 410f3067be1bd3ab7db128187309a0c198fcdfc9d02e5da12bd3f98d74631137
MD5 9cb36703a21c6bcaaafea13dcf5acafc
BLAKE2b-256 3ed9b69b892c280bdc30589add6e1b1cdb1158b377f515664eb1d79a2e2e5722

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7b47c10e9df5daafdf682d1061eceeac3a0bb616e448d07ea8e7b751c0fd1d68
MD5 702d813c0567c4250036790403b2e164
BLAKE2b-256 2f0fd4abdc744c6ca0a4dc64784c83c071993a2b4ed7ebbdb6713c58e0952bf7

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 62e9eaf850aa8748ab827b3199bff5f3095d947e5d290c5367e03f48bdb9f2ef
MD5 268bf56df8ecbdd23b2d3c9cc90791aa
BLAKE2b-256 5050ed46251f3b404e63684f1d53acc628c04893b8024b64acc6ae8238ca1fac

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ebfab78ea338dfb3613af30d1140d5f3d867be06bd943e6a95b68f40d9c7eb53
MD5 5472da061013261bdc5e671162978bd8
BLAKE2b-256 7603208153f68ae00ded6dd9dca9bcba44c2c687fec7d22d300f0efbb0f4641c

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 91b8b4bab14b20e8c4228d7a785a6793ec56e722fc500d0e5a2ce37aef31cb57
MD5 14bdd831764b999394478e2e566a6a17
BLAKE2b-256 734639b4f160731fea897ee043b170706f07035dda1b52487c2cd9fe39ba2f65

See more details on using hashes here.

File details

Details for the file massive_speedup-0.1.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for massive_speedup-0.1.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 34a919a23dfb7eb64f35c459f880ec322f5a0c11c7320179fdfeaf83de8ab4f2
MD5 165f9c22d4defb19d8edde9dbf496287
BLAKE2b-256 519373e6b88a336f4bf98d22cd55bce4463e1f4888c6fdfd2258bb61e8e9245b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page