Skip to main content

sp2 is a high performance reactive stream processing library, written in C++ and Python

Project description

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.

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

sp2-0.0.3.tar.gz (3.1 MB view details)

Uploaded Source

File details

Details for the file sp2-0.0.3.tar.gz.

File metadata

  • Download URL: sp2-0.0.3.tar.gz
  • Upload date:
  • Size: 3.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for sp2-0.0.3.tar.gz
Algorithm Hash digest
SHA256 aeddd557b706de7d72c1952a0d6da0348b4d6f6001b8ef643dec915e8eac1d66
MD5 8ae8afa661acbfc8f8593486ddf3b17f
BLAKE2b-256 3c8f6c140633df9709d9bfed13f0e00c7dadcb386a529410fcb5395ea5c0704e

See more details on using hashes here.

Supported by

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