using System; using System.Collections.Generic; using System.Linq; using System.Text; using TSLab.Script; using TSLab.Script.Handlers; using TSLab.Script.Optimization; using TSLab.Script.Helpers; using TSLab.Script.Realtime; namespace GAWPortfolio { //Значение по умолчанию Гарантийного обеспечения на покупку фьючерса в рублях. [HandlerCategory("GAW")] [HandlerName("ГО на покупку с значением по умолчанию")] [InputInfo(0, "Данные")] public class GAWBuyDeposit : IOneSourceHandler, ISecurityInputs, IDoubleReturns, IStreamHandler, IContextUses { public IContext Context { set; private get; } //Значение по умолчанию [HandlerParameter(IsShown = true, NotOptimized = true, Default = "23000", Name = "ГО по умолчанию")] public double ParBuyGO { get; set; } public IList Execute(ISecurity sec) { var value = sec.FinInfo.BuyDeposit ?? ParBuyGO; var res = new double[Context.BarsCount]; for (int i = 0; i < res.Count(); i++) { res[i] = value; } return res; } } //Значение по умолчанию Гарантийного обеспечения на продажу фьючерса в рублях. [HandlerCategory("GAW")] [HandlerName("ГО на продажу с значением по умолчанию")] [InputInfo(0, "Данные")] public class GAWSellDeposit : IOneSourceHandler, ISecurityInputs, IDoubleReturns, IStreamHandler, IContextUses { public IContext Context { set; private get; } //Значение по умолчанию [HandlerParameter(IsShown = true, NotOptimized = true, Default = "24000", Name = "ГО по умолчанию")] public double ParSellGO { get; set; } public IList Execute(ISecurity sec) { var value = sec.FinInfo.SellDeposit ?? ParSellGO; var res = new double[Context.BarsCount]; for (int i = 0; i < res.Count(); i++) { res[i] = value; } return res; } } //Шаг изменения цены в пунктах. [HandlerCategory("GAW")] [HandlerName("Шаг изменения цены в пунктах со значением по умолчанию")] [InputInfo(0, "Данные")] public class GAWStepSize : IOneSourceHandler, ISecurityInputs, IDoubleReturns, IStreamHandler, IContextUses { public IContext Context { set; private get; } //Значение по умолчанию [HandlerParameter(IsShown = true, NotOptimized = true, Default = "10", Name = "ГО по умолчанию")] public double ParStepSize { get; set; } public IList Execute(ISecurity sec) { var secRt = sec as ISecurityRt; //Данные в реалтайм var value = (secRt != null) ? sec.Tick : ParStepSize; var res = new double[Context.BarsCount]; for (int i = 0; i < res.Count(); i++) { res[i] = value; } return res; } } //Стоимость одного шага цены в рублях через [HandlerCategory("GAW")] [HandlerName("Стоимость одного шага цены в рублях со значением по умолчанию")] [InputInfo(0, "Данные")] public class GAWStepPrice : IOneSourceHandler, ISecurityInputs, IDoubleReturns, IStreamHandler, IContextUses { public IContext Context { set; private get; } //Значение по умолчанию [HandlerParameter(IsShown = true, NotOptimized = true, Default = "13", Name = "ГО по умолчанию")] public double ParStepPrice { get; set; } public IList Execute(ISecurity sec) { var value = sec.FinInfo.StepPrice ?? ParStepPrice; var res = new double[Context.BarsCount]; for (int i = 0; i < res.Count(); i++) { res[i] = value; } return res; } } }