MCPcopy Create free account
hub / github.com/Open-Quant/openquant / register

Function register

crates/pyopenquant/src/bet_sizing.rs:281–314  ·  view source on GitHub ↗
(py: Python<'_>, parent: &Bound<'_, PyModule>)

Source from the content-addressed store, hash-verified

279/// float
280/// The power exponent `w` (at least 0).
281///
282/// Raises
283/// ------
284/// ValueError
285/// If `price_div` is outside `[-1, 1]`.
286#[pyfunction(name = "get_w_power")]
287fn bet_sizing_get_w_power(price_div: f64, m_bet_size: f64) -> PyResult<f64> {
288 openquant::bet_sizing::get_w_power(price_div, m_bet_size).map_err(to_py_err)
289}
290
291/// Target position for a forecast and market price, using the curve named by `func`.
292///
293/// AFML Snippet 10.4. Returns `trunc(m(f - m_p) * max_pos)`: the bet size of the divergence
294/// times the maximum position, truncated toward zero to whole units.
295///
296/// Parameters
297/// ----------
298/// w : float
299/// Curve parameter (sigmoid width or power exponent), e.g. from `get_w`.
300/// f : float
301/// Forecast price.
302/// m_p : float
303/// Current market price.
304/// max_pos : float
305/// Maximum absolute position.
306/// func : str
307/// `"sigmoid"` or `"power"`.
308///
309/// Returns
310/// -------
311/// float
312/// The target position, a whole number.
313///
314/// Raises
315/// ------
316/// ValueError
317/// If `func` is not `"sigmoid"` or `"power"`, or `func` is `"power"` and `f - m_p` is

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected