nkaz001 / hftbacktest

A high-frequency trading and market-making backtesting and trading bot in Python and Rust, which accounts for limit orders, queue positions, and latencies, utilizing full tick data for trades and order books, with real-world crypto market-making examples for Binance Futures
MIT License
2.01k stars 395 forks source link

Add a config.toml to make builds work on M1 by fixing linker errors on MacOS #104

Closed roykim98 closed 3 months ago

roykim98 commented 3 months ago

Without this change, builds will otherwise fail on Apple M1 CPUs when trying to build the Python extensions.

https://github.com/inferiorhumanorgans/r2-c166/blob/752b61d36acd1ddbbcd0844505f94093773e4cc5/README.md#building-on-osx

...
            "__Py_NoneStruct", referenced from:
                pyo3_ffi::object::Py_None::hda8ba4bd0026440a in libpyo3-4148043010e22fb2.rlib[8](pyo3-4148043010e22fb2.pyo3.d6121509127cc09a-cgu.05.rcgu.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: could not compile `py-hftbacktest` (lib) due to 1 previous error

cargo build succeeds with this change.

nkaz001 commented 3 months ago

Can that be set in Cargo.toml instead of .cargo/config.toml?

roykim98 commented 3 months ago

@nkaz001 I don't believe so, but I'm no expert on Rust / Cargo. I had tried that initially, but got the following error:

Error: failed to parse manifest at `.../hftbacktest/Cargo.toml`

Caused by:
  this virtual manifest specifies a `target` section, which is not allowed

My understanding is that, based on documentation:

Cargo.toml is a manifest file in which we can specify a bunch of different metadata about our package.

And configuration exists outside of the manifest--which configures Cargo, not necessarily our package.

nkaz001 commented 3 months ago

I see. Thank you.