work on new engine
This commit is contained in:
parent
44476da13f
commit
a1e5a21847
126 changed files with 3425 additions and 6695 deletions
77
apps/stock/engine/src/api_new/system.rs
Normal file
77
apps/stock/engine/src/api_new/system.rs
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
use napi_derive::napi;
|
||||
use napi::bindgen_prelude::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[napi]
|
||||
pub struct SystemAPI {
|
||||
core: Arc<crate::TradingCore>,
|
||||
}
|
||||
|
||||
impl SystemAPI {
|
||||
pub fn new(core: Arc<crate::TradingCore>) -> Self {
|
||||
Self { core }
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
impl SystemAPI {
|
||||
#[napi]
|
||||
pub async fn start(&self) -> Result<()> {
|
||||
// Start the trading system
|
||||
match self.core.get_mode() {
|
||||
crate::TradingMode::Backtest { .. } => {
|
||||
// Start backtest processing
|
||||
todo!("Start backtest")
|
||||
}
|
||||
crate::TradingMode::Paper { .. } => {
|
||||
// Start paper trading
|
||||
todo!("Start paper trading")
|
||||
}
|
||||
crate::TradingMode::Live { .. } => {
|
||||
// Start live trading
|
||||
todo!("Start live trading")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub async fn stop(&self) -> Result<()> {
|
||||
// Stop the trading system
|
||||
todo!("Stop trading system")
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn get_mode(&self) -> String {
|
||||
match self.core.get_mode() {
|
||||
crate::TradingMode::Backtest { .. } => "backtest".to_string(),
|
||||
crate::TradingMode::Paper { .. } => "paper".to_string(),
|
||||
crate::TradingMode::Live { .. } => "live".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn get_current_time(&self) -> String {
|
||||
self.core.get_time().to_rfc3339()
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn set_risk_limits(&self, limits: String) -> Result<()> {
|
||||
// Parse and set risk limits
|
||||
let limits: serde_json::Value = serde_json::from_str(&limits)
|
||||
.map_err(|e| Error::from_reason(format!("Invalid limits: {}", e)))?;
|
||||
|
||||
todo!("Set risk limits")
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn get_risk_metrics(&self) -> Result<JsObject> {
|
||||
// Get current risk metrics
|
||||
todo!("Get risk metrics")
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn get_analytics(&self) -> Result<JsObject> {
|
||||
// Get trading analytics
|
||||
todo!("Get analytics")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue