Получить все заявки и сделки поставщика

using System.Linq; using System.Text; using TSLab.DataSource; using TSLab.Script; using TSLab.Script.Handlers; namespace MyLib { public class GetAllTrades : IExternalScript { public void Execute(IContext ctx, ISecurity sec) { // В блок 'Внешний скрипт' необходимо добавить TSLab.DataSourceHelper.dll var helper = sec?.SecurityDescription?.TradePlace?.DataSource as TradableHelper; if (helper != null) { var sb = new StringBuilder(); // Выводит последние 10 заявок поставщика sb.AppendLine("=== Orders ==="); foreach (var o in helper.Orders.OrderByDescending(x => x.Date).Take(10)) sb.AppendLine($"{o.Date} {o.Security.Id} {o.Status}, {(o.Info.IsBuy ? "B" : "S")} " + $"price={o.Info.OrderPrice}, qty={o.Quantity}"); sb.AppendLine(); sb.AppendLine("=== Trades ==="); // Выводит последние 10 сделок поставщика foreach (var t in helper.Trades.OrderByDescending(x => x.Date).Take(10)) sb.AppendLine($"{t.Date} {t.Security.Id} {(t.IsBuy ? "B" : "S")}, " + $"price={t.Price}, qty={t.Quantity}"); ctx.Log(sb.ToString(), MessageType.Info, true); } } } }