Exemplo n.º 1
0
 public override void Initialize()
 {
     macd = this.MACD(this.C, 13, 26, 9);
 }
Exemplo n.º 2
0
        public override void InitializeMultiAfter()
        {
            foreach (string instrument in this.instrumentMap.Keys)
            {
                if (instrument.StartsWith("rb"))
                {
                    this.rbInstrumentId = instrument;
                    this.macdMinRB      = MACD(this.instrumentMap[instrument][0].C, 8, 15, 9);
                    List <Data> datas = this.instrumentMap[instrument];
                    for (int i = 0; i < datas.Count; i++)
                    {
                        Data data = datas[i];
                        if (data.Interval != 1 || data.IntervalType != EnumIntervalType.Min)
                        {
                            datas.RemoveAt(i);
                            i--;
                        }
                    }
                    if (datas.Count <= 0)
                    {
                        throw new ArgumentException("rb not contains min 1 data");
                    }
                    continue;
                }
                if (instrument.StartsWith("i"))
                {
                    this.ironInstrumentId = instrument;
                    this.macdMinIron      = MACD(this.instrumentMap[instrument][0].C, 8, 15, 9);
                    List <Data> datas = this.instrumentMap[instrument];
                    for (int i = 0; i < datas.Count; i++)
                    {
                        Data data = datas[i];
                        if (data.Interval != 1 || data.IntervalType != EnumIntervalType.Min)
                        {
                            datas.RemoveAt(i);
                            i--;
                        }
                    }
                    if (datas.Count <= 0)
                    {
                        throw new ArgumentException("iron not contains min 1 data");
                    }
                    continue;
                }
                if (this.macdMinIron != null && this.macdMinRB != null)
                {
                    break;
                }
            }
            if (this.macdMinIron == null || this.macdMinRB == null)
            {
                throw new ArgumentException("rbxxx or ixxx doesn't exist in strategy");
            }
            int ironIndex = 0;

            for (int i = 0; i < this.Datas.Count; i++)
            {
                Data data = this.Datas[i];
                if (data.Instrument.StartsWith("i"))
                {
                    ironIndex = i;
                    break;
                }
            }
            if (ironIndex != 0)
            {
                Data oldfirst = this.Datas[0];
                this.Datas[0]         = this.Datas[ironIndex];
                this.Datas[ironIndex] = oldfirst;
            }
        }