/// <summary> /// Get stock data of certain data cycle /// </summary> /// <param name="dc">The data cycle</param> /// <returns></returns> public Hashtable GetCycleData(DataCycle dc) { if (dc.CycleBase == DataCycleBase.DAY && dc.Repeat == 1 && !Adjusted) { return(htData); } else { Hashtable htCycle = (Hashtable)htAllCycle[dc.ToString()]; if (htCycle == null) { Hashtable ht; if (DataCycle.CycleBase < DataCycleBase.DAY) { ht = htRealtime; } else { ht = htData; } if (ht == null) { return(ht); } double[] ODATE = (double[])ht["DATE"]; if (ODATE == null) { return(null); } int[] NEWDATE = new int[ODATE.Length]; int Last = int.MinValue; int j = -1; int Num; for (int i = 0; i < ODATE.Length; i++) { Num = DataCycle.GetSequence(ODATE[i]); if (Num > Last) { j++; } NEWDATE[i] = j; Last = Num; } if (ht["CLOSE"] != null) { if (ht["OPEN"] == null) { ht["OPEN"] = ht["CLOSE"]; } if (ht["HIGH"] == null) { ht["HIGH"] = ht["CLOSE"]; } if (ht["LOW"] == null) { ht["LOW"] = ht["CLOSE"]; } } htCycle = new Hashtable(); foreach (string s in ht.Keys) { htCycle[s] = new double[j + 1]; } bool NeedAdjust = (Adjusted && ht["ADJCLOSE"] != null && ht["CLOSE"] != null); double[] CLOSE = (double[])ht["CLOSE"]; double[] ADJCLOSE = (double[])ht["ADJCLOSE"]; foreach (string s in ht.Keys) { bool DoAdjust = NeedAdjust; MergeCycleType mct; try { mct = (MergeCycleType)Enum.Parse(typeof(MergeCycleType), s); } catch { DoAdjust = false; if (s == "VOLUME" || s == "AMOUNT") { mct = MergeCycleType.SUM; } else { mct = MergeCycleType.CLOSE; } } MergeCycle(ODATE, NEWDATE, CLOSE, ADJCLOSE, (double[])ht[s], (double[])htCycle[s], mct, DoAdjust); } htAllCycle[dc.ToString()] = htCycle; } return(htCycle); } }
/// <summary> /// Get stock data of certain data cycle /// </summary> /// <param name="dc">The data cycle</param> /// <returns></returns> public Hashtable GetCycleData(DataCycle dc) { if (dc.CycleBase == DataCycleBase.DAY && dc.Repeat == 1 && !Adjusted) { return(htData); } else { dc.WeekAdjust = weekAdjust; Hashtable htCycle = (Hashtable)htAllCycle[dc.ToString()]; if (htCycle == null) { if (htData == null) { return(htData); } Hashtable ht = htData; if (intradayInfo != null) { ht = DoExpandMinute(ht); } if (futureBars != 0) { ht = ExpandFutureBars(ht); } if (ht["CLOSE"] != null) { if (ht["OPEN"] == null) { ht["OPEN"] = ht["CLOSE"]; } if (ht["HIGH"] == null) { ht["HIGH"] = ht["CLOSE"]; } if (ht["LOW"] == null) { ht["LOW"] = ht["CLOSE"]; } } double[] ODATE = (double[])ht["DATE"]; if (ODATE == null) { return(null); } int[] NEWDATE = new int[ODATE.Length]; int Last = int.MinValue; int j = -1; int Num; for (int i = 0; i < ODATE.Length; i++) { if (DataCycle.CycleBase == DataCycleBase.TICK) { Num = i / DataCycle.Repeat; } else { Num = DataCycle.GetSequence(ODATE[i]); } if (Num > Last) { j++; } NEWDATE[i] = j; Last = Num; } htCycle = new Hashtable(); foreach (string s in ht.Keys) { htCycle[s] = new double[j + 1]; } bool NeedAdjust = (Adjusted && ht["ADJCLOSE"] != null && ht["CLOSE"] != null); double[] CLOSE = (double[])ht["CLOSE"]; double[] ADJCLOSE = (double[])ht["ADJCLOSE"]; foreach (string s in ht.Keys) { bool DoAdjust = NeedAdjust; MergeCycleType mct; DoAdjust = false; if (htGroupping[s] != null) { mct = (MergeCycleType)htGroupping[s]; } else if (s == "DATE") { mct = dateMergeType; // MergeCycleType.OPEN; } else if (s == "VOLUME" || s == "AMOUNT") { mct = MergeCycleType.SUM; } else { try { mct = (MergeCycleType)Enum.Parse(typeof(MergeCycleType), s); DoAdjust = true; } catch { mct = MergeCycleType.CLOSE; } } MergeCycle(ODATE, NEWDATE, CLOSE, ADJCLOSE, (double[])ht[s], (double[])htCycle[s], mct, DoAdjust); } htAllCycle[dc.ToString()] = htCycle; } return(htCycle); } }
public string GetUnique() { return(DataCycle.ToString()); }
public Hashtable GetCycleData(DataCycle dc) { if (((dc.CycleBase == DataCycleBase.DAY) && (dc.Repeat == 1)) && !this.Adjusted) { return(this.htData); } Hashtable hashtable = (Hashtable)this.htAllCycle[dc.ToString()]; if (hashtable == null) { if (this.htData == null) { return(this.htData); } Hashtable htData = this.htData; if (this.intradayInfo != null) { htData = this.DoExpandMinute(htData); } if (htData["CLOSE"] != null) { if (htData["OPEN"] == null) { htData["OPEN"] = htData["CLOSE"]; } if (htData["HIGH"] == null) { htData["HIGH"] = htData["CLOSE"]; } if (htData["LOW"] == null) { htData["LOW"] = htData["CLOSE"]; } } double[] oDATE = (double[])htData["DATE"]; if (oDATE == null) { return(null); } int[] nEWDATE = new int[oDATE.Length]; int num = -2147483648; int num2 = -1; for (int i = 0; i < oDATE.Length; i++) { int sequence = this.DataCycle.GetSequence(oDATE[i]); if (sequence > num) { num2++; } nEWDATE[i] = num2; num = sequence; } hashtable = new Hashtable(); foreach (string str in htData.Keys) { hashtable[str] = new double[num2 + 1]; } bool flag = (this.Adjusted && (htData["ADJCLOSE"] != null)) && (htData["CLOSE"] != null); double[] cLOSE = (double[])htData["CLOSE"]; double[] aDJCLOSE = (double[])htData["ADJCLOSE"]; foreach (string str2 in htData.Keys) { MergeCycleType oPEN; bool doAdjust = flag; doAdjust = false; switch (str2) { case "DATE": oPEN = MergeCycleType.OPEN; break; case "VOLUME": case "AMOUNT": oPEN = MergeCycleType.SUM; break; default: try { oPEN = (MergeCycleType)Enum.Parse(typeof(MergeCycleType), str2); doAdjust = true; } catch { oPEN = MergeCycleType.CLOSE; } break; } this.MergeCycle(oDATE, nEWDATE, cLOSE, aDJCLOSE, (double[])htData[str2], (double[])hashtable[str2], oPEN, doAdjust); } this.htAllCycle[dc.ToString()] = hashtable; } return(hashtable); }