feat: Add support for python md plugins

This commit is contained in:
John Colvin committed 2024-09-18 14:02:39 +00:00
1 parent 2b62668df8
commit 2e9b4c78f3
46 files changed
+2265 -11

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
<!-- Links -->
[pybind11]: https://github.com/pybind/pybind11
[lib_spark]: ../lib_spark/README.md
# lib_python_md
This library binds c++ market data providers to python modules
which can be loaded at runtime.
## **Dependencies**
* **[Pybind11][pybind11]**
* **[lib_spark][lib_spark]**
## Example
```python
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<br/>
the plugins directory at build time, and should automatically be loaded at runtime.