mirror of
https://github.com/KhizarImran/backtestingfx.git
synced 2026-08-13 03:58:07 +00:00
bug fixes: types.rs
This commit is contained in:
@@ -45,6 +45,13 @@ fn max_drawdown(equity_curve: &[f64]) -> f64 {
|
|||||||
max_dd
|
max_dd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[pymethods]
|
||||||
|
impl Stats {
|
||||||
|
fn __repr__(&self) -> String {
|
||||||
|
format!("{}", self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Stats {
|
impl Stats {
|
||||||
pub fn compute(broker: &Broker, equity_curve: &[f64]) -> Self {
|
pub fn compute(broker: &Broker, equity_curve: &[f64]) -> Self {
|
||||||
let num_trades = broker.trade_history.len();
|
let num_trades = broker.trade_history.len();
|
||||||
|
|||||||
+9
-2
@@ -1,6 +1,6 @@
|
|||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
#[pyclass]
|
#[pyclass(from_py_object)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Bar {
|
pub struct Bar {
|
||||||
// Initialises the interface for the bar
|
// Initialises the interface for the bar
|
||||||
@@ -22,7 +22,14 @@ pub struct Bar {
|
|||||||
impl Bar {
|
impl Bar {
|
||||||
#[new]
|
#[new]
|
||||||
pub fn new(timestamp: i64, open: f64, high: f64, low: f64, close: f64, volume: f64) -> Self {
|
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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user