- ago
I am using TOS and I have it connected to WL and working great! I wanted to try to use this connection to automatically 1x an hour to log all the account balances. Is this possible? I see that there is a BrokerAccount class and properties AccountValue and Cash. Would it be possible to enumerate the connected accounts and just write these 2 values 1x an hour to a text or csv file for each one? TIA!
0
182
Solved
2 Replies

Reply

Bookmark

Sort
- ago
#1
Here's the basic loop. Of course, replace the WriteToDebugLog calls and adjust statements for writing to CSV file with the specific data you need. This code is assumed to be in the Execute(BarHistory bars, int idx) method.

CODE:
var td = bars.DateTimes[idx].TimeOfDay; if (td.Hours == 9 && td.Minutes == 30 || td.Hours >= 10 && td.Hours <= 16 && td.Minutes == 0) { foreach (var broker in SignalManager.Brokers) { WriteToDebugLog($"Broker: {broker.Name}"); foreach (var account in broker.Accounts) { WriteToDebugLog($"\tAccount: {account.AccountID}, Balance: {account.AccountValue}"); foreach (var position in account.Positions) { WriteToDebugLog($"\t\tPosition: {position.Symbol} Quantity: {position.Quantity}, Value: {position.Value}"); } } } }
0
Best Answer
- ago
#2
That is perfect! Thank you very much!
0

Reply

Bookmark

Sort