A Python module written in Rust that implements some loop-heavy routines needed in online portfolio optimization.
These are the latest instructions at the moment of writing.
These might change as pyo3
changes, if you run into issues check the pyo3 docs.
Build using cargo build --release
and copy /target/release/online_python.so
to a place where Python can find it.
Build using cargo build --release
and copy /target/release/online_python.dll
to a place where Python can find it.
Also, rename the file to online_python.pyd
.
On Mac Os, you need to set additional linker arguments. One option is to compile with cargo rustc --release -- -C link-arg=-undefined -C link-arg=dynamic_lookup , the other is to create a .cargo/config with the following content:
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
Now copy /target/release/online_python.dylib
to a place where Python can find it.
Also, rename the file to online_python.so
.
Simply import using import online_python
.
Errors are not handled nicely, so if you supply erroneous arguments your Python instance will die.
The Python console will tell you what you did wrong, or where this code contains a bug.