public RawMarketData Decode_Raw(InPacket iPacket, String targetCode, DateTime curDateTime) { try { StringPacket sp = new StringPacket(iPacket.ToString().Substring(24)); String code = sp.Decode(); if (code != targetCode) { return null; } RawMarketData rmd = new RawMarketData(targetCode, Detail.ProductType.Unknown); String type = sp.Decode(); double value = Convert.ToDouble(sp.Decode()); DateTime dt = DateTime.ParseExact(sp.Decode(), "yyyyMMdd HH:mm:ss.fff", null); SetData_Raw(rmd, type, value, dt); return rmd; } catch (System.Exception ex) { logger.Warn(ex.ToString()); } return null; }
public PairArbEachOutput(StringPacket sp) { try { OptionCode = sp.Decode(); _CallPut = sp.Decode(); Strike = sp.Decode(); int liveCount = sp.DecodeInt(); for (int i = 0; i < liveCount; ++i) { _liveSweepUnitOutputs.Add(new PairSweeperOutput(sp)); } int doneCount = sp.DecodeInt(); for (int i = 0; i < doneCount; ++i) { _doneSweepUnitOutputs.Add(new PairSweeperOutput(sp)); } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
public override void UpdateUI(String strategyName, StringPacket sp) { try { String header = sp.Decode(); this.richTextBox1.Text = sp.Decode(); if (header.CompareTo(StrategyCommand.STR_OVERVIEW) == 0) { } else if (header.CompareTo(StrategyCommand.STR_INTERNAL) == 0) { } else if (header.CompareTo(StrategyCommand.STR_POSITION) == 0) { } else { logger.Warn(String.Format("Unknown header in UpdateUI({0})", header)); } } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }
public SweepUnitPOrder(StringPacket sp) { Code = sp.Decode(); ReqCount = sp.DecodeLong(); ReqPrice = sp.DecodeDouble(); ContractedCount = sp.DecodeLong(); _State = sp.Decode(); }
public SortedList<DateTime, InfomaxDataRow> LoadData( String targetCode, String path, InfomaxDataRow.Type targetType) { SortedList<DateTime, InfomaxDataRow> data = new SortedList<DateTime, InfomaxDataRow>(); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); StreamReader sr = new StreamReader(fs); while (!sr.EndOfStream) { String line = sr.ReadLine(); StringPacket sp = new StringPacket(line); sp.Decode(); // skip sp.Decode(); // skip InfomaxDataRow.Type type = InfomaxDataRow.Type.Unknown; String strType = sp.Decode(); if (strType.CompareTo("CurPrice") == 0) { type = InfomaxDataRow.Type.CurPrice; } else if (strType.CompareTo("BidPrice") == 0) { type = InfomaxDataRow.Type.BidPrice1; } else if (strType.CompareTo("AskPrice") == 0) { type = InfomaxDataRow.Type.AskPrice1; } double value = sp.DecodeDouble(); DateTime dt = DateTime.ParseExact(sp.Decode(), "yyyyMMdd HH:mm:ss.fff", null); if (type == targetType) { InfomaxDataRow row = new InfomaxDataRow(); row.RowType = type; row.Value = value; row.CurDateTime = dt; data.Add(dt, row); } } sr.Close(); fs.Close(); return data; }
void ChangeAfterCancel(StringPacket sp) { String strEnterAfterCancel = sp.Decode(); Boolean enterAfterCancel = Convert.ToBoolean(strEnterAfterCancel); _monitorController.EnterAfterCancel = enterAfterCancel; }
public ElwArbEachOutput(StringPacket sp) { try { OptionCode = sp.Decode(); int liveCount = sp.DecodeInt(); for (int i = 0; i < liveCount; ++i) { _liveEOSOutput.Add(new EOSOutput(sp)); } int doneCount = sp.DecodeInt(); for (int i = 0; i < doneCount; ++i) { _doneEOSOutput.Add(new EOSOutput(sp)); } int rLiveCount = sp.DecodeInt(); for (int i = 0; i < rLiveCount; ++i) { _rLiveEOSOutput.Add(new EOSOutput(sp)); } int rDoneCount = sp.DecodeInt(); for (int i = 0; i < rDoneCount; ++i) { _rDoneEOSOutput.Add(new EOSOutput(sp)); } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
public SweepUnitDataRow(StringPacket sp, int id) { ID = id; Code = sp.Decode(); Exposure = sp.DecodeDouble(); _State = sp.Decode(); int count = sp.DecodeInt(); Orders = new ArrayList(); for (int i = 0; i < count; ++i) { Orders.Add(new SweepUnitPOrder(sp)); } }
public override void UpdateUI(String strategyName, StringPacket sp) { try { String command = sp.Decode(); } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }
public SortedList<DateTime, InfomaxDataRow> LoadData( String targetCode, String path, InfomaxDataRow.Type targetType) { SortedList<DateTime, InfomaxDataRow> data = new SortedList<DateTime, InfomaxDataRow>(); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); StreamReader sr = new StreamReader(fs); while (!sr.EndOfStream) { String line = sr.ReadLine(); StringPacket sp = new StringPacket(line); String code = sp.Decode(); if (code.CompareTo(targetCode) == 0) { InfomaxDataRow.Type type = InfomaxDataRow.ConvertStringToType(sp.Decode()); double value = sp.DecodeDouble(); DateTime dt = DateTime.ParseExact(sp.Decode(), "yyyyMMdd HH:mm:ss.fff", null); if (type == targetType) { InfomaxDataRow row = new InfomaxDataRow(); row.RowType = type; row.Value = value; row.CurDateTime = dt; data.Add(dt, row); } } } sr.Close(); fs.Close(); return data; }
public void SetData(InPacket iPacket) { try { StringPacket sp = new StringPacket(iPacket.ToString()); String code = sp.Decode(); RawMarketData rmd = RmdManager.Ins().KtbSpot.GetData(code); if (rmd == null) { return; } String type = sp.Decode(); double value = Convert.ToDouble(sp.Decode()); DateTime dt = DateTime.ParseExact(sp.Decode(), "yyyyMMdd HH:mm:ss.fff", null); SetData_Raw(rmd, type, value, dt); } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }
public override void UpdateUI(String strategyName, StringPacket sp) { lock (locker) { try { String command = sp.Decode(); if (command.CompareTo(Const.LOAD_PRODUCTS) == 0) { UpdateProductList(sp); } } catch (System.Exception ex) { logger.Warn(ex.ToString()); } } }
public override void UpdateUI(String strategyName, StringPacket sp) { try { String header = sp.Decode(); switch (header) { case StrategyCommand.STR_OVERVIEW: UpdateOverviewData(strategyName, sp); break; default: break; } } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }
public override void UpdateUI(String strategyName, StringPacket sp) { try { String header = sp.Decode(); if (header.CompareTo(StrategyCommand.REQUEST_ELW_OOR_ORDERS) == 0) { //TODO logger.Warn("아직 구현하지 않았다."); } else { logger.Warn("Invalid."); } } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }
void UpdateProductList(StringPacket sp) { int count = sp.DecodeInt(); dataGridView1.Rows.Clear(); for (int i = 0; i < count; ++i) { String code = sp.Decode(); String askPrice = sp.Decode(); String bidPrice = sp.Decode(); Boolean bLegal = Convert.ToBoolean(sp.Decode()); int index = dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells[0].Value = code; dataGridView1.Rows[index].Cells[1].Value = askPrice; dataGridView1.Rows[index].Cells[2].Value = bidPrice; dataGridView1.Rows[index].Cells[3].Value = bLegal; } }
public void HandleCommand(StringPacket command) { String key = command.Decode(); switch (key) { case StrategyCommand.CREATE_CUSTOM_UI: CreateCustomUI(); break; case StrategyCommand.STR_OVERVIEW: GiveOverviewDataToUI(command); break; case StrategyCommand.DOOR_CHANGE_AFTER_CANCEL: ChangeAfterCancel(command); break; case StrategyCommand.DOOR_ENTER_SIGNAL: ChangeStateIntoEnterIfPossible(); break; case StrategyCommand.DOOR_CANCEL_SIGNAL: ChangeStateIntoCancelIfPossible(); break; case StrategyCommand.DOOR_REFRESH_SWEEPER: GiveSweeperInfoToUI(); break; case StrategyCommand.DOOR_CANCEL_ORDERS: CancelOrders(command); break; case StrategyCommand.DOOR_REQUEST_SWEEP_ORDER: RequestSweeperOrder(command); break; case StrategyCommand.DOOR_CHANGE_MIN_ENTER_COUNT: ChangeEnterCount(command); break; case StrategyCommand.DOOR_REMOVE_OLD_ROUND_SWEEPER: RemoveOldRoundSweeper(); break; default: break; } }
public void HandleCommand(StringPacket command) { String key = command.Decode(); switch (key) { case StrategyCommand.CREATE_CUSTOM_UI: CreateCustomUI(); break; case StrategyCommand.STR_OVERVIEW: GiveOverviewDataToUI(command); break; case StrategyCommand.EDOOR_CHANGE_ENTER_TEN: ChangeEnterTenFlag(command); break; case StrategyCommand.EDOOR_CHANGE_BLOCK_AFTER_CANCEL: ChangeBlockAfterCancel(command); break; default: break; } }
void GiveOverviewDataToUI(StringPacket sp) { String subTarget = sp.Decode(); if (subTarget.CompareTo(StrategyCommand.EDOOR_OVERVIEW) == 0) { EDoor_Overview_DataForUI data = new EDoor_Overview_DataForUI(); // 스케줄러 상태를 구한다. data.IsSchedulerOn = ScheduleManager.Ins().IsStart; // 에이전트 상태를 구한다. data.IsAgentOn = _agent.IsStart(); // Enter, Monitor, Rebalance 각 상태의 수량을 구한다. data.EnterCount = _monitorController.GetStateCount(EDoorEachMonitorEnterState.EnteringState); data.MonitorCount = _monitorController.GetStateCount(EDoorEachMonitorEnterState.MonitorState); data.RebalanceCount = _monitorController.GetStateCount(EDoorEachMonitorEnterState.RebalanceState); // 진행중인 Sweeper, 완료된 Sweeper 수량을 구한다. data.LiveSweeperCount = _sweeperController.GetLiveCount(); data.DoneSweeperCount = _sweeperController.GetDoneCount(); // BlockAfterCancel data.BlockAfterCancel = _monitorController.BlockAfterCancel; // EnterCountState(10 or Max) data.EnterTen = _monitorController.EnterTen; String jsonText = Util.GetJsonText(typeof(EDoor_Overview_DataForUI), data); StringPacket spRet = new StringPacket(); spRet.Encode(StrategyCommand.STR_OVERVIEW); spRet.Encode(StrategyCommand.EDOOR_OVERVIEW); spRet.Encode(jsonText); StrategyUIChannel.Ins().UpdateUI(GetStrategyName(), spRet); } else { logger.Warn("Invalid"); } }
RawMarketData Decode_Raw(String line) { StringPacket sp = new StringPacket(line); String code = sp.Decode(); //2011-07-13 09:00:00.000 DateTime curDateTime = DateTime.ParseExact(sp.Decode(), "yyyy-MM-dd HH:mm:ss.fff", null); if (curDateTime.Hour >= 15) { return null; } double askPrice = sp.DecodeDouble(); double curPrice = sp.DecodeDouble(); double bidPrice = sp.DecodeDouble(); RawMarketData rmd = new RawMarketData(code, Detail.ProductType.Unknown); rmd.CurPrice = curPrice; rmd.BidPrice1 = bidPrice; rmd.AskPrice1 = askPrice; rmd.LastUpdatedTime = curDateTime; return rmd; }
public SweepUnitOutput(StringPacket sp) { Code = sp.Decode(); State = sp.Decode(); NetBookValue = sp.Decode(); Exposure = sp.Decode(); UsedCodes = sp.Decode(); }
//////////////////////////////////////////////////////////////////////////////////////////////// public void HandleCommand(StringPacket command) { String strCommand = command.Decode(); if (strCommand.ToUpper().CompareTo(StrategyCommand.PERMISSION_OK) == 0) { UpdatePermissionOK(); } }
void ResponseWasDiffDataToUI(String header, StringPacket sp) { String optionCode = sp.Decode(); if (!_watchList.ContainsKey(WAS_WATCH)) { logger.Warn(String.Format("No was_watch list")); return; } WasMainController wasMainController = _watchList[WAS_WATCH] as WasMainController; String koiKey = ElwOptionUtil.GetKOIKey(optionCode); Was_Diff_DataForUI data = wasMainController.GetWasDiffDataForUI(koiKey); Serializer serializer = new Serializer(typeof(Was_Diff_DataForUI)); String jsonText = serializer.Serialize(data); StrategyUIChannel.Ins().UpdateUI(GetStrategyName(), header, jsonText); }
List<String> ParseWatchListString(String input) { List<String> ret = new List<string>(); StringPacket sp = new StringPacket(input, ";"); while (!sp.Empty()) { ret.Add(sp.Decode()); } return ret; }
void UpdateOverviewData(String strategyName, StringPacket sp) { String detail = sp.Decode(); switch (detail) { case StrategyCommand.EDOOR_OVERVIEW: UpdateOverviewData(sp); break; default: break; } }
void UpdateOverviewData(StringPacket sp) { EDoor_Overview_DataForUI data = Util.GetJsonObject( typeof(EDoor_Overview_DataForUI), sp.Decode()) as EDoor_Overview_DataForUI; UtilUI.UpdateButtonColor(cb1, data.IsSchedulerOn); UtilUI.UpdateButtonColor(cb2, data.IsAgentOn); UtilUI.UpdateButtonColor(cb3, data.BlockAfterCancel); textBox1.Text = "" + data.MonitorCount; textBox2.Text = "" + data.EnterCount; textBox3.Text = "" + data.RebalanceCount; textBox4.Text = "" + data.LiveSweeperCount; textBox5.Text = "" + data.DoneSweeperCount; radioButton1.Checked = data.EnterTen; }
void GiveOverviewDataToUI(StringPacket sp) { String subTarget = sp.Decode(); if (subTarget.CompareTo(StrategyCommand.DOOR_OVERVIEW) == 0) { Door_Overview_DataForUI data = new Door_Overview_DataForUI(); data.IsSchedulerOn = ScheduleManager.Ins().IsStart; data.IsAgentOn = _agent.IsStart(); data.MonitorState = _monitorController.GetStateString(); data.SweeperCount = _sweeperController.GetLiveCount(); data.OutOrderCount = GetOutOrderCount(); data.EnterAfterCancel = _monitorController.EnterAfterCancel; data.EnterMinCount = _monitorController.EnterMinCount; String jsonText = Util.GetJsonText(typeof(Door_Overview_DataForUI), data); StringPacket spRet = new StringPacket(); spRet.Encode(StrategyCommand.STR_OVERVIEW); spRet.Encode(StrategyCommand.DOOR_OVERVIEW); spRet.Encode(jsonText); StrategyUIChannel.Ins().UpdateUI(GetStrategyName(), spRet); } else { logger.Warn("Invalid"); } }
void ChangeEnterCount(StringPacket sp) { Boolean enterMinCount = Convert.ToBoolean(sp.Decode()); _monitorController.EnterMinCount = enterMinCount; }
public void UpdateModifiedList(StringPacket sp) { lock (locker) { int count = sp.DecodeInt(); _codes.Clear(); for (int i = 0; i < count; ++i) { String code = sp.Decode(); _codes.Add(code, code); } String futureCode = KospiFutureUtil.Ins().KFI.Code; _codes.Add(futureCode, futureCode); } }
void CancelOrders(StringPacket sp) { int sweeperID = Convert.ToInt32(sp.Decode()); _sweeperController.CancelOrders(sweeperID); logger.Info("Cancel Sweeper Orders"); }
void RequestSweeperOrder(StringPacket sp) { long sweeperID = Convert.ToInt64(sp.Decode()); String code = sp.Decode(); double reqPrice = Convert.ToDouble(Util.RemoveComma(sp.Decode())); reqPrice = ProductUtil.Ins().RoundProductPrice(code, reqPrice); long reqCount = Convert.ToInt64(Util.RemoveComma(sp.Decode())); TradingDirection ls = TradingDirection.Short; if (reqCount > 0) { ls = TradingDirection.Long; } reqCount = Math.Abs(reqCount); RawMarketData rmdClone = RmdManager.Ins().GetDataClone(code); _sweeperController.RequestSweeperOrder(sweeperID, ls, code, reqPrice, reqCount, rmdClone); }