fahsjkn
This commit is contained in:
10
src/bot.rs
10
src/bot.rs
@@ -428,6 +428,10 @@ impl TradingBot {
|
||||
let current = &indicators[indicators.len() - 1];
|
||||
let previous = &indicators[indicators.len() - 2];
|
||||
|
||||
if current.rsi.is_nan() || current.macd.is_nan() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(generate_signal(symbol, current, previous))
|
||||
}
|
||||
|
||||
@@ -487,7 +491,7 @@ impl TradingBot {
|
||||
// Phase 2: Momentum ranking - only buy top N momentum stocks
|
||||
let mut ranked_signals: Vec<&TradeSignal> = signals
|
||||
.iter()
|
||||
.filter(|s| !s.momentum.is_nan() && s.momentum != 0.0)
|
||||
.filter(|s| !s.momentum.is_nan())
|
||||
.collect();
|
||||
ranked_signals.sort_by(|a, b| {
|
||||
b.momentum.partial_cmp(&a.momentum).unwrap_or(std::cmp::Ordering::Equal)
|
||||
@@ -505,8 +509,8 @@ impl TradingBot {
|
||||
top_momentum_symbols
|
||||
);
|
||||
|
||||
// Phase 3: Process buys (only for top momentum stocks)
|
||||
for signal in &signals {
|
||||
// Phase 3: Process buys in momentum-ranked order (highest momentum first)
|
||||
for signal in &ranked_signals {
|
||||
if !top_momentum_symbols.contains(&signal.symbol) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user