Ejemplo n.º 1
0
        public List <IOrder> ProcessSignal(List <ISignal> signalList, IPortfolio targetPortfolio)
        {
            if (targetPortfolio == null || signalList == null || signalList.Count == 0)
            {
                return(null);
            }
            var ol = new List <IOrder>();

            signalList.ForEach(s =>
            {
                if (TargetSignalName == s.Name && s.ResultType == SignalType.Trade &&
                    (string.IsNullOrEmpty(TargetInstrumentTicker) || TargetInstrumentTicker == s.Ticker))
                {
                    if (Threshold < CommonProc.EPSILON ||
                        (s.IsPositive && s.Value >= Threshold) ||
                        (!s.IsPositive && s.Value <= Threshold))
                    {
                        if (PercentLimit < CommonProc.EPSILON)
                        {
                            var o = targetPortfolio.GenerateOrder(s.Ticker, s.Price, Order.MinOperationShares, TargetOrderType);
                            if (o != null)
                            {
                                o.OrderTime = s.Time;
                                ol.Add(o);
                            }
                        }
                        else if (MaxOrderTimes > 0 && CurrentOrderTimes < MaxOrderTimes)
                        {
                            var p = PercentLimit / (MaxOrderTimes - CurrentOrderTimes);
                            var o = targetPortfolio.GenerateOrderByPercent(s.Ticker, s.Price, p, TargetOrderType);
                            if (o != null)
                            {
                                o.OrderTime = s.Time;
                                ol.Add(o);
                                CurrentOrderTimes++;
                            }
                        }
                    }
                }
            });
            return(ol);
        }