- 매수주문 호가 단위로

This commit is contained in:
2017-02-09 15:24:37 +09:00
parent 31791b2dd7
commit 231b0d48ca
3 changed files with 132 additions and 113 deletions

View File

@@ -162,6 +162,27 @@ namespace NewsCrawler
}
}
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 iMaxPrice)
{
if(m_bInitialized == false)
@@ -172,21 +193,22 @@ namespace NewsCrawler
try
{
int iCurPrice = GetCurPrice(Code);
iCurPrice = (int)(iCurPrice*1.015);
int iCount = iMaxPrice/iCurPrice;
int iCallValue = GetCallUnitValue((int)(iCurPrice*1.015));
int iCount = iMaxPrice/iCallValue;
m_CP0311.SetInputValue(0, 2);
m_CP0311.SetInputValue(1, Config.GetAccount());
m_CP0311.SetInputValue(2, Config.GetSubAccount());
m_CP0311.SetInputValue(3, Code.m_strCode);
m_CP0311.SetInputValue(4, iCount);
m_CP0311.SetInputValue(5, iCurPrice);
m_CP0311.SetInputValue(5, iCallValue);
m_CP0311.SetInputValue(7, "01");
m_CP0311.SetInputValue(8, "01");
m_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}원, 지정가 IOC 매수", Code.ToString(), iCount, iCallValue));
}
catch(Exception ex)
{