← Назад

Quoting стратегии

Приветствую всех!

class Abi : Strategy
    {
        public Abi()
            : base()
        {
        }

        void Trader_QuotesChanged(IEnumerable<MarketDepth> obj)
        {
            OnProcess();
        }

        protected override void OnRunned()
        {
            base.OnRunned();
        }

        protected override void OnRunning()
        {
            Trader.QuotesChanged += Trader_QuotesChanged;
            Trader.RegisterQuotes(Security);
            base.OnRunning();
        }

        protected override StrategyProcessResults OnProcess()
        {
            if (ProcessState == StrategyProcessStates.Stopping)
            {
                return StrategyProcessResults.Stop;
            }
            
            if (ChildStrategies.Count == 0)
            {
                
                this.Volume = 3;
                var s = new MarketQuotingStrategy(
                    CreateOrder(OrderDirections.Sell, Security.BestAsk.Price + 2),
                    new Unit()
                    {
                        Security = this.Security,
                        Type = UnitTypes.Step,
                        Value = 1
                    },
                    1);
                
                this.ChildStrategies.Add(s);
                s.Start();
            }
            return StrategyProcessResults.Continue;
        }
    }

Подскажите плиз что неправильно в этом коде или как должна работать MarketQuotingStrategy? Если выставить из Abi стратегии заявку она встает. Стакан выводиться. По логу видно что родительская и дочерняя стратегии стартовали. Но больше никаких действий не происходит. Инструмент лукойл. Указываю цену на 2 рубля выше лучшего аска в надежде что MarketQuotingStrategy выставит заявку и начнет ее двигать.

Комментарии (3)

Вход или Создать аккаунт, Войдите или зарегистрируйтесь, чтобы оставить комментарий

Serg
Serg Автор

Сколько не мучал ничего не получильсь... ээхх. Было решено унаследоваться от стратегии BestByPriceQuotingStrategy

    class BBMB : BestByPriceQuotingStrategy
    {
        public BBMB(Order o, Unit u) : base(o, u)
        { }

        protected override StrategyProcessResults OnProcess()
        {
            return base.OnProcess();
        }

        protected override void OnRunned()
        {
            base.OnRunned();
        }

        protected override void OnRunning()
        {
            Trader.QuotesChanged += new System.Action<IEnumerable<MarketDepth>>(Trader_QuotesChanged);
            base.OnRunning();
        }

        void Trader_QuotesChanged(IEnumerable<MarketDepth> obj)
        {
            OnProcess();
        }
        
        protected override void OnStopping()
        {
            Trader.QuotesChanged -= new System.Action<IEnumerable<MarketDepth>>(Trader_QuotesChanged);
            base.OnStopping();
        }
    }

В главной стратегии код был немного переделан:

        protected override StrategyProcessResults OnProcess()
        {
            if (ProcessState == StrategyProcessStates.Stopping)
                return StrategyProcessResults.Stop;
            
            if (ChildStrategies.Count == 0)
            {
                this.Volume = 3;
                Order o = CreateOrder(OrderDirections.Sell, 1754);
                Unit u = new Unit()
                {
                    Security = this.Security,
                    Type = UnitTypes.Point,
                    Value = 0.02
                };

                var ss = new BBMB(o, u) { IsParallel = true};
                AddLog(StrategyErrorStates.Warning, ss.PriceExchange.ToString(), this);
                this.ChildStrategies.Add(ss);
                ss.Start();
            }
            
            return StrategyProcessResults.Continue;
        }

Теперь заявка выставляется, но почему то по цене 100р когда в стакане около 1750. При различных значения u.Value от 0.01 до 100 (с разными шагами) значение цены заявки равнялась 100.

Serg
Serg Автор

Если у кого-то работает MarketQuotingStrategy или BestByPriceQuotingStrategy или любая другая основанная на QuotingStrategy киньте плиз пример. Спасибо.

Mikhail Sukhov
Mikhail Sukhov

Serg: Если у кого-то работает MarketQuotingStrategy или BestByPriceQuotingStrategy или любая другая основанная на QuotingStrategy киньте плиз пример. Спасибо.

Логирование стратегий сделайте плиз. И выложите текстом. Так пока не понятно.