Skip to main content

sp2

PyPI License Build Status Python Versions


sp2 is a high performance reactive stream processing library. The main engine is a C++ complex event graph processor, with bindings exposed into Python. Its key features include switchable simulation/realtime timesteps for both offline and online processing, custom input and output adapters for integration with static and streaming data sources and sinks, and extensible acceleration via customizable C++ nodes for calculations.

The high level goal of sp2 is to make writing realtime code simple and performant. Write event driven code once, test it in simulation, then deploy as realtime without any code changes.

Here is a very simple example of a small sp2 program to calculate a bid-ask spread. In this example, we use a constant bid and ask, but in the real world you might pipe these directly into your live streaming data source, or into your historical data source, without modifications to your core logic.

import sp2
from sp2 import ts
from datetime import datetime


@sp2.node
def spread(bid: ts[float], ask: ts[float]) -> ts[float]:
    if sp2.valid(bid, ask):
        return ask - bid


@sp2.graph
def my_graph():
    bid = sp2.const(1.0)
    ask = sp2.const(2.0)
    s = spread(bid, ask)

    sp2.print('spread', s)
    sp2.print('bid', bid)
    sp2.print('ask', ask)


if __name__ == '__main__':
    sp2.run(my_graph, starttime=datetime.utcnow())

Running this, our output should look like (with some slight variations for current time):

2024-02-07 04:37:13.446548 bid:1.0
2024-02-07 04:37:13.446548 ask:2.0
2024-02-07 04:37:13.446548 spread:1.0

Getting Started

See our wiki!

Development

Check out the Developer Documentation

Authors

sp2 was originally developed as csp at Point72 by the High Frequency Algo team, with contributions from users across the firm.

License

This software is licensed under the Apache 2.0 license. See the LICENSE file for details.

Metadata

Release files for sp2 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sp2 0.0.3
File Size Uploaded
sp2-0.0.3.tar.gz 3.1 MB Details

Release files / sp2-0.0.3.tar.gz

Download URL sp2-0.0.3.tar.gz
Size 3.1 MB
Tags Source
SHA-256 checksum
How to use checksums
aeddd557b706de7d72c1952a0d6da0348b4d6f6001b8ef643dec915e8eac1d66
BLAKE2b-256 checksum
How to use checksums
3c8f6c140633df9709d9bfed13f0e00c7dadcb386a529410fcb5395ea5c0704e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.0.3 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page