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}

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)

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=True)

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.0.tar.gz (88.8 kB 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.0-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.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (976.9 kB view details)

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

massive_speedup-0.1.0-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.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (984.5 kB view details)

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

massive_speedup-0.1.0-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.0-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (976.7 kB view details)

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

massive_speedup-0.1.0-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.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (984.3 kB view details)

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

massive_speedup-0.1.0-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.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (984.4 kB view details)

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

massive_speedup-0.1.0-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.0-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.0-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.0-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.0-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.0-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.0.tar.gz.

File metadata

  • Download URL: massive_speedup-0.1.0.tar.gz
  • Upload date:
  • Size: 88.8 kB
  • 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.0.tar.gz
Algorithm Hash digest
SHA256 001fc1b158818adb8b228ac28a06aca752841ed7ac3903e086c9d48b2dc1d4f9
MD5 e68b5d23a49310b13b6ff793e6aa669d
BLAKE2b-256 831fd67018e59570cb37049df31b12687d1521f5282216145e6f1ea8fabc736b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e7fde47fb2757c50c6ada27b7a90d1f875f1dde1aa7af8b48add204c72935b83
MD5 ef0c9865619195338b40443e3b2cc376
BLAKE2b-256 377f2d4ec0ff17161fd08176a38ab2a714d04e2517ab816f8748d94cca1572b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e6f33240736ef049c12a0bc7176fdf6ff93b28e7dcfed28b7f198b797692e3ae
MD5 b80b30bf53ed8ecdb420fd555eb283aa
BLAKE2b-256 56c9fa34b707993316e5885e52c28b03b3bc1b9092ef212d403dd0f98cadbd2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 21e2d05b58d5d342a9b36c43c2a11d4e7e207c1895cf86c8275d5851f6fcbbd9
MD5 532de94501fdd2f2c8065a7e1d0dac98
BLAKE2b-256 3b384c9a8e523884865d9055385737ba92b2fc11ad16aac414f64dbc22991d97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0506889e5ff0fc3ebc78284deb1cb344636bd88f6729161e9ec9d2d2793a3c53
MD5 27fea28c9c457305227ecd1378e166e2
BLAKE2b-256 e12d0bf79a5eac19e558115f2eb07fa14a985600b6a5b34ec5955e0732fb870e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 78d1767859183a23ad0803305c30b8babd49bb175ef500ba2e7f9c751b3f781c
MD5 a0d4c3db80f89c63639bd4e9c701474b
BLAKE2b-256 75cc5d809e385f68882032706521410bca2cb83b0fe59963cda3454eee9a35da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c2d98be9c27d44f9dcc8e1b056c9cf4b41af5a16bc8a3db3166d5c795601a77a
MD5 7bceb6991893439e4251d052a7219a0c
BLAKE2b-256 0de93fcf27af866e1cf57d5f0e066256e36714a816ee20b5fe13f0f13b75097a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 433f36d8a57c9c65758f39a389ec003293625839be75c9a4199551648d912a79
MD5 a820e6e29ddb971d12470adff1ec8b36
BLAKE2b-256 bb575c0bb50c87c3b69a428ce0d9de70e48e0dbedee528c7714ba047d696292f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fcbe662ec886664582c1c77362fe56c7acf066f4c676d60e9752af413f3464dd
MD5 12830f89fe7fcce66096f124293568a1
BLAKE2b-256 af4586082d0f0a31d1d2ac4012bf307c2947a9161e95fe49491d044165078853

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 73a5cd823d7904e867d58753d6acc257a1bb37b5c9d79fcfb998ac47beed1a35
MD5 8ec0b2e956cef56e16a0b9d15465a0e3
BLAKE2b-256 ce011dc30b68b0a7bfd84ae59f164014c6f1ece6460751c74aa6c31b189a1f67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 82d2fb1e4c24e4b1d96f2d074af971b7af47214fba36295f0e38d0938d39c92d
MD5 a2c256e69d96d3fc4ac47f9cc3222609
BLAKE2b-256 cd3e66e712c3da96b9150b6da7fcc06dae779855f8b493620c2350194713559d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c6801dc49de0ffe2ec2a28ffd2b76202489745dbf895bfa4ff8c2032125dca99
MD5 f01b76c4f13af73f78a112d50de15431
BLAKE2b-256 37eb6dd50597e024dcf8ca3d242583a2646640feb8eaf9e071cc649add0872f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d0b83fa4be1ef4dd481b3b7a60bf61d8a51f9e7bbb11ed134c7cfef8fa5006ef
MD5 a24dac9b25acf120599885d26c79244c
BLAKE2b-256 60b92748291fab37bbe7bd2bb8c5c354d799cca6b40e0b391c9a93b790447df7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fc7877d8f610f59cb6530beb23890aebe3a9bbb7f0d2878e15de8a1fd284bcb3
MD5 bb0f99a7839f397974a265b3c1d43788
BLAKE2b-256 34aac38bf6594a3fa9581486f7f4b660f7a049e2dd85f3a148d861d5afa8cd1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 92bf8476b6c80e72e29efaaa49c07ba07018ba177ca1746337f1d1f203659bfc
MD5 20880907619858e1102d1eca7fdd5b75
BLAKE2b-256 a9e0e6b2f920759d843c5d46bfefab87cac8a524a9d08975421de8711abae28c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6975009128733031e594d68ac2d2222e6c9ca43665ab6ca6098e41910bab4dbc
MD5 02eddd7ba5e634a65fb234aaead0961c
BLAKE2b-256 3fd1b07cf2b4807aa38fae07a9ecba2cea5332fcf50bcd417050cf6f9ac6a9ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 87ea18c992ce637fc08ba493f981c8df72ae6b529c063f486586a4cdbd899c00
MD5 21f388eb7346e513b552c4bf14c92402
BLAKE2b-256 001ff682b9f04fb38ab53f0dedf79c11b2936681f5028bada754b854b8cc4020

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