private void Init() { int date = (int)(this.DateTime / 1000000L); if (this.Cache[date].HasPrice(this.DateTime)) { Exac = this.Cache[date].GetPrice(this.DateTime); } else { int bkDate = date; // Prev { if (this.Cache[date].HasPrevPrice(this.DateTime)) { Prev = this.Cache[date].GetPrevPrice(this.DateTime); } else { for (int c = 0; c < EMPTY_DAY_MAX; c++) { date = DateToDay.toDate(DateToDay.toDay(date) - 1); if (this.Cache[date].IsEmpty() == false) { Prev = this.Cache[date].GetLastPrice(); break; } } } } date = bkDate; // Next { if (this.Cache[date].HasNextPrice(this.DateTime)) { Next = this.Cache[date].GetNextPrice(this.DateTime); } else { for (int c = 0; c < EMPTY_DAY_MAX; c++) { date = DateToDay.toDate(DateToDay.toDay(date) + 1); if (this.Cache[date].IsEmpty() == false) { Next = this.Cache[date].GetFirstPrice(); break; } } } } } }
public RawPrice GetPrice(long dateTime) { int index = Prices.indexOf(RawPrice.GetTarget(dateTime)); if (index == -1) { throw new Exception(dateTime + " の Price はありません。"); } return(Prices[index]); }
public RawPrice GetNextPrice(long dateTime) { int index = Prices.rightIndexOf(RawPrice.GetTarget(dateTime)) + 1; if (Prices.size() <= index) { throw new Exception(dateTime + " より後の Price はありません。"); } return(Prices[index]); }
public RawPrice GetPrevPrice(long dateTime) { int index = Prices.leftIndexOf(RawPrice.GetTarget(dateTime)) - 1; if (index < 0) { throw new Exception(dateTime + " より前の Price はありません。"); } return(Prices[index]); }
public bool HasPrice(long dateTime) { return(Prices.contains(RawPrice.GetTarget(dateTime))); }
public static int Comp(RawPrice a, RawPrice b) { return(LongTools.comp(a.DateTime, b.DateTime)); }