diff --git a/CybosHelper.cs b/CybosHelper.cs index e7df72d..85d06af 100644 --- a/CybosHelper.cs +++ b/CybosHelper.cs @@ -105,6 +105,27 @@ namespace VICrawlerNS m_Listener.OnReceivedEvent(uiTime, strCode, uiEventCode, strDesc, cUpDown=='U'); } + int GetCallUnitValue(int iValue) + { + int iUnit = 1; + if(iValue < 1000) + iUnit = 1; + else if(iValue < 5000) + iUnit = 5; + else if(iValue < 10000) + iUnit = 10; + else if(iValue < 50000) + iUnit = 50; + else if(iValue < 100000) + iUnit = 100; + else if(iValue < 500000) + iUnit = 500; + else + iUnit = 1000; + + return (iValue/iUnit)*iUnit; + } + public void Buy(CodeList.CODE_VALUE Code, int iBuyPrice) { try @@ -113,8 +134,8 @@ namespace VICrawlerNS CPStockMst.SetInputValue(0, Code.m_strCode); CPStockMst.BlockRequest2(0); int iCurPrice = CPStockMst.GetHeaderValue(11); - iCurPrice = (int)(iCurPrice*1.015); - int iCount = iBuyPrice/iCurPrice; + int iCallValue = GetCallUnitValue((int)(iCurPrice*1.015)); + int iCount = iBuyPrice/iCallValue; CPTRADELib.CpTd0311 CP0311 = new CPTRADELib.CpTd0311(); CP0311.SetInputValue(0, 2); @@ -122,12 +143,12 @@ namespace VICrawlerNS CP0311.SetInputValue(2, Config.GetSubAccount()); CP0311.SetInputValue(3, Code.m_strCode); CP0311.SetInputValue(4, iCount); - CP0311.SetInputValue(5, iCurPrice); + CP0311.SetInputValue(5, iCallValue); CP0311.SetInputValue(7, "01"); CP0311.SetInputValue(8, "01"); CP0311.BlockRequest2(1); - Util.Log(Util.LOG_TYPE.BUY, string.Format("code:{0} {1}주 현재가 {2}원, 지정가 매수", Code.ToString(), iCount, iCurPrice)); + Util.Log(Util.LOG_TYPE.BUY, string.Format("code:{0} {1}주 현재가 {2}원, 지정가 {3} IOC 매수", Code.ToString(), iCount, iCurPrice, iCallValue)); } catch(Exception ex) {