// account의 준비를 도와주는 클래스이다. public PB_WorkingOrderLoader(String accountName, String password, Account.OrderLineType pt) { _accountName = accountName; _password = password; _pt = pt; // 객체생성 _bizServer = new BizConcServer(); _IBizConcServerEvents_ReceiveResultEventHandler _bizServerEvent = new _IBizConcServerEvents_ReceiveResultEventHandler(_bizServer_ReceiveResult); _bizServer.ReceiveResult += _bizServerEvent; if (_pt == Account.OrderLineType.StockSpotLine) { _bizServer.SetViewType(cSTOCK_UNITY, cDT_OUTTYPE_NOTCONT); // 미체결 _bizServer.AddRepeatDataAll(); _bizServer.SendReceive(_accountName, _password); } else if (_pt == Account.OrderLineType.FutureOptionSpreadLine) { _bizServer.SetViewType(cFUTOPT_UNITY, cDT_OUTTYPE_NOTCONT); // 미체결 _bizServer.AddRepeatDataAll(); _bizServer.SendReceive(_accountName, _password); } else { logger.Error("AccountReadyHelper constructor error"); Util.KillWithNotice("AccountReadyHelper constructor error"); } }
public SweepUnit_OE( POrder goalOrder, Account accountFO, Account accountSpot, OptionTribe ot, ISweeper parent, Boolean bConservativeOptionPolicyOn, int muteSec) { ID = SweepUnitIDManager.NextID++; _parent = parent; GoalOrder = goalOrder; RealOrders = new List<POrder>(); _ot = ot; _mute = new Timer(muteSec, ""); // 2초 _candidateCodes = ElwOptionUtil.GetSameCandidateCodes(goalOrder.Code); _accountSpot = accountSpot; _accountFO = accountFO; _bConservativeOptionPolicyOn = bConservativeOptionPolicyOn; if (!RequestInitOrder()) { GoalOrder.Free(); } _State = State._1_MuteFewSecs; ShowState(); }
public SweepUnit_FO( long signedGoalCountFO, String code, double initEnterPrice, POrder initOrder, Account accountFO, ISweeper parent, int muteSec) { this.ID = SweepUnitIDManager.NextID++; this.InitEnterPrice = initEnterPrice; this.InitSignedGoalCount = this.CurSignedTargetCount = signedGoalCountFO; this.Code = code; this._initOrder = initOrder; this.AccountFO = accountFO; this._parent = parent; this._muteSec = muteSec; this.InitLongShort = InitSignedGoalCount > 0 ? TradingDirection.Long : TradingDirection.Short; this._mute = new Timer(muteSec, ""); this._bResumed = false; this._bCompleteQuickly = false; this.RealOrders = new List<POrder>(); RequestInitOrder(); }
public PBHTS(Account account) { this.AccountName = account.AccountName; this.Password = account.Password; this._account = account; this.PT = account.LineType; _arhr = new PB_RemainLoader(this.AccountName, this.Password, this._account, this.PT); _bizServerContract = new BizConcServer(); if (PT == Account.OrderLineType.FutureOptionSpreadLine) { _bizServerContract.SetViewType(cFUTOPT_UNITY, cDT_OUTTYPE_CONTRACT); } else if (PT == Account.OrderLineType.StockSpotLine) { _bizServerContract.SetViewType(cSTOCK_UNITY, cDT_OUTTYPE_CONTRACT); } else { logger.Error("Unknown pt ({0})", PT); Util.KillWithNotice("Unknown pt"); } _bizServerContract.ReceiveDTReal += new _IBizConcServerEvents_ReceiveDTRealEventHandler(ReceiveDTRealEventHandler); _bizServerContract.AddRepeatByIndex((int)KSCDCCOMSvrDllLib.FO_BIZCONC_REPEAT_IDL.FO_BZCONT_ORDERNUM); _bizServerContract.SetManualUpdate(true); _bizServerContract.SendReceive(this.AccountName, this.Password); OrderServerPOrderCount = 128; CreateOrderServerPOrderCount(OrderServerPOrderCount); InitRemainPOrdersBlocking(); }
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 Dictionary<String, long> GetBlocksLB(List<String> candidateCodes, Account account) { Dictionary<String, long> codes = new Dictionary<string, long>(); foreach (String code in candidateCodes) { Detail.ProductType dpt = ProductUtil.Ins().GetProductType(code); if (dpt == Detail.ProductType.ELW || dpt == Detail.ProductType.Stock) { long possibleShortCount = account.GetMaxPossibleShortCount_Fast(code); if (possibleShortCount > 0) { long count = possibleShortCount; codes.Add(code, count); } } else if (dpt == Detail.ProductType.CallOption || dpt == Detail.ProductType.PutOption || dpt == Detail.ProductType.KospiFuture) { codes.Add(code, long.MaxValue / 2); } else { Trace.Assert(false); } } return codes; }
void InitDefaultInfos( STR_Door_Input input, String strategyName, Account elwAccount, Account optionAccount, MonitorLimit_Time_And_MarketData monitorLimit) { // 1. set member variables this.Input = input; this._accountNames.Add(elwAccount.AccountName); this._accountNames.Add(optionAccount.AccountName); this._strategyName = strategyName; this.ElwAccount = elwAccount; this.OptionAccount = optionAccount; this.MonitorLimit = monitorLimit; List<Account> accounts = new List<Account>(); accounts.Add(this.ElwAccount); accounts.Add(this.OptionAccount); // 2. Set Agent this._agent = new Agent(this, accounts); // 3. Set Order Limit IOrderLimit orderLimitFO = CreateOrderLimit_FO(); IOrderLimit orderLimitELW = CreateOrderLimit_ELW(); this.OptionAccount.SetOrderLimit(orderLimitFO); this.OptionAccount.SetOrderLimitEmptyRMD(orderLimitFO); this.ElwAccount.SetOrderLimit(orderLimitELW); this.ElwAccount.SetOrderLimitEmptyRMD(orderLimitELW); }
public MonitorEnter_BondArb(StrategyNode node) { this._node = node; STR_Arb root = node.Root as STR_Arb; this._bondAccount = root.BondAccount; }
//public Boolean IsValidUpDownRange(RawMarketData rmdFuture) //{ // double upPrice = kfi.YesterdayLastPrice + 0.7 * (kfi.UpLimit - kfi.YesterdayLastPrice); // double downPrice = kfi.YesterdayLastPrice - 0.7 * (kfi.YesterdayLastPrice - kfi.DownLimit); // if (rmdFuture.CurPrice < upPrice && rmdFuture.CurPrice > downPrice) // { // return true; // } // return false; //} public OptionContOORData(String code, double enterValue, Account account, IOOR_Product optionProduct) { Code = code; EnterValue = enterValue; _Account = account; TradingOrders = new ArrayList(); CancelOrders = new ArrayList(); OptionProduct = optionProduct; }
public Account(String accountName, String password, Account.OrderLineType pt, String htsType) { AccountName = accountName; Password = password; LineType = pt; this.LongBlockManager = new POrderLongBlockManager(); Hts = HtsGenerator.Generate(htsType, this); }
public Test_PB_HTSSweeper( POrder o, Account accountFO, STR_Test_PB_Fut_HTS parent) { _parent = parent; InitSweepUnit_FO(o, accountFO); }
public SweepUnit_FO( long signedGoalCountFO, String code, double initEnterPrice, POrder initOrder, Account accountFO, ISweeper parent) : this(signedGoalCountFO, code, initEnterPrice, initOrder, accountFO, parent, 2) { }
public STR_Door( STR_Door_Input input, String strategyName, Account elwAccount, Account optionAccount, MonitorLimit_Time_And_MarketData monitorLimit) { InitDefaultInfos(input, strategyName, elwAccount, optionAccount, monitorLimit); InitController(); }
public SweepUnit_OE( POrder goalOrder, Account accountFO, Account accountSpot, OptionTribe ot, ISweeper parent, Boolean bConservativeOptionPolicyOn) : this(goalOrder, accountFO, accountSpot, ot, parent, true, 2) { }
public static void ClearBondAccount(Account account) { Account_Accessor accessor = new Account_Accessor(new PrivateObject(account)); ClearOrders(accessor._completeOrders); ClearOrders(accessor._inProgressOrders); ClearOrders(accessor._requestOrders); ForcedClearPOrderBidAskManager(); }
public POrder( TradingDirection longShort, String code, long reqCount, double reqPrice, Account account, RawMarketData rmdClone) : this(longShort, code, reqCount, reqPrice, account, rmdClone, MarketType._3_Default, false) { }
public PB_RemainLoader_FO(String accountName, String password, Account account) { _account = account; _accountName = accountName; _password = password; // 객체생성 _bizServer = new BizConcServer(); _IBizConcServerEvents_ReceiveResultEventHandler _bizServerEvent = new _IBizConcServerEvents_ReceiveResultEventHandler(_bizServer_ReceiveResult); _bizServer.ReceiveResult += _bizServerEvent; }
public POrderLongBlock( String code, String codeNoTail, long count, Account account) { this.Code = code; this.CodeNoTail = codeNoTail; this.Count = count; this._Account = account; }
public POrder( TradingDirection longShort, String code, long reqCount, double reqPrice, Account account, RawMarketData rmdClone, MarketType market, Boolean bWeakLongBlock) { this.LongShort = longShort; this.Code = code; this.ReqCount = reqCount; this.ReqPrice = reqPrice; this.TargetAccount = account; this.RMDClone = rmdClone.Clone() as RawMarketData; // 밖에서도 열심히 했겠지만 최종적으로 Clone을 저장하도록 한다. this.Market = market; this.IsWeakLongBlock = bWeakLongBlock; this.InitReqPrice = reqPrice; this.ContractedCount = 0; this.CanceledCount = 0; this.OrderNumber = -1; this.AvgContractPrice = 0; this.IsAllocatedYetRequestOrFree = true; this.CreatedTime = DateTime.Now; this.NoErrorOrderIn = false; this.Comment = ""; this.ShortCutTargetOfContractCallBack = null; this.EarlyUpdatedLongBlockCount = 0; _bGotLastPacket = false; // dependency가 있음(SetMarketType, SetcodeNoTail, SetLongBlock) Boolean bSuccess1 = SetMarketType(); Boolean bSuccess2 = SetCodeNoTail(bSuccess1); ConvertOverPriceToInRMDPriceIfNotZero(); SetLongBlock(bSuccess2); POrderManager.Ins().Add(this); ValidateInput(); }
public PositionTakerController(String code, TradingDirection longShort, long targetCount, double targetPrice, Account targetAccount) { this.Code = code; this.LongShort = longShort; this.UnsignedTargetCount = targetCount; this.TargetPrice = targetPrice; this.RepeatCount = 0; this.Orders = new List<POrder>(); this.TargetAccount = targetAccount; // 여기서 주문까지 쏴버린다. PTState = new S1_RequestOrder_PositionTakerState(this); }
public ElwArbReadyOrder(Account elwAccount, Account optionAccount) { try { this._elwAccount = elwAccount; this._optionAccount = optionAccount; List<double> strikes = OptionUtil.GetSortedStrikeList(CallPutFlag.Call); OptionTribe ot = null; foreach (double strike in strikes) { ot = ElwOptionUtil.GetOptionTribe(strike, CallPutFlag.Call); if (ot != null && ot.ElwInfos.Count > 0) { break; } } if (ot == null) { logger.Error("option tribe does not exist in ElwArbreadyOrder"); Util.KillWithNotice("option tribe does not exist in ElwArbreadyOrder"); } this._elwInfo = ot.ElwInfos[0]; if (this._elwInfo == null) { logger.Error("elw info does not exist in ElwArbreadyOrder"); Util.KillWithNotice("elw info does not exist in ElwArbreadyOrder"); } this._koi = ElwOptionUtil.GetKOIFromElwInfo(_elwInfo); if (this._koi == null) { logger.Error("koi info does not exist in ElwArbreadyOrder"); Util.KillWithNotice("koi info does not exist in ElwArbreadyOrder"); } this._elwLongPrice = 5; this._koiShortPrice = this._koi.UpLimit; } catch (System.Exception ex) { logger.Error(ex.ToString()); Util.KillWithNotice(ex.ToString()); } }
// account의 준비를 도와주는 클래스이다. public PB_RemainLoader(String accountName, String password, Account account, Account.OrderLineType pt) { if (pt == Account.OrderLineType.FutureOptionSpreadLine) { _context = new PB_RemainLoader_FO(accountName, password, account); } else if (pt == Account.OrderLineType.StockSpotLine) { _context = new PB_RemainLoader_Spot(accountName, password, account); } else { logger.Error("Invalid pt"); Util.KillWithNotice("Invalid pt"); } }
public Test_PB_HTS_MonitorEnter(StrategyNode node) { this.IsPermissionOK = false; this._node = node; this._monitorLimit = new MonitorLimit_LastUpdatedRmd(); String fut1 = KospiFutureUtil.Ins().KFSI.FutureCode1; _referenceRmdFut1 = RmdManager.Ins().GetData(fut1); _referenceRmdFut1List = new List<RawMarketData>(); _referenceRmdFut1List.Add(_referenceRmdFut1); _root = node.Root as STR_Test_PB_Fut_HTS; _futureAccount = _root.FutureAccount; }
public static void MyClassInitialize(TestContext testContext) { // 선물, 옵션, Elw 상품 정보를 CP에서 읽어오고 config를 설정한다. ConfigManager.Ins().Initialize("c:\\UnittestMadViper\\config.txt"); DB_DataLoader_Kospi_Future.Ins().Load(); DB_DataLoader_Option.Ins().Load(); DB_DataLoader_Elw.Ins().Load(); // 각각의 OrderLimit이 decorator pattern을 잘 지키고 있는지를 테스트 하기 위해서 TestDummy를 root로 설정하여 // 테스트를 진행한다. OrderLimitPassTestDummy dummy = new OrderLimitPassTestDummy(); g_ol_with_dummy = new ValuePerOnceOrderLimit(kValuePerOnce, dummy); g_account_fo = AccountManager.Ins().CreateSimFOAccount(); g_default_orderlimit = new DefaultOrderLimit(g_account_fo); g_ol_with_default = new ValuePerOnceOrderLimit(kValuePerOnce, g_default_orderlimit); }
static IHTS GetKBHts(Account account) { //ugly int realKB = Convert.ToInt32( Util.RemoveComma(ConfigManager.Ins().Config.GetValue(ConfigKeyConst.KB_REAL))); Boolean bReal = true; if (realKB == 0) { bReal = false; } else { bReal = true; } return new KBHTS(account, bReal); }
public static ElwOptionArbData GetElwOptionArbData( ElwInfo elw, RawMarketData rmdElw, KospiOptionInfo kospiOptionInfo, RawMarketData rmdOption, long maxCountOfOptionPerOnce, double maxValueOfOptionPerOnce, Account optionAccount, Account elwAccount, Boolean bForward, Boolean bAgressiveReverseOn, long totalAttemptOptionCount) { PreData data = GetPreData( elw, rmdElw, kospiOptionInfo, rmdOption, maxCountOfOptionPerOnce, maxValueOfOptionPerOnce, optionAccount, elwAccount, bForward, bAgressiveReverseOn, totalAttemptOptionCount); { ElwOptionArbData eoad = GetElwOptionArbData_WithProfit(data); if (eoad != null) { return eoad; } } { ElwOptionArbData eoad = GetElwOptionArbData_WO_Profit(data); if (eoad != null) { return eoad; } } return null; }
public SweepUnitContext_FO( long signedGoalCountFO, String code, double initEnterPrice, POrder initOrder, Account accountFO, ISweeper sweeper) { this.RealOrders = new List<POrder>(); this.ID = SweepUnitIDManager.NextID++; this.InitSignedGoalCount = this.CurSignedTargetCount = signedGoalCountFO; this.Code = code; this._initEnterPrice = initEnterPrice; this._initOrder = initOrder; this.AccountFO = accountFO; this._sweeper = sweeper; }
public MonitorEnter_CalFut( StrategyNode node, Detail.ProductType pt, String fut1, String spread, String fut2, ForwardBackward fb) { this._node = node; IMarketDataBoard board = null; switch (pt) { case Detail.ProductType.KospiFuture: board = RmdManager.Ins().KospiFuture; break; case Detail.ProductType.UsdFuture: board = RmdManager.Ins().Future; break; case Detail.ProductType.KtbFuture: board = RmdManager.Ins().Future; break; default: String errorMsg = String.Format("{0} is not valid type", pt); logger.Error(errorMsg); Util.KillWithNotice(errorMsg); break; } _refRmdFut1 = board.GetData(fut1); _refRmdSpread = board.GetData(spread); _refRmdFut2 = board.GetData(fut2); _referenceRmds.Add(_refRmdFut1); _referenceRmds.Add(_refRmdSpread); _referenceRmds.Add(_refRmdFut2); STR_Arb root = node.Root as STR_Arb; _futureAccount = root.FutureAccount; }
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()); } }