public SweepUnitContext_Bond_Long( TradingDirection ls, BondPair pair, Account bondAccount, ISweeper sweeper) { this.ID = SweepUnitIDManager.NextID++; this.LongShort = ls; Trace.Assert(this.LongShort == TradingDirection.Long); this.InitSignedGoalCount = pair.Count; this.CurSignedTargetCount = pair.Count; this.EnterCode = pair.EnterCodeWithMarketType; this._initEnterPrice = pair.EnterPrice; this.BondAccount = bondAccount; this._enterMarketType = BondUtil.GetMarketType(pair.EnterCodeWithMarketType); this._sweeper = sweeper; CreateInitOrders(pair); this.RealOrdersLong = new List<POrder>(); ReadyBidAskCountDataForAllocate(pair); }
public SweepUnitContext_Bond_Short( TradingDirection ls, BondPair pair, Account bondAccount, ISweeper sweeper) { this.ID = SweepUnitIDManager.NextID++; this.LongShort = ls; Trace.Assert(this.LongShort == TradingDirection.Short); // -15 this.CurSignedTargetCount = pair.Count * (-1); this.EnterCode = pair.EnterCodeWithMarketType; this.PairCode = pair.PairCodeWithMarketType; this._initSweepPrice = pair.PairPrice; this.BondAccount = bondAccount; this._enterMarketType = BondUtil.GetMarketType(pair.EnterCodeWithMarketType); this._pairMarketType = BondUtil.GetMarketType(pair.PairCodeWithMarketType); this._sweeper = sweeper; this.RealOrdersShort = new List<POrder>(); }
public void AddPair(BondPair pair) { String key = GetKey(pair); String reverseKey = GetReverseKey(pair); if (!_keys.ContainsKey(key) && !_keys.ContainsKey(reverseKey)) { _keys.Add(key, key); _pairs.Add(pair); } }
public Sweeper_BondArb( BondPair pair, Account bondAccount) { try { this.ID = g_curID++; this._bStartWithSweeperMode = false; this.EnterCodeWithMarketType = pair.EnterCodeWithMarketType; this.PairCodeWithMarketType = pair.PairCodeWithMarketType; this.EnterPrice = pair.EnterPrice; this.PairPrice = pair.PairPrice; logger.Info("[Start BondArb Sweeper] #{0:n0}, '{1}' ({2:n0} -> {3:n0}) ({4:n0})", this.ID, BondUtil.GetCodeNoTail(this.EnterCodeWithMarketType), this.EnterPrice, this.PairPrice, pair.Count); SweepUnitContext_Bond_Long contextLong = new SweepUnitContext_Bond_Long(TradingDirection.Long, pair, bondAccount, this); _sweepUnitLong = new SweepUnitTemplate(contextLong, this, 5); _sweepUnitLong.CompleteCarefully(); SweepUnitContext_Bond_Short contextShort = new SweepUnitContext_Bond_Short(TradingDirection.Short, pair, bondAccount, this); _sweepUnitShort = new SweepUnitTemplate(contextShort, this, 5); _sweepUnitShort.CompleteCarefully(); } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
void SetHousingBondPairAndRmds(ref BondPair housingBondPair, ref RawMarketData rmdNormal, ref RawMarketData rmdSmall) { housingBondPair = BondPairManager.Ins().GetBondPair(_kHousingBondCode_Normal); RawMarketData rmd1 = RmdManager.Ins().BondSpot.GetData(housingBondPair.Code1); RawMarketData rmd2 = RmdManager.Ins().BondSpot.GetData(housingBondPair.Code2); rmdNormal = GetNormalRMD(rmd1, rmd2); rmdSmall = GetSmallRMD(rmd1, rmd2); }
void SetCreditBondPairAndRmds(ref BondPair bondPair, ref RawMarketData rmdNormal, ref RawMarketData rmdRetail) { bondPair = BondPairManager.Ins().GetBondPair(_kDoosanCode_Normal); RawMarketData rmd1 = RmdManager.Ins().BondSpot.GetData(bondPair.Code1); RawMarketData rmd2 = RmdManager.Ins().BondSpot.GetData(bondPair.Code2); rmdNormal = GetNormalRMD(rmd1, rmd2); rmdRetail = GetRetailRMD(rmd1, rmd2); }
private int CheckArbChance(BondPair pair) { return pair.CheckArbChance(this._bondAccount); }
void ReadyBidAskCountDataForAllocate(BondPair pair) { // 매수에 100개, 매도에 10개인 기회인 경우에 // 잘못하면 10개의 주문을 내고 매도쪽에 수량이 부족할 수가 있다. // 이런 경우를 막기 위해서 매도쪽도 같이 수량을 잡아주도록 한다. this._dummyShortOrderForReserveBidAskCount = new POrder( TradingDirection.Short, pair.PairCodeWithMarketType, Math.Abs(this.InitSignedGoalCount), pair.PairPrice, this.BondAccount, pair.GetSweeperRMD(), BondUtil.GetMarketType(pair.PairCodeWithMarketType), true); // 바로 취소 this._dummyShortOrderForReserveBidAskCount.OrderNumber = 0; this._dummyShortOrderForReserveBidAskCount.Update(0, 0, false); this._dummyShortOrderForReserveBidAskCount.UpdateCancelMessage(_dummyShortOrderForReserveBidAskCount.ReqCount); }
void CreateInitOrders(BondPair pair) { Trace.Assert(this.LongShort == TradingDirection.Long); LongShortCount lsc = new LongShortCount(pair.Count); List<long> reqCounts = GetReqCounts(lsc, this._enterMarketType); double reqPrice = this._initEnterPrice; TradingDirection ls = TradingDirection.Long; _initOrders = new List<POrder>(); foreach (long reqCount in reqCounts) { POrder o = new POrder(ls, this.EnterCode, reqCount, reqPrice, this.BondAccount, pair.GetEnterRMD(), BondUtil.GetMarketType(this.EnterCode), false); o.ShortCutTargetOfContractCallBack = this; _initOrders.Add(o); } }
String GetReverseKey(BondPair pair) { return String.Format("{1};{0}", pair.Code1, pair.Code2); }
String GetKey(BondPair pair) { return String.Format("{0};{1}", pair.Code1, pair.Code2); }
public List<BondPair> GetNewPairsAndDeleteNewArrival() { List<BondPair> pairs = new List<BondPair>(); List<RawMarketData> newArrival = new List<RawMarketData>(); lock (_bondLock) { if (_bondNewArrival.Count > 0) { newArrival.AddRange(_bondNewArrival); _bondNewArrival.Clear(); } } foreach (RawMarketData rmd in newArrival) { String shortCode = Util.GetBondShortCode(rmd.Code); RawMarketData rmdNormal = GetBondRmdNormal(shortCode); RawMarketData rmdRetail = GetBondRmdRetail(shortCode); RawMarketData rmdSmall = GetBondRmdSmall(shortCode); if (rmdNormal != null && rmdSmall != null) { BondPair tp = new BondPair(rmdNormal.Code, rmdSmall.Code, rmdNormal.Name); pairs.Add(tp); } else if (rmdNormal != null && rmdRetail != null) { BondPair tp = new BondPair(rmdNormal.Code, rmdRetail.Code, rmdNormal.Name); pairs.Add(tp); } else if (rmdRetail != null && rmdSmall != null) { BondPair tp = new BondPair(rmdRetail.Code, rmdSmall.Code, rmdRetail.Name); pairs.Add(tp); } } return pairs; }