it might be better
This commit is contained in:
@@ -199,12 +199,12 @@ impl Backtester {
|
||||
let shares =
|
||||
self.strategy
|
||||
.calculate_position_size(price, portfolio_value, available_cash, signal);
|
||||
if shares == 0 {
|
||||
if shares <= 0.0 {
|
||||
return false;
|
||||
}
|
||||
|
||||
let fill_price = Self::apply_slippage(price, "buy");
|
||||
let cost = shares as f64 * fill_price;
|
||||
let cost = shares * fill_price;
|
||||
if cost > self.cash {
|
||||
return false;
|
||||
}
|
||||
@@ -214,7 +214,7 @@ impl Backtester {
|
||||
symbol.to_string(),
|
||||
BacktestPosition {
|
||||
symbol: symbol.to_string(),
|
||||
shares: shares as f64,
|
||||
shares: shares,
|
||||
entry_price: fill_price,
|
||||
entry_time: timestamp,
|
||||
entry_atr: signal.atr,
|
||||
@@ -229,7 +229,7 @@ impl Backtester {
|
||||
self.trades.push(Trade {
|
||||
symbol: symbol.to_string(),
|
||||
side: "BUY".to_string(),
|
||||
shares: shares as f64,
|
||||
shares: shares,
|
||||
price: fill_price,
|
||||
timestamp,
|
||||
pnl: 0.0,
|
||||
|
||||
Reference in New Issue
Block a user