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
- Host: GitHub
- URL: https://github.com/Point72/csp
- Owner: Point72
- License: apache-2.0
- Created: 2024-01-22T18:40:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-07T22:02:04.000Z (about 2 months ago)
- Last Synced: 2025-05-07T22:29:38.804Z (about 2 months ago)
- Topics: cpp, python, reactive, reactive-programming, stream-processing, streaming
- Language: Python
- Homepage: https://github.com/Point72/csp/wiki
- Size: 4.76 MB
- Stars: 287
- Watchers: 14
- Forks: 49
- Open Issues: 72
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
[](https://pypi.python.org/pypi/csp)
[](https://github.com/Point72/csp/LICENSE)
[](https://github.com/Point72/csp/actions/workflows/build.yml)
[](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.
[
](https://github.com/robambalu)
[](https://github.com/jacarr4)
[](https://github.com/AdamGlustein)
[](https://github.com/stephenmarkacs)
## License
This software is licensed under the Apache 2.0 license. See the [LICENSE](LICENSE) file for details.