From c17e3b25c92d62f41c7d39b9bb04e48a7871d88f Mon Sep 17 00:00:00 2001 From: mjjo Date: Sat, 11 Feb 2017 13:26:42 +0900 Subject: [PATCH] =?UTF-8?q?-=20=EB=A7=A4=EC=88=98=20=EC=88=98=EC=A0=95=20(?= =?UTF-8?q?=ED=98=B8=EA=B0=80=20=EB=8B=A8=EC=9C=84=20=EC=A0=81=EC=9A=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CybosHelper.cs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) 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) {