Code Monkey home page Code Monkey logo

csp's Introduction


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 into your live streaming data source, or into 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.

csp's People

Contributors

timkpaine avatar ngoldbaum avatar robambalu avatar pavithraes avatar adamglustein avatar arhamchopra avatar melissawm avatar wrieg123 avatar ptomecek avatar ogarokpeter avatar argaj avatar isuruf avatar svatasoiu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.