Получить данные всех агентов
Метод runtime.GetAllAgentRuntimeInfo() возвращает данные по всем агентам.
Те же данные что в таблице Агенты.
using System.Linq; using System.Text; using TSLab.Script; using TSLab.Script.Handlers; namespace MyLib { public class TestAgentsInfo : IExternalScript { public void Execute(IContext ctx, ISecurity sec) { // В переменной agents будут данные по агентам. var agents = ctx.Runtime.GetAllAgentRuntimeInfo().ToList(); var sb = new StringBuilder(); foreach (var agent in agents) { sb.AppendLine($"Агент: {agent.AgentName}"); sb.AppendLine($"Скрипт: {agent.ScriptName}"); sb.AppendLine($"Работает: {agent.IsStarted}"); foreach (var sourceItem in agent.SourceItems) { sb.AppendLine($" Поставщик: {sourceItem.ProviderName}"); sb.AppendLine($" Счет: {sourceItem.AccountName}"); sb.AppendLine($" Валюта счета: {sourceItem.CurrencyName}"); sb.AppendLine($" Инструмент: {sourceItem.SecurityName}"); sb.AppendLine($" Позиция (лоты): {sourceItem.PositionInLots}"); sb.AppendLine($" Позиция (деньги): {sourceItem.PositionInMoney}"); sb.AppendLine($" Длинные поз. (лоты): {sourceItem.PositionLong}"); sb.AppendLine($" Короткие поз. (лоты): {sourceItem.PositionShort}"); sb.AppendLine($" Учетная цена: {sourceItem.BalancePrice}"); sb.AppendLine($" П/У: {sourceItem.Profit}"); sb.AppendLine($" П/У (дн): {sourceItem.DailyProfit}"); sb.AppendLine($" НП/У: {sourceItem.ProfitVol}"); sb.AppendLine($" Комиссия: {sourceItem.Commission}"); sb.AppendLine($" Текущая цена: {sourceItem.LastPrice}"); sb.AppendLine($" Оценочная цена: {sourceItem.AssessedPrice}"); sb.AppendLine(); } } ctx.Log(sb.ToString(), toMessageWindow: true); } } }