it might be better

This commit is contained in:
zastian-dev
2026-02-13 13:43:42 +00:00
parent 1ef03999b7
commit 798c3eafd5
3 changed files with 13 additions and 11 deletions

View File

@@ -33,9 +33,9 @@ impl Strategy {
portfolio_value: f64,
available_cash: f64,
signal: &TradeSignal,
) -> u64 {
) -> f64 {
if available_cash <= 0.0 {
return 0;
return 0.0;
}
let position_value = if signal.atr_pct > MIN_ATR_PCT {
@@ -51,7 +51,9 @@ impl Strategy {
};
let position_value = position_value.min(available_cash);
(position_value / price).floor() as u64
// Use fractional shares — Alpaca supports them for paper trading.
// Truncate to 4 decimal places to avoid floating point dust.
((position_value / price) * 10000.0).floor() / 10000.0
}
/// Check if stop-loss, trailing stop, or time exit should trigger.