Exemple #1
0
        public bool OpenShort(int lots)
        {
            if (_order != null)
            {
                return(false);                // есть активный ордер
            }
            var hold = _platform.GetHoldingLots(_insID);

            if (hold != 0)
            {
                return(false);           // позиция уже открыта (не важно какая)
            }
            _order = _platform.AddSellOrder(_insID, null, lots);

            return(true);
        }
Exemple #2
0
        private void OnTick(DateTime time, decimal price, int lots)
        {
            if (ma1 == 0)
            {
                return;
            }
            if (_order != null && _order.Status == OrderStatus.Active)
            {
                return;                                                        // находимся в состоянии активной заявки
            }
            int t    = time.Hour * 10000 + time.Minute * 100 + time.Second;
            int hold = _platform.GetHoldingLots(_gazp.InsID);

            // вход
            if (hold == 0 && price >= ma1 + 0.2m && t >= 103000 && t < 183000)
            {
                int openLots = (int)decimal.Round(_platform.GetCurrentSumma() / (price * 10)) - 1;
                if (openLots > 0)
                {
                    _order = _platform.AddBuyOrder(_gazp.InsID, null, openLots);
                }
            }

            // выход
            if (hold > 0 && (price <= ma1 || t >= 183000))
            {
                _order = _platform.AddSellOrder(_gazp.InsID, null, hold);
            }
        }