Format related strategy and test files
This commit is contained in:
@@ -236,11 +236,7 @@ impl PlatformExprStrategy {
|
||||
engine.register_fn(
|
||||
"iff",
|
||||
|condition: bool, when_true: Dynamic, when_false: Dynamic| {
|
||||
if condition {
|
||||
when_true
|
||||
} else {
|
||||
when_false
|
||||
}
|
||||
if condition { when_true } else { when_false }
|
||||
},
|
||||
);
|
||||
engine.register_fn("contains", |value: &str, needle: &str| {
|
||||
@@ -404,11 +400,7 @@ impl PlatformExprStrategy {
|
||||
0
|
||||
} else {
|
||||
let next = quantity.saturating_sub(order_step_size.max(1));
|
||||
if next < minimum {
|
||||
0
|
||||
} else {
|
||||
next
|
||||
}
|
||||
if next < minimum { 0 } else { next }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -971,9 +963,7 @@ impl PlatformExprStrategy {
|
||||
minimum_order_quantity: instrument
|
||||
.map(|item| item.minimum_order_quantity())
|
||||
.unwrap_or(100) as i64,
|
||||
order_step_size: instrument
|
||||
.map(|item| item.order_step_size())
|
||||
.unwrap_or(100) as i64,
|
||||
order_step_size: instrument.map(|item| item.order_step_size()).unwrap_or(100) as i64,
|
||||
paused: market.paused || candidate.is_paused,
|
||||
is_st: candidate.is_st || self.special_name(ctx, symbol),
|
||||
is_kcb: candidate.is_kcb,
|
||||
|
||||
@@ -178,11 +178,7 @@ impl CnSmallCapRotationStrategy {
|
||||
let (sum, count) = window.fold((0.0, 0usize), |(sum, count), value| {
|
||||
(sum + value, count + 1)
|
||||
});
|
||||
if count == 0 {
|
||||
0.0
|
||||
} else {
|
||||
sum / count as f64
|
||||
}
|
||||
if count == 0 { 0.0 } else { sum / count as f64 }
|
||||
}
|
||||
|
||||
fn gross_exposure(&self, closes: &[f64]) -> f64 {
|
||||
@@ -332,7 +328,7 @@ impl Strategy for CnSmallCapRotationStrategy {
|
||||
order_intents: Vec::new(),
|
||||
notes: vec![format!("warmup: {}", message)],
|
||||
diagnostics: vec![
|
||||
"insufficient history; skip trading on warmup dates".to_string()
|
||||
"insufficient history; skip trading on warmup dates".to_string(),
|
||||
],
|
||||
});
|
||||
}
|
||||
@@ -628,11 +624,7 @@ impl JqMicroCapStrategy {
|
||||
0
|
||||
} else {
|
||||
let next = quantity.saturating_sub(order_step_size.max(1));
|
||||
if next < minimum {
|
||||
0
|
||||
} else {
|
||||
next
|
||||
}
|
||||
if next < minimum { 0 } else { next }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1538,7 +1530,7 @@ impl Strategy for JqMicroCapStrategy {
|
||||
order_intents: Vec::new(),
|
||||
notes: vec![format!("warmup: {}", message)],
|
||||
diagnostics: vec![
|
||||
"insufficient history; skip trading on warmup dates".to_string()
|
||||
"insufficient history; skip trading on warmup dates".to_string(),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user