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.1.tar.gz (19.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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (984.4 kB view details)

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

massive_speedup-0.1.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: massive_speedup-0.1.1.tar.gz
  • Upload date:
  • Size: 19.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.1.tar.gz
Algorithm Hash digest
SHA256 c9160f051fa135e609107e28964ebe152d91aa3aeaed58c9982a76770fffab8b
MD5 d01a774adf280819c2e28822f3c45fb4
BLAKE2b-256 6b81ec2573550201c2214b663006f18a2d51976f94d444015d216b68f8fa8ed5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 36d785862dd4809d89909ae32f608226225efe8f6928f9c6cb8e6083c94db6c1
MD5 5ad684318b08bedb892b74818785f3e2
BLAKE2b-256 8e8a8bcc5d968f8e9adc85b6361257c3a98aa2fb2acfd070c0c2249728f55b5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e252dd64ac40388549389be6454c566223effbf20b21f453ab6949c7ea1debe
MD5 253bfcce9fdc9f71e2a6678835391d94
BLAKE2b-256 b5701bfd23c82e5d7de86a1414c996022033e6d9dd09e25c323af0dc52baa326

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 85629f4b630ce27a15552e0cd1e06fd4485b09597e593f11b281ed09fdf78a67
MD5 d8b71191c30a265b5a554d2022931721
BLAKE2b-256 9b5bb95ec88624b7356f8b56e243179bf51eb8768b59a6f13d76ec1fa6ff08f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e425dcaa1371025e7f0d95637b1fdcac8ae5b5add7f1697674777af70e98d9ff
MD5 c68b2c0305a0b4ad0d30830a8d7759b0
BLAKE2b-256 f8c918773110ec91e7a4bc57809f4363dcc27959e3863248f6aadfd704c216af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 18a02883ba58e6e573079435c014412f29bcdd6f3301b7460a2e1fcba2801665
MD5 af6789972ebd1603732e22944d385df4
BLAKE2b-256 761b58d08d1ec3d0e7a7c19cb382cdad5e0196d89e77e61c5e2d4c5d57d58499

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee463e5c6232cf89a4e9f749b8eb23486c3d5eb01e44b4ecef9f88caf5d8ede1
MD5 bb692be2b8370ad59d5890e2dcf675c6
BLAKE2b-256 8c1a5a8089af6b0f0e83359165055e9f7aa446f1678d6ee65a4aa7a6af4b87ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6d845360f9fa3aa49a5b4fbb5ef881b10daa9a2599e2919e63773a965f7ee1e6
MD5 6f0273f33c97a6f6976e2c16ab01d19b
BLAKE2b-256 679950b21664fa03af74d4518125065d5e0b026c72d9a1a84ea0c9d4a9e9fe71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2fecfa60841f83908cb78413a8c2109f9ed6d5676c4b31db4e5e8c0382ff0e91
MD5 a38a29913272886a3668f9fc30758e91
BLAKE2b-256 c4a20925e71a032b30b83239bfbefd4d7ba7267a65c38c5097e37ed4ad939796

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 acfced187e5a38879eadd44c1e4c7426447d0d68b2833ec2bc31599ceb7cb528
MD5 077d4b697e6611a198c769cf0facf520
BLAKE2b-256 602d227e1c8b0bea26e335a97eb35f7cbdb01e438bb697b6622500860b31aa37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 294adc19e672eec8f3de55099d8ae7de2240e32d307f37110762239011441a83
MD5 d91ba7d11146c82b93f8fd062c20c550
BLAKE2b-256 d6d14cd236d8a53aa3dac602b75d9dc92d7b5102aa65b919a79b0dd8490355ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c6a2ae01cbd130e466575de35bbf58b5dbab7267e3491346163a42bd95833ed2
MD5 ceaa47a05f87cae16bddefcc7d68d6c4
BLAKE2b-256 2cdf59172b80ff0a3d4b2509dcccf57c365dfd136a09d4ebad58a2117cbe9638

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 673d82679ebd4ecd25e1a9ce363723de2a78673cf1f839d3a9f207d5b721f450
MD5 568845f210ca2183b27b43ffeb794c1e
BLAKE2b-256 a23d50306f5e15a416de8f545c915b5d169fb9a2a4e65318ae6eab6bcdfe3463

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fde80d8f0baf8693c274c66c1324b6a62faed8e31a17ebd889e21349f8ec4b43
MD5 a50846b9836a84e083863e85cb914f5f
BLAKE2b-256 935013173a4d72de9789afc523620c6aab82b872bf5c03611d4658c74c23a0ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a1a0809a2c0ae3f517f227e264fca371c4c5babec58ffd772d9b3337e6843682
MD5 aea8556b64c51aa2bf9ae7237df34680
BLAKE2b-256 856de7deeb856f0601dc2fa1020749a74122a2a1bc7ed4bab108db57bf3fd909

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9cf1e1aa0a100fb0550786912b59c1de63b8da058e6b4b708d70ee901bf1f9b5
MD5 dddc4bd2043a3dc3bc3b45f9fdeb7616
BLAKE2b-256 280c1652f3836d3aa70e66123ed10719bb57315d9a1443f6aa2517c3db4d89e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for massive_speedup-0.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d857fc3dea26f20e360c82b5e96a5ad842b67cd611d6979c1db1e5ed0affe64
MD5 aeba16c69b7037696d796b2139bd15f3
BLAKE2b-256 54e5a480cc3c8149288a676a407e4e9e0851360accbe840c96ebeb7bcef290f2

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