mirror of
https://github.com/KhizarImran/backtestingfx.git
synced 2026-08-19 06:58:05 +00:00
adding python wrapping
This commit is contained in:
@@ -3,5 +3,10 @@ name = "backtestingfx"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "backtestingfx"
|
||||||
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
pyo3 = { version = "0.28", features = ["extension-module"]}
|
||||||
+12
-4
@@ -1,6 +1,14 @@
|
|||||||
pub mod types;
|
|
||||||
pub mod strategy;
|
|
||||||
pub mod broker;
|
pub mod broker;
|
||||||
pub mod engine;
|
|
||||||
pub mod data;
|
pub mod data;
|
||||||
pub mod stats;
|
pub mod engine;
|
||||||
|
pub mod stats;
|
||||||
|
pub mod strategy;
|
||||||
|
pub mod types;
|
||||||
|
|
||||||
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
|
#[pymodule]
|
||||||
|
fn backtestingfx(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||||
|
m.add_class::<types::Bar>()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
+17
-6
@@ -1,32 +1,43 @@
|
|||||||
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
|
#[pyclass]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Bar { // Initialises the interface for the bar
|
pub struct Bar {
|
||||||
|
// Initialises the interface for the bar
|
||||||
|
#[pyo3(get)]
|
||||||
pub timestamp: i64,
|
pub timestamp: i64,
|
||||||
|
#[pyo3(get)]
|
||||||
pub open: f64,
|
pub open: f64,
|
||||||
|
#[pyo3(get)]
|
||||||
pub high: f64,
|
pub high: f64,
|
||||||
|
#[pyo3(get)]
|
||||||
pub low: f64,
|
pub low: f64,
|
||||||
|
#[pyo3(get)]
|
||||||
pub close: f64,
|
pub close: f64,
|
||||||
|
#[pyo3(get)]
|
||||||
pub volume: f64,
|
pub volume: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Position { // this is for the trading position
|
pub struct Position {
|
||||||
|
// this is for the trading position
|
||||||
pub id: u64,
|
pub id: u64,
|
||||||
pub entry_price: f64,
|
pub entry_price: f64,
|
||||||
pub lot_size: f64,
|
pub lot_size: f64,
|
||||||
pub is_long: bool,
|
pub is_long: bool,
|
||||||
pub entry_timestamp: i64,
|
pub entry_timestamp: i64,
|
||||||
pub stop_loss: Option<f64>,
|
pub stop_loss: Option<f64>,
|
||||||
pub take_profit: Option<f64>
|
pub take_profit: Option<f64>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Trade { // the actual trade
|
pub struct Trade {
|
||||||
|
// the actual trade
|
||||||
pub entry_price: f64,
|
pub entry_price: f64,
|
||||||
pub exit_price: f64,
|
pub exit_price: f64,
|
||||||
pub lot_size: f64,
|
pub lot_size: f64,
|
||||||
pub is_long: bool,
|
pub is_long: bool,
|
||||||
pub pnl: f64,
|
pub pnl: f64,
|
||||||
pub entry_timestamp: i64,
|
pub entry_timestamp: i64,
|
||||||
pub exit_timestamp:i64
|
pub exit_timestamp: i64,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user