Exemplo n.º 1
0
        public override void ForceStop()
        {
            try
            {
                CStrategyPrices.StopUpdates();
                LState.IsStartegyRun = false;

                var ActiveOrdersE = new ActiveOrdersGridEventArgs()
                {
                    StrategyType = LParam.StrategyType,
                    StrategyName = LParam.StrategyName
                };
                ChangeActiveOrders?.Invoke(this, ActiveOrdersE);

                ClosePosition();
                LState.Reset();
                Stop();
            }
            catch (Exception ex)
            {
                System.Media.SystemSounds.Beep.Play();
                Print(String.Format("Ошибка при принудительной остановке стратегии: {0}", ex.Message), true);
                ChangeState?.Invoke(false, false, LParam.StrategyName);
            }
        }
Exemplo n.º 2
0
        public override void ActiveOrdersInfo()
        {
            var ActiveOrdersE = new ActiveOrdersGridEventArgs()
            {
                StrategyType = LParam.StrategyType,
                StrategyName = LParam.StrategyName
            };

            if (LState.CurrentStep > 0)
            {
                if (LState.CurrentStep < LParam.MaxStepsNumber)
                {
                    ActiveOrdersE.ActiveOrdersList.Add(new ActiveOrders()       //Enter Position
                    {
                        OrderType = "Limit",
                        Direction = LParam.IsDirectionLong ? "Buy" : "Sell",
                        Amount    = LState.EnterPositionSum,
                        Price     = LState.EnterPositionPrice,
                        Comment   = String.Format("Переход на шаг {0}", LState.CurrentStep + 1)
                    });
                }

                ActiveOrdersE.ActiveOrdersList.Add(new ActiveOrders()       //Close Position
                {
                    OrderType = "Limit",
                    Direction = LParam.IsDirectionLong ? "Sell" : "Buy",
                    Amount    = LState.ClosePositionSum,
                    Price     = LState.ClosePositionPrice,
                    Comment   = String.Format("Закрытие шага {0}", LState.CurrentStep)
                });
            }
            ChangeActiveOrders?.Invoke(this, ActiveOrdersE);
        }