Skip to content
forked from Point72/csp

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

License

Notifications You must be signed in to change notification settings

ProspectiveCo/csp

 
 

Repository files navigation


csp csp

PyPI License Build Status Python Versions


csp 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 csp 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 csp 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 in from your live streaming data source, or in from your historical data source, without modifications to your core logic.

import csp
from csp import ts
from datetime import datetime


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


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

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


if __name__ == '__main__':
    csp.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 contribution guide and local development instructions.

Authors

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

robambalu jacarr4 AdamGlustein stephenmarkacs

License

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 54.4%
  • Python 43.1%
  • CMake 2.3%
  • Other 0.2%