From 706be103f07863e4b9b0e66048399eb5d64d5f03 Mon Sep 17 00:00:00 2001 From: KhizarImran Date: Sat, 20 Jun 2026 17:52:19 +0100 Subject: [PATCH] bug fixes: types.rs --- src/stats.rs | 7 +++++++ src/types.rs | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/stats.rs b/src/stats.rs index bd32ee4..45414cd 100644 --- a/src/stats.rs +++ b/src/stats.rs @@ -45,6 +45,13 @@ fn max_drawdown(equity_curve: &[f64]) -> f64 { max_dd } +#[pymethods] +impl Stats { + fn __repr__(&self) -> String { + format!("{}", self) + } +} + impl Stats { pub fn compute(broker: &Broker, equity_curve: &[f64]) -> Self { let num_trades = broker.trade_history.len(); diff --git a/src/types.rs b/src/types.rs index 16e02f7..db16d2d 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,6 +1,6 @@ use pyo3::prelude::*; -#[pyclass] +#[pyclass(from_py_object)] #[derive(Debug, Clone)] pub struct Bar { // Initialises the interface for the bar @@ -22,7 +22,14 @@ pub struct Bar { impl Bar { #[new] pub fn new(timestamp: i64, open: f64, high: f64, low: f64, close: f64, volume: f64) -> Self { - Bar { timestamp, open, high, low, close, volume } + Bar { + timestamp, + open, + high, + low, + close, + volume, + } } }