Expose stock account accessors
This commit is contained in:
@@ -1342,6 +1342,7 @@ fn strategy_context_exposes_rqalpha_style_account_runtime_view() {
|
||||
|
||||
let account = ctx.account();
|
||||
|
||||
assert_eq!(account.account_type, "STOCK");
|
||||
assert!((account.starting_cash - 10_000.0).abs() < 1e-6);
|
||||
assert!((account.frozen_cash - 600.0).abs() < 1e-6);
|
||||
assert!((account.available_cash - 9_400.0).abs() < 1e-6);
|
||||
@@ -1350,6 +1351,13 @@ fn strategy_context_exposes_rqalpha_style_account_runtime_view() {
|
||||
assert!((account.daily_returns - portfolio.daily_returns()).abs() < 1e-6);
|
||||
assert!((account.total_returns - portfolio.total_returns()).abs() < 1e-6);
|
||||
assert!((ctx.available_cash() - account.available_cash).abs() < 1e-6);
|
||||
assert!(ctx.future_account().is_none());
|
||||
assert!(ctx.account_by_type("FUTURE").is_none());
|
||||
assert!((ctx.account_by_type("stock").unwrap().cash - account.cash).abs() < 1e-6);
|
||||
assert_eq!(
|
||||
ctx.accounts().keys().cloned().collect::<Vec<_>>(),
|
||||
vec!["STOCK".to_string()]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user