Пример #1
0
        public override void OnSendCommand(ExecutionCommand cmd)
        {
            var order = cmd.Order;
            var info  = OrderExtensions.GetOrderInfo(order);

            info.processor = new OrderProcessor(this, order, _logger);
            ((OrderProcessor)info.processor).Init();
        }
Пример #2
0
        protected override void OnReminder(DateTime dateTime, object data)
        {
            var order = (Order)data;

            if (order.IsDone)
            {
                return;
            }
            var info = OrderExtensions.GetOrderInfo(order);

            ((OrderProcessor)info.processor)?.OnReminder(dateTime, order);
        }
Пример #3
0
        protected override void OnExecutionReport(ExecutionReport report)
        {
            var info = OrderExtensions.GetOrderInfo(report.Order);

            ((OrderProcessor)info.processor)?.OnExecutionReport(report);
        }
Пример #4
0
        public override void OnCancelCommand(ExecutionCommand cmd)
        {
            var info = OrderExtensions.GetOrderInfo(cmd.Order);

            ((OrderProcessor)info.processor)?.Cancel();
        }
Пример #5
0
        private void InitProcessor()
        {
            if (_processorInitiated)
            {
                return;
            }
            _processorInitiated = true;
            if (_store == null)
            {
                _store = GetPositionStore();
            }
            foreach (var strategy in framework.StrategyManager.GetStrategies())
            {
                if (strategy.Id == Id)
                {
                    continue;
                }
                _store.GetPositionManager(strategy);
            }

            var processorList = new Dictionary <int, OrderProcessor>();
            var orders        = OrderManager.Orders.ToArray();

            foreach (var order in orders)
            {
                if (order.IsDone || order.ProviderId != AgentId)
                {
                    continue;
                }

                var info = OrderExtensions.GetOrderInfo(order);
                info.processor          = new OrderProcessor(this, order, _logger);
                processorList[order.Id] = (OrderProcessor)info.processor;
            }

            foreach (var order in orders)
            {
                if (order.strategyId != Id)
                {
                    continue;
                }

                var info = OrderExtensions.GetOrderInfo(order);
                if (info.ParentOrderId == 0)
                {
                    continue;
                }

                if (!processorList.TryGetValue(info.ParentOrderId, out var processor))
                {
                    continue;
                }
                switch (order.GetOpenClose())
                {
                case XApi.OpenCloseType.Undefined:
                case XApi.OpenCloseType.Open:
                    processor.openOrder = order;
                    break;

                case XApi.OpenCloseType.Close:
                    processor.closeOrder = order;
                    break;

                case XApi.OpenCloseType.CloseToday:
                    processor.closeTodayOrder = order;
                    break;
                }
                if (!order.IsDone)
                {
                    info.processor = processor;
                }
            }

            foreach (var item in processorList)
            {
                item.Value.Resume();
            }
        }