void RequestInitOrder(POrder goalOrder, List<POrder> realOrders) { POrder o = new POrder(goalOrder); o.AddComment(String.Format("EOS#({0}), GoalOrder", CurID)); o.SetAsLegalPrice(); o.ConvertOverPriceToInRMDPriceIfNotZero(); POrderUtil.RequestOrder(o, realOrders); }
void ReqOrderStepBehindPart(POrder goal, List<POrder> real, double targetExposurePercent, RawMarketData rmd) { double curExposurePercent = GetCurExposurePercent(goal, real); double diffExposure = targetExposurePercent - curExposurePercent; if (diffExposure <= 0) { return; } long goalCount = POrderUtil.GetSignedReqCount(goal); long reqCount = (long)(Math.Round(diffExposure * goalCount / 100, 0)); long curCount = POrderUtil.GetSignedMaxPossibleExposureCount(real); if (Math.Abs(goalCount) < Math.Abs(reqCount + curCount)) { //reqCount = goalCount - curCount; logger.Error("({0}, {1}, {2})", reqCount, goalCount, curCount); Util.KillWithNotice("error"); return; } if (reqCount != 0) { reqCount = Math.Abs(reqCount); if (goal.TargetAccount.LineType == Account.OrderLineType.StockSpotLine) { reqCount = ElwUtil.RoundElwCount(reqCount); } POrder o = new POrder( goal.LongShort, goal.Code, reqCount, goal.ReqPrice, goal.TargetAccount, rmd); o.AddComment(String.Format("EOS#({0}), StepBehindPart, {1}", CurID, o.Code)); o.SetAsLegalPrice(); o.ConvertOverPriceToInRMDPriceIfNotZero(); POrderUtil.RequestOrder(o, real); } }
Boolean MakeOrder_Raw(RawMarketData rmd, long remainCount100k, Dictionary<String, long> blocksLB, ref List<POrder> newOrders, ref String log) { if (remainCount100k == 0) { log += "remainCount100k == 0"; return true; } long signedRealCount = ElwOptionUtil.Convert100KToRealCount(rmd.Code, remainCount100k); if (signedRealCount == 0 || remainCount100k - ElwOptionUtil.ConvertRealToCount100k(rmd.Code, signedRealCount) != 0) { log += String.Format("signRealCount({0}) remainCount100k({1}) code({2})|", signedRealCount, remainCount100k, rmd.Code); return false; } long reqCount = Math.Abs(signedRealCount); TradingDirection ls = TradingDirection.Long; if (signedRealCount < 0) { ls = TradingDirection.Short; if (!blocksLB.ContainsKey(rmd.Code)) { log += String.Format("[22], {0}|", rmd.Code); return false; } if (blocksLB[rmd.Code] < Math.Abs(signedRealCount)) { log += String.Format("[23] BlockLB[{2}]({0}) < signedRealCount({1})", blocksLB[rmd.Code], signedRealCount, rmd.Code); return false; } reqCount = Math.Abs(signedRealCount); long tmp = ProductUtil.Ins().RoundProductCount(Math.Abs(reqCount), rmd.DPT); if (tmp != reqCount) { logger.Error("tmp({0}) != reqCount({1}) in MakeOrder_Raw", tmp, reqCount); Util.KillWithNotice("tmp != reqCount in MakeOrder_Raw"); } } Account account = _accountFO; if (rmd.DPT == Detail.ProductType.ELW || rmd.DPT == Detail.ProductType.Stock) { account = _accountSpot; } double price = ProductUtil.Ins().GetMidPrice(rmd); price = AdjustPrice(ls, rmd, price); POrder o = new POrder(ls, rmd.Code, reqCount, price, account, rmd); o.AddComment("SweepUnit_OE.MakeOrder_Raw"); log += String.Format("[23], {0}|", o.ToString()); if (o.ReqCount > 0) { // 여기서 Reserve하고 법적 문제가 있는지 확인한다. o.SetAsLegalPrice(); o.ConvertOverPriceToInRMDPriceIfNotZero(); log += String.Format("[24], {0}|", o.ToString()); newOrders.Add(o); } else { o.Free(); log += String.Format("[24], ReqCount <= 0"); return false; } long ret = remainCount100k - ElwOptionUtil.ConvertRealToCount100k(rmd.Code, signedRealCount); if (ret != 0) { logger.Error( "CRITICAL ERROR!!! in MakeOrder_Raw ret != 0 ret({0}), remainCount100k({1}), signedRealCount({2}), Code({3})", ret, remainCount100k, signedRealCount, rmd.Code); Util.KillWithNotice("CRITICAL ERROR!!! in MakeOrder_Raw"); return false; } return true; }
// 주문을 하고 정해놓은 컨테이너에 담는 역할을 수행한다. void RequestOrder_Raw(POrder order, List<POrder> container) { try { order.SetAsLegalPrice(); order.ConvertOverPriceToInRMDPriceIfNotZero(); Boolean bSuccess = true; if (order.TargetAccount.LineType == Account.OrderLineType.StockSpotLine) { Trace.Assert(false); } else if (order.TargetAccount.LineType == Account.OrderLineType.FutureOptionSpreadLine) { bSuccess = order.TargetAccount.RequestOrder(order); } else { logger.Error("{0} unsupported ProductType", order.TargetAccount.LineType); Util.KillWithNotice("unsupported ProductType"); Trace.Assert(false); } if (!bSuccess) { logger.Error(order.ToString()); Util.KillWithNotice(order.ToString()); _State = State._0_Exception; SoundManager.Ins().PlayExceptionSound(); ShowState(); } else { // 성공했으면 담는다. container.Add(order); } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
void RequestOrder_Raw(POrder order, List<POrder> container) { try { order.SetAsLegalPrice(); order.ConvertOverPriceToInRMDPriceIfNotZero(); Boolean bSuccess = true; bSuccess = order.TargetAccount.RequestOrder(order); if (!bSuccess) { logger.Error("{0} order error", order.ToString()); Util.KillWithNotice("order error"); _State = State._0_Exception; SoundManager.Ins().PlayExceptionSound(); ShowState(); } else { // 성공했으면 담는다. container.Add(order); } } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }