using System.Linq;
using TSLab.DataSource;
using TSLab.Script;
using TSLab.Script.Handlers;
namespace MyLib
{
public class GetBalanceCurrency : IExternalScript
{
public void Execute(IContext ctx, ISecurity sec)
{
var ds = sec?.SecurityDescription?.TradePlace?.DataSource;
if (ds != null)
{
// указать номер счета
var balances = (ds as IPortfolioSourceBase)?.GetBalances("7500B05");
// указать тикер
var balance = balances?.FirstOrDefault(x => x.SecurityName == "SiH1");
if (balance != null)
{
ctx.Log($"Текущая: {balance.RealRest}", MessageType.Info, true);
ctx.Log($"НП/У: {balance.ProfitVolume}", MessageType.Info, true);
}
}
}
}
}