예제 #1
0
파일: DataNavigate.cs 프로젝트: wanwei/sc2
 private void CurrentNavigate_Code_OnRealTimeChanged(object sender, RealTimeChangedArgument argument)
 {
     if (this.OnRealTimeChanged != null)
     {
         this.OnRealTimeChanged(sender, argument);
     }
 }
예제 #2
0
 private void RealTimeDataReader_Code_OnRealTimeChanged(object sender, RealTimeChangedArgument argument)
 {
     if (OnRealTimeChanged != null)
     {
         OnRealTimeChanged(this, argument);
     }
 }
예제 #3
0
 private void HistoryDataForward_OnRealTimeChanged(object sender, RealTimeChangedArgument e)
 {
     if (this.OnRealTimeChanged != null)
     {
         this.OnRealTimeChanged(this, e);
     }
 }
예제 #4
0
        //public RealTimeReader_Strategy(IDataReader dataReader, RealTimeReader_StrategyArguments args)
        //{
        //    //this.dataPackage = DataPackageFactory.CreateDataPackage(dataReader,)
        //    this.dataReader = dataReader;
        //    this.code = args.Code;
        //    this.startDate = args.StartDate;
        //    this.endDate = args.EndDate;
        //    this.referedPeriods = args.ReferedPeriods;
        //    this.forwardPeriod = new ForwardPeriod(args.IsTickForward, args.ForwardKLinePeriod);

        //    this.allKLineData = new Dictionary<KLinePeriod, KLineData_RealTime>();
        //    for (int i = 0; i < referedPeriods.UsedKLinePeriods.Count; i++)
        //    {
        //        KLinePeriod period = referedPeriods.UsedKLinePeriods[i];
        //        IKLineData klineData = this.dataReader.KLineDataReader.GetData(code, startDate, endDate, period);
        //        KLineData_RealTime klineData_RealTime = new KLineData_RealTime(klineData);
        //        allKLineData.Add(period, klineData_RealTime);
        //    }

        //    IList<int> allTradingDays = dataReader.TradingDayReader.GetTradingDays(startDate, endDate);
        //    if (args.IsTickForward)
        //    {
        //        this.klineDataForward = new HistoryDataForward_Code_TickPeriod(dataReader, code, allKLineData, allTradingDays, args.ForwardKLinePeriod);
        //    }
        //    else
        //    {
        //        KLinePeriod mainPeriod = args.ForwardKLinePeriod;
        //        KLineData_RealTime mainKLineData = allKLineData[mainPeriod];
        //        this.klineDataForward = new HistoryDataForward_Code_KLinePeriod(code, mainKLineData, allKLineData);
        //    }

        //    this.klineDataForward.OnTick += KlineDataForward_OnTick;
        //    this.klineDataForward.OnBar += KlineDataForward_OnBar;
        //}

        private void KlineDataForward_OnRealTimeChanged(object sender, RealTimeChangedArgument e)
        {
            if (OnRealTimeChanged != null)
            {
                OnRealTimeChanged(this, e);
            }
        }
예제 #5
0
 private void DataForward_OnRealTimeChanged(object sender, RealTimeChangedArgument argument)
 {
     if (OnRealTimeChanged != null)
     {
         OnRealTimeChanged(this, new RealTimeChangedArgument(argument.PrevTime, this.Time, this));
     }
     if (OnNavigateTo != null)
     {
         OnNavigateTo(this, new DataNavigateEventArgs(Code, Code, argument.PrevTime, argument.Time));
     }
 }
예제 #6
0
        private void RealTimeDataReader_RealTimeChanged(object sender, RealTimeChangedArgument e)
        {
            lock (lockObj)
            {
                this.time = e.Time;
                //过了新的一天,昨日的委托需要全部清除
                if (e.TradingDayChanged)
                {
                    CancelAllOrder();
                    return;
                }

                loopOrders.Clear();
                loopOrders.AddRange(waitingOrders);

                //TODO 价格变化后需要修改现金余额
                for (int i = 0; i < loopOrders.Count; i++)
                {
                    OrderInfo order = loopOrders[i];
                    if (AccountSetting.TradeType == AccountTradeType.DELAYTIME)
                    {
                        double delayTime   = AccountSetting.DelayTime;
                        double betweenTime = e.Time - order.OrderTime;
                        if (betweenTime <= delayTime)
                        {
                            continue;
                        }
                    }
                    else if (accountSetting.TradeType == AccountTradeType.DELAYTICK)
                    {
                        ITickData tickData = this.realTimeDataReader.GetRealTimeData(order.Instrumentid).GetTickData();
                        if (tickData != null)
                        {
                            if (this.dic_Code_OrderDelayInfo.ContainsKey(order.OrderID))
                            {
                                OrderDelayInfo delayInfo = this.dic_Code_OrderDelayInfo[order.OrderID];
                                int            tickIndex = delayInfo.orderTickIndex;
                                int            delayTick = AccountSetting.DelayTick;
                                if (tickData.BarPos - tickIndex < delayTick)
                                {
                                    continue;
                                }
                            }
                        }
                    }
                    DoTrade(order);
                }
            }
        }
예제 #7
0
파일: DataNavigate.cs 프로젝트: wanwei/sc2
 private void DataForward_Code_OnRealTimeChanged(object sender, RealTimeChangedArgument argument)
 {
     if (this.OnRealTimeChanged != null)
     {
         double prevTime = argument.PrevTime;
         double time     = argument.Time;
         this.OnRealTimeChanged(this, new RealTimeChangedArgument(prevTime, time, this));
     }
     if (this.OnNavigateTo != null)
     {
         string prevCode = Code;
         string code     = Code;
         double prevTime = argument.PrevTime;
         double time     = argument.Time;
         this.OnNavigateTo(this, new DataNavigateEventArgs(prevCode, code, prevTime, time));
     }
 }