pub struct NeuralTrader { /* private fields */ }Expand description
Main Neural Trader system instance
This is the primary interface for interacting with the trading system from Node.js. It manages strategies, execution, and portfolio state.
§Example
const { NeuralTrader } = require('@neural-trader/rust-core');
const trader = new NeuralTrader({
apiKey: process.env.ALPACA_API_KEY,
apiSecret: process.env.ALPACA_API_SECRET,
paperTrading: true
});
await trader.start();
const positions = await trader.getPositions();
await trader.stop();Implementations§
Source§impl NeuralTrader
impl NeuralTrader
Source§impl NeuralTrader
impl NeuralTrader
pub fn into_reference( val: NeuralTrader, env: Env, ) -> Result<Reference<NeuralTrader>>
pub fn into_instance(self, env: Env) -> Result<ClassInstance<NeuralTrader>>
Source§impl NeuralTrader
impl NeuralTrader
Sourcepub fn new(config: JsConfig) -> Self
pub fn new(config: JsConfig) -> Self
Create a new Neural Trader instance
§Arguments
config- Configuration object with API credentials and settings
Sourcepub async fn start(&self) -> Result<()>
pub async fn start(&self) -> Result<()>
Start the trading system
Initializes connections to market data providers and brokers. Returns a Promise that resolves when the system is ready.
Sourcepub async fn stop(&self) -> Result<()>
pub async fn stop(&self) -> Result<()>
Stop the trading system gracefully
Closes all positions, cancels open orders, and disconnects from services.
Sourcepub async fn get_positions(&self) -> Result<Vec<JsPosition>>
pub async fn get_positions(&self) -> Result<Vec<JsPosition>>
Get current portfolio positions
Returns all open positions with real-time P&L.
Sourcepub async fn place_order(&self, _order: JsOrder) -> Result<String>
pub async fn place_order(&self, _order: JsOrder) -> Result<String>
Sourcepub async fn get_balance(&self) -> Result<String>
pub async fn get_balance(&self) -> Result<String>
Get current account balance
Returns cash balance in account currency
Sourcepub async fn get_equity(&self) -> Result<String>
pub async fn get_equity(&self) -> Result<String>
Get current portfolio equity (cash + positions)
Trait Implementations§
Source§impl FromNapiMutRef for NeuralTrader
impl FromNapiMutRef for NeuralTrader
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Safety Read more
Source§impl FromNapiRef for NeuralTrader
impl FromNapiRef for NeuralTrader
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Safety Read more
Source§impl FromNapiValue for &NeuralTrader
impl FromNapiValue for &NeuralTrader
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl FromNapiValue for &mut NeuralTrader
impl FromNapiValue for &mut NeuralTrader
Source§unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
unsafe fn from_napi_value(env: napi_env, napi_val: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self, Error>
Source§impl ToNapiValue for NeuralTrader
impl ToNapiValue for NeuralTrader
Source§unsafe fn to_napi_value(env: napi_env, val: NeuralTrader) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: NeuralTrader) -> Result<napi_value>
Safety Read more
Source§impl TypeName for &NeuralTrader
impl TypeName for &NeuralTrader
Source§impl TypeName for &mut NeuralTrader
impl TypeName for &mut NeuralTrader
Source§impl TypeName for NeuralTrader
impl TypeName for NeuralTrader
Source§impl ValidateNapiValue for &NeuralTrader
impl ValidateNapiValue for &NeuralTrader
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Source§impl ValidateNapiValue for &mut NeuralTrader
impl ValidateNapiValue for &mut NeuralTrader
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Safety Read more
Auto Trait Implementations§
impl Freeze for NeuralTrader
impl RefUnwindSafe for NeuralTrader
impl Send for NeuralTrader
impl Sync for NeuralTrader
impl Unpin for NeuralTrader
impl UnwindSafe for NeuralTrader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more