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; }
void ChangeAfterCancel(StringPacket sp) { String strEnterAfterCancel = sp.Decode(); Boolean enterAfterCancel = Convert.ToBoolean(strEnterAfterCancel); _monitorController.EnterAfterCancel = enterAfterCancel; }
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()); } }
private void button11_Click(object sender, EventArgs e) { try { String strategyName = textStrategyCommand.Text; String command = textCommand.Text; String detailCommand = textDetailCommand.Text; DialogResult dr = MessageBox.Show(this, String.Format("{0}|{1}|{2}|, right?", strategyName, command, detailCommand), "", MessageBoxButtons.YesNoCancel); if (dr == DialogResult.Yes) { StringPacket sp = new StringPacket(); sp.Encode(Const.COMMAND_HANDLE_STRATEGY_COMMAND); sp.Encode(strategyName); sp.Encode(command); sp.Encode(detailCommand); ScheduleManager.Ins().AddCommand(sp); } } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }
public static void Error(String log) { MLog.Ins().Error(log); // Error라면 무조건 죽인다. 이 편이 속편하다. 작은 기회에 연연하지 말자 AccountManager.Ins().SafetyPinOn(); //Email EmailErrorOut(log); //WebErrorOut(log); if (_dtLastUpdated.AddMilliseconds(500) > DateTime.Now) { _log += String.Format("!!! {0}\r\n", log); return; } else { UpdateDelayedLog_Raw(); } StringPacket packet = new StringPacket(); packet.Encode(log); Object[] pList = { packet, System.EventArgs.Empty }; if (CommandForm.IsReady) { CommandForm.Ins().BeginInvoke(new System.EventHandler(CommandForm.Ins().Error), pList); } }
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 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 void AddCommand(StringPacket packet) { // 아무곳에서나 불러도 된다. 다만 ScheduleManager의 lock을 잡고 있지 않은 상태라면 lock (locker) { _commands.Enqueue(packet); } }
public SweepUnitPOrder(StringPacket sp) { Code = sp.Decode(); ReqCount = sp.DecodeLong(); ReqPrice = sp.DecodeDouble(); ContractedCount = sp.DecodeLong(); _State = sp.Decode(); }
public override void UpdateUI(String strategyName, StringPacket sp) { try { String command = sp.Decode(); } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }
public void EncodeStringPacket(ref StringPacket sp) { int count = GetCount(); sp.Encode(count); foreach (String code in _longPOrders.Keys) { if (_shortPOrders.ContainsKey(code)) { double bidPrice = _longPOrders[code].GetMax(); double askPrice = _shortPOrders[code].GetMin(); Boolean bLegal = true; if (bidPrice >= askPrice) { bLegal = false; } sp.Encode(code); sp.Encode(askPrice); sp.Encode(bidPrice); sp.Encode(bLegal.ToString()); } else { double bidPrice = _longPOrders[code].GetMax(); double askPrice = double.MinValue; Boolean bLegal = true; sp.Encode(code); sp.Encode(askPrice); sp.Encode(bidPrice); sp.Encode(bLegal.ToString()); } } foreach (String code in _shortPOrders.Keys) { if (!_longPOrders.ContainsKey(code)) { double bidPrice = double.MaxValue; double askPrice = _shortPOrders[code].GetMin(); Boolean bLegal = true; sp.Encode(code); sp.Encode(askPrice); sp.Encode(bidPrice); sp.Encode(bLegal.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); 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; }
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)); } }
private void button1_Click(object sender, EventArgs e) { //새로고침 try { StringPacket sp = new StringPacket(); sp.Encode(Const.COMMAND_HANDLE_LEGAL_PRICE_CHECKER); sp.Encode(Const.LOAD_PRODUCTS); ScheduleManager.Ins().AddCommand(sp); } catch (System.Exception ex) { logger.Warn(ex.ToString()); } }
public static void GetSweepUnitRow(SweepUnit_OE_WithFuture bes, ref StringPacket sp) { sp.Encode(bes.OT.KOI.Code); sp.Encode(bes.GetSignedContractedCountOfRealOrdersFO()); sp.Encode(bes._State.ToString()); sp.Encode(bes.RealOrders.Count); for (int i = 0; i < bes.RealOrders.Count; ++i) { POrder o = bes.RealOrders[i] as POrder; sp.Encode(o.Code); sp.Encode(o.GetSignedReqCount()); sp.Encode(o.ReqPrice); sp.Encode(o.GetSignedContractedCount()); sp.Encode(o.GetState()); } }
private void button2_Click(object sender, EventArgs e) { //Feed try { StringPacket sp = new StringPacket(); sp.Encode(Const.COMMAND_FEED_RMD); String rmdText = textJsonText.Text; _logs.Add(rmdText); sp.Encode(rmdText); ScheduleManager.Ins().AddCommand(sp); } 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()); } }
private void button1_Click(object sender, EventArgs e) { try { // 주문하기 String strategyName = _strategyName; StringPacket sp = new StringPacket(); sp.Encode(Const.COMMAND_HANDLE_STRATEGY_COMMAND); sp.Encode(strategyName); sp.Encode(StrategyCommand.REQUEST_ELW_OOR_ORDERS); ScheduleManager.Ins().AddCommand(sp); } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
public void AddCommand(String line) { if (line.ToUpper().CompareTo("QUIT") == 0) { ScheduleManager.KillProcess(); } line = line.Trim(); if (line.Length == 0) { return; } line = line.Replace(" ", "|"); StringPacket sp = new StringPacket(); sp.Encode(line); ScheduleManager.Ins().AddCommand(sp); }
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 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()); } }
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; } }
private void button2_Click(object sender, EventArgs e) { //change try { String jsonText = GetJsonText(); if (jsonText.Length == 0) { return; } StringPacket sp = new StringPacket(); sp.Encode(Const.COMMAND_SIM_KRX_POLICY_CHANGE); sp.Encode(jsonText); ScheduleManager.Ins().AddCommand(sp); } 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; }
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"); } }
public void EncodeStringPacket(ref StringPacket sp) { List<ElwArbSweepUnit> liveEoss = new List<ElwArbSweepUnit>(); foreach (String key in _lives.Keys) { List<ElwArbSweepUnit> arr = _lives[key]; foreach (ElwArbSweepUnit eos in arr) { liveEoss.Add(eos); } } sp.Encode(liveEoss.Count); foreach (ElwArbSweepUnit eos in liveEoss) { eos.EncodeStringPacket(ref sp); } List<ElwArbSweepUnit> doneEoss = new List<ElwArbSweepUnit>(); foreach (String key in _dones.Keys) { List<ElwArbSweepUnit> arr = _dones[key]; foreach (ElwArbSweepUnit eos in arr) { doneEoss.Add(eos); } } sp.Encode(doneEoss.Count); foreach (ElwArbSweepUnit eos in doneEoss) { eos.EncodeStringPacket(ref sp); } }
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 void Encode(StringPacket packet) { _strPacket = _strPacket + packet._strPacket; }