An open API service indexing awesome lists of open source software.

https://github.com/Point72/csp

csp is a high performance reactive stream processing library, written in C++ and Python
https://github.com/Point72/csp

cpp python reactive reactive-programming stream-processing streaming

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        




csp


csp


[![PyPI](https://img.shields.io/pypi/v/csp.svg?style=flat)](https://pypi.python.org/pypi/csp)
[![License](https://img.shields.io/badge/license-Apache--2.0-green)](https://github.com/Point72/csp/LICENSE)
[![Build Status](https://github.com/Point72/csp/actions/workflows/build.yml/badge.svg)](https://github.com/Point72/csp/actions/workflows/build.yml)
[![Python Versions](https://img.shields.io/badge/python-3.8_%7C_3.9_%7C_3.10_%7C_3.11_%7C_3.12-blue)](https://github.com/Point72/csp/blob/main/pyproject.toml)


`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](https://en.wikipedia.org/wiki/Bid%E2%80%93ask_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.

```python
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):

```raw
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!](https://github.com/Point72/csp/wiki)

## Development

Check out the [contribution guide](https://github.com/Point72/csp/wiki/Contribute) and [local development instructions](https://github.com/Point72/csp/wiki/Local-Development-Setup).

## Authors

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

[robambalu](https://github.com/robambalu)
[jacarr4](https://github.com/jacarr4)
[AdamGlustein](https://github.com/AdamGlustein)
[stephenmarkacs](https://github.com/stephenmarkacs)

## License

This software is licensed under the Apache 2.0 license. See the [LICENSE](LICENSE) file for details.