public void AddTuple(FoxCaptureTuple tuple) { String slideKey = FoxCaptureSlide.CreateKey(tuple.InsertedTime, tuple.GroupID); if (_dic.ContainsKey(slideKey)) { _dic[slideKey].AddTuple(tuple); } else { Debug.Assert(false); } }
public void AddTuple(FoxCaptureTuple tuple) { _list.Add(tuple); }
void SaveCaptureTuple(Dictionary<String, FoxRawDataEachCollector> eachControllers) { foreach (FoxRawDataEachCollector ec in eachControllers.Values) { FoxCaptureTuple tuple = new FoxCaptureTuple(); tuple.GroupID = this._slide.GroupID; tuple.Code = ec.Code; tuple.VelocityWithTimeInterval = ec.VelocityData.GetVelocityWithMilliSecKey(); tuple.RangesWithMinuteKey = ec.RangeData.GetRangesWithMinuteKey(); tuple.VolsWithMinuteKey = ec.PriceVolData.GetVolsWithMinuteKey(); tuple.ElwOneOptionValue = 0; tuple.ElwCode = ""; tuple.ElwCount = 0; tuple.ElwPrice = 0; if (ec.OT != null) { ec.OT.ReadyRawData(); RawMarketData rmdLongCandidate = null; Dictionary<String, String> exceptCodes = new Dictionary<String, String>(); exceptCodes.Add(tuple.Code, tuple.Code); double oneOptionValue = ec.OT.GetBestLongOneOptionValue(ref rmdLongCandidate, exceptCodes); if (rmdLongCandidate != null) { tuple.ElwOneOptionValue = oneOptionValue; tuple.ElwCode = rmdLongCandidate.Code; tuple.ElwCount = rmdLongCandidate.AskCount1; tuple.ElwPrice = rmdLongCandidate.AskPrice1; } } RawMarketData rmdFO = RmdManager.Ins().GetDataClone(ec.Code); if (!Util.IsValidRMDTimeAndPrice(rmdFO)) { continue; } tuple.BidPrice = rmdFO.BidPrice1; tuple.AskPrice = rmdFO.AskPrice1; tuple.CurPrice = rmdFO.CurPrice; tuple.TimeOffset = this._curTimeOffset; tuple.InsertedTime = _insertedTime; // 여기서 코드별로 정리해 놓지 않았다. 코드별로 정리해 놓는 것이 좋을 수도 있다. // 코드별로 정리한다면 Dictionary<String, List<FoxCaptureTuple>>와 같은 식으로 정리하면 된다. _slide.AddTuple(tuple); // 선물과 가격이 0.5 ~ 3.0 사이인 옵션만 저장한다. if (tuple.Code.CompareTo(_futureCode) == 0 || (tuple.CurPrice >= 0.5 && tuple.CurPrice <= 3.0)) { //DB DBOut(tuple); } } ++this._curTimeOffset; }
List<String> GetVolQuery(FoxCaptureTuple tuple) { List<String> ret = new List<string>(); String insertedDate = tuple.InsertedTime.ToString("yyyy-MM-dd"); int groupID = tuple.GroupID; String code = tuple.Code; int timeOffset = tuple.TimeOffset; foreach (int interval in tuple.VolsWithMinuteKey.Keys) { FoxPriceVolDatum datum = tuple.VolsWithMinuteKey[interval]; double vol = datum.PriceVol; String query = String.Format( "insert into fox_capture_data_vol values ('{0}', {1}, '{2}', {3}, {4}, {5})", insertedDate, groupID, code, timeOffset, interval, vol); ret.Add(query); } return ret; }
List<String> GetVelocityQuery(FoxCaptureTuple tuple) { List<String> ret = new List<string>(); String insertedDate = tuple.InsertedTime.ToString("yyyy-MM-dd"); int groupID = tuple.GroupID; String code = tuple.Code; int timeOffset = tuple.TimeOffset; foreach (int interval in tuple.VelocityWithTimeInterval.Keys) { FoxPriceVelocityDatum datum = tuple.VelocityWithTimeInterval[interval]; double velocity = datum.Velocity; String query = String.Format( "insert into fox_capture_data_velocity values ('{0}', {1}, '{2}', {3}, {4}, {5})", insertedDate, groupID, code, timeOffset, interval, velocity); ret.Add(query); } return ret; }
List<String> GetRangeQuery(FoxCaptureTuple tuple) { List<String> ret = new List<string>(); String insertedDate = tuple.InsertedTime.ToString("yyyy-MM-dd"); int groupID = tuple.GroupID; String code = tuple.Code; int timeOffset = tuple.TimeOffset; foreach (int interval in tuple.RangesWithMinuteKey.Keys) { FoxPriceRangeDatum datum = tuple.RangesWithMinuteKey[interval]; String observationTime = datum.ObservationTime.ToString("yyyy-MM-dd HH:mm:ss"); double maxPrice = datum.MaxPrice; double minPrice = datum.MinPrice; String query = String.Format( "insert into fox_capture_data_range values ('{0}', {1}, '{2}', {3}, {4}, {5}, {6}, '{7}')", insertedDate, groupID, code, timeOffset, interval, maxPrice, minPrice, observationTime); ret.Add(query); } return ret; }
String GetDefaultQuery(FoxCaptureTuple tuple) { String insertedDate = tuple.InsertedTime.ToString("yyyy-MM-dd"); int groupID = tuple.GroupID; String code = tuple.Code; int timeOffset = tuple.TimeOffset; double bidPrice = tuple.BidPrice; double askPrice = tuple.AskPrice; double curPrice = tuple.CurPrice; String observationTime = tuple.InsertedTime.ToString("yyyy-MM-dd HH:mm:ss"); double possibleMinLongOneOptionValue = tuple.ElwOneOptionValue; String longCode = tuple.ElwCode; long longCount = tuple.ElwCount; String query = String.Format( "insert into fox_capture_data_default values ('{0}', {1}, '{2}', {3}, {4}, {5}, {6}, '{7}', {8}, '{9}', {10})", insertedDate, groupID, code, timeOffset, bidPrice, askPrice, curPrice, observationTime, possibleMinLongOneOptionValue, longCode, longCount); return query; }
void DBOut(FoxCaptureTuple tuple) { String queryDefault = GetDefaultQuery(tuple); List<String> queryRange = GetRangeQuery(tuple); List<String> queryVelocity = GetVelocityQuery(tuple); List<String> queryVol = GetVolQuery(tuple); ArrayList arr = new ArrayList(); arr.Add(queryDefault); arr.AddRange(queryRange); arr.AddRange(queryVelocity); arr.AddRange(queryVol); if (this.IsToDB_InRunning) { DBOutManager.Ins().AddTask(DBOutManager.Task.QueryOut, arr); } }