mirror of
https://github.com/KhizarImran/backtestingfx.git
synced 2026-08-13 03:58:07 +00:00
build: fixed error relates to exit_price & exit_timestamp
This commit is contained in:
+5
-4
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
use crate::types::{Position, Trade};
|
use crate::types::{Position, Trade};
|
||||||
|
|
||||||
pub struct Broker{
|
pub struct Broker{
|
||||||
@@ -7,7 +8,7 @@ pub struct Broker{
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Broker {
|
impl Broker {
|
||||||
pub fn new(initial_cash: f64) -> self { // does not need &mut because it initialises something new
|
pub fn new(initial_cash: f64) -> Self { // does not need &mut because it initialises something new
|
||||||
Broker {
|
Broker {
|
||||||
cash: initial_cash,
|
cash: initial_cash,
|
||||||
positions: Vec::new(),
|
positions: Vec::new(),
|
||||||
@@ -20,7 +21,7 @@ impl Broker {
|
|||||||
entry_price: price,
|
entry_price: price,
|
||||||
lot_size,
|
lot_size,
|
||||||
is_long: true,
|
is_long: true,
|
||||||
entry_timestamp: timestamp
|
entry_timestamp: timestamp,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,12 +44,12 @@ impl Broker {
|
|||||||
self.cash += pnl;
|
self.cash += pnl;
|
||||||
self.trade_history.push(Trade {
|
self.trade_history.push(Trade {
|
||||||
entry_price: position.entry_price,
|
entry_price: position.entry_price,
|
||||||
exit_price: position.exit_price,
|
|
||||||
lot_size: position.lot_size,
|
lot_size: position.lot_size,
|
||||||
is_long: position.is_long,
|
is_long: position.is_long,
|
||||||
pnl,
|
pnl,
|
||||||
entry_timestamp: position.entry_timestamp,
|
entry_timestamp: position.entry_timestamp,
|
||||||
exit_timestamp: timestamp
|
exit_timestamp: timestamp,
|
||||||
|
exit_price: price
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user