Files
spark/src/lib_python_md/README.md
T

1.6 KiB

lib_python_md

This library binds c++ market data providers to python modules which can be loaded at runtime.

Dependencies

Example

import python_md_module as pymd


class MdProviderExample(pymd.MdProvider):
    def __init__(self):
        super(MdProviderExample, self).__init__()
        pass

    def start(self, sink: pymd.MdSink):
        print("Starting MdProviderExample")
        # An actual implementation would subscribe to market data here.
        # This is just an example to show you how to pass market data
        # back to the c++ Spark api.

        def add_dummy_security():
            # This example populates a dummy security for demonstrative purposes.
            # Of course, an actual implementation would populate the security list 
            # with data received from the exchange (or some other provider).
            sec_list = pymd.PySecurityList()
            sec = pymd.PySecurity()
            sec.set_venue("GLBX")
            sec.set_name("ESH5")
            sec.set_asset("ES")
            sec.set_expiration("2025-03-28")
            sec_list.append(sec)
            # Note: the example only adds 1 sec, but batch adds are supported.
            sink.on_securities(sec_list)

         add_dummy_security()

    def stop(self):
        print("Stopping MdProviderExample")

Devs

Python files in python_md_providers/ (child dir of this dir) are copied to
the plugins directory at build time, and should automatically be loaded at runtime.