Unify simulation order execution and persist paper accounting
This commit is contained in:
parent
7dec0be3b4
commit
63c3856797
37 changed files with 3901 additions and 3043 deletions
|
|
@ -13,6 +13,21 @@ pub struct BacktestEngine {
|
|||
|
||||
#[napi]
|
||||
impl BacktestEngine {
|
||||
#[napi]
|
||||
pub fn update_risk_limits(&self, input: napi::JsObject) -> Result<()> {
|
||||
let limits = super::parse_risk_limits(input)?;
|
||||
if !limits.valid() {
|
||||
return Err(Error::from_reason(
|
||||
"Risk limits must be positive finite numbers",
|
||||
));
|
||||
}
|
||||
let guard = self.inner.lock();
|
||||
let engine = guard
|
||||
.as_ref()
|
||||
.ok_or_else(|| Error::from_reason("Backtest engine unavailable"))?;
|
||||
engine.update_risk_limits(limits);
|
||||
Ok(())
|
||||
}
|
||||
#[napi(constructor)]
|
||||
pub fn new(config: napi::JsObject, env: Env) -> Result<Self> {
|
||||
let config = parse_backtest_config(config)?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue