pub fn py_new_generic_spread_id(
instrument_ratios: Vec<(InstrumentId, i64)>,
) -> PyResult<InstrumentId>Expand description
Creates a generic spread instrument ID from (instrument_id, ratio) legs.
Sorts the legs by symbol and joins them with GENERIC_SPREAD_ID_SEPARATOR, formatting a
positive ratio as (ratio)symbol and a negative ratio as ((ratio))symbol. For example,
MSFT.NASDAQ with ratio 1 and AAPL.NASDAQ with ratio -2 produce
((2))AAPL___(1)MSFT.NASDAQ.
A leg symbol that contains the separator or ends with _ produces an ID that does not parse
back into the same legs.
ยงErrors
Returns an error if:
- Fewer than two legs are given.
- A ratio is zero or
i64::MIN. - The legs have different venues.