Account Class
Definition
The Account class can be used to subscribe to account-related events as well as access account-related information.
Also happens when rewinding/fast forwarding Playback connections.
Static Account Class Properties
| Property | Description |
|---|---|
| All | A collection of Account objects |
| AccountStatusUpdate | Event handler for account status updates |
| SimulationAccountReset | Event handler for resets on sim accounts |
Methods and Properties From Account instances
| Property | Description |
|---|---|
| AccountItem | Represents various account variables used to reflect values the status of the account |
| AccountItemUpdate | Event handler for changes to account values |
| Cancel() | Cancels specified order(s) on the account |
| CancelAllOrders() | Cancels all orders of an instrument on the account |
| Change() | Changes specified order(s) on the account |
| Connection | A Connection representing the connection this account is associated with |
| CreateOrder() | Creates orders for the account that need to be submitted via Submit() |
| Denomination | A Currency representing the denomination currency of this connection |
| Executions | A collection of executions on this account |
| ExecutionUpdate | Event handler for when new executions come in, an existing execution is amended, or an execution is removed |
| Flatten() | Flattens the account on specified instrument(s) |
| Get() | Returns the value of an AccountItem |
| Name | A string representing the name of this account |
| Orders | A collection of orders on this account |
| OrderUpdate | Event handler for changes to orders |
| Positions | A collection of positions on this account |
| PositionUpdate | Event handler for changes to positions |
| Strategies | A collection of strategies on this account |
| Submit() | Submits specified order(s) |
Example
1 private Account myAccount; 2 3 protected override void OnStateChange() 4 { 5 if (State == State.SetDefaults) 6 { 7 // Find our Sim101 account 8 lock (Account.All) 9 myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101"); 10 11 // Subscribe to static events. Remember to unsubscribe with -= when you are done 12 Account.AccountStatusUpdate += OnAccountStatusUpdate; 13 14 if (myAccount != null) 15 { 16 // Print some information about our account using the AccountItem indexer 17 Print(string.Format("Account Name: {0} Connection Name: {1} Cash Value {2}", 18 myAccount.Name, 19 myAccount.Connection.Options.Name, 20 myAccount.Get(AccountItem.CashValue, Currency.UsDollar))); 21 22 // Print the prices of the executions on our account 23 lock (myAccount.Executions) 24 foreach (Execution execution in myAccount.Executions) 25 Print("Price: " + execution.Price); 26 27 // Subscribe to events. Remember to unsubscribe with -= when you are done 28 myAccount.AccountItemUpdate += OnAccountItemUpdate; 29 myAccount.ExecutionUpdate += OnExecutionUpdate; 30 } 31 } 32 else if (State == State.Terminated) 33 { 34 // Unsubscribe to events 35 myAccount.AccountItemUpdate -= OnAccountItemUpdate; 36 myAccount.ExecutionUpdate -= OnExecutionUpdate; 37 Account.AccountStatusUpdate -= OnAccountStatusUpdate; 38 } 39 } 40 41 private void OnAccountStatusUpdate(object sender, AccountStatusEventArgs e) 42 { 43 // Do something with the account status update 44 } 45 46 private void OnAccountItemUpdate(object sender, AccountItemEventArgs e) 47 { 48 // Do something with the account item update 49 } 50 51 private void OnExecutionUpdate(object sender, ExecutionEventArgs e) 52 { 53 // Do something with the execution update 54 }

