- 마감 전 청산
- 미체결 취소 버튼 - TR lock
This commit is contained in:
@@ -14,6 +14,7 @@ namespace AutoSellerNS
|
||||
AutoSeller m_Listener = null;
|
||||
|
||||
CPUTILLib.CpCybos m_CPCybos = new CPUTILLib.CpCybos();
|
||||
CPUTILLib.CpCodeMgr m_CPCodeMgr = new CPUTILLib.CpCodeMgr();
|
||||
CPFORETRADELib.CpForeTdUtil m_CPUtil = new CPFORETRADELib.CpForeTdUtil();
|
||||
DSCBO1Lib.CpConclusion m_CpConclusion = new DSCBO1Lib.CpConclusion();
|
||||
|
||||
@@ -28,6 +29,10 @@ namespace AutoSellerNS
|
||||
|
||||
ConcurrentDictionary<string, int> m_SellingCode = new ConcurrentDictionary<string, int>();
|
||||
ConcurrentDictionary<int, string> m_ItemsInCorrection = new ConcurrentDictionary<int, string>();
|
||||
ConcurrentQueue<CPTRADELib.ICpTdDib> m_TRQueue = new ConcurrentQueue<CPTRADELib.ICpTdDib>();
|
||||
|
||||
DateTime m_MarketStartTime;
|
||||
DateTime m_MarketEndTime;
|
||||
|
||||
public CybosHelper(AutoSeller Listener)
|
||||
{
|
||||
@@ -65,7 +70,14 @@ namespace AutoSellerNS
|
||||
m_Listener.SetAccountList(m_CPUtil.AccountNumber);
|
||||
m_CpConclusion.Received += CpConclusion_Received;
|
||||
m_CpConclusion.Subscribe();
|
||||
}
|
||||
|
||||
int iStartTime = (int)m_CPCodeMgr.GetMarketStartTime();
|
||||
int iEndTime = (int)m_CPCodeMgr.GetMarketEndTime();
|
||||
|
||||
m_MarketStartTime = DateTime.Parse(string.Format("{0:00}:{1:00}:{2:00}", iStartTime/100, iStartTime%100, 0));
|
||||
m_MarketEndTime = DateTime.Parse(string.Format("{0:00}:{1:00}:{2:00}", iEndTime / 100, iEndTime % 100, 0));
|
||||
|
||||
}
|
||||
|
||||
public async Task InitCybosAsync()
|
||||
{
|
||||
@@ -118,23 +130,32 @@ namespace AutoSellerNS
|
||||
}
|
||||
}
|
||||
|
||||
int iTdDibWaitCnt = 0;
|
||||
ConcurrentQueue<CPTRADELib.ICpTdDib> m_TRQueue = new ConcurrentQueue<CPTRADELib.ICpTdDib>();
|
||||
void BlockRequestTRProc()
|
||||
{
|
||||
if (m_TRQueue.Count == 0)
|
||||
return;
|
||||
|
||||
lock (m_RequestTRLock)
|
||||
{
|
||||
CPTRADELib.ICpTdDib tr;
|
||||
bool bContinue = true;
|
||||
while (bContinue == true && m_TRQueue.TryDequeue(out tr) == true && GetLimitRemainCountTrade() > 0)
|
||||
{
|
||||
var ret = tr.BlockRequest2(0);
|
||||
if (ret == -1)
|
||||
Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest TR 오류");
|
||||
else if (ret == 1)
|
||||
Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest TR 수신대기");
|
||||
bContinue = (ret == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
//int iTdDibWaitCnt = 0;
|
||||
void BlockRequest(CPTRADELib.ICpTdDib dib)
|
||||
{
|
||||
m_TRQueue.Enqueue(dib);
|
||||
|
||||
CPTRADELib.ICpTdDib tr;
|
||||
bool bContinue = true;
|
||||
while(bContinue == true && m_TRQueue.TryDequeue(out tr) == true)
|
||||
{
|
||||
var ret = tr.BlockRequest2(0);
|
||||
if (ret == -1)
|
||||
Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest TR 오류");
|
||||
else if (ret == 1)
|
||||
Util.Log(Util.LOG_TYPE.DEBUG, "BlockRequest TR 수신대기");
|
||||
bContinue = (ret == 0);
|
||||
}
|
||||
BlockRequestTRProc();
|
||||
|
||||
////lock (m_RequestTRLock)
|
||||
//{
|
||||
@@ -458,6 +479,16 @@ namespace AutoSellerNS
|
||||
return (iValue/iUnit)*iUnit;
|
||||
}
|
||||
|
||||
public DateTime GetMarketStartTime()
|
||||
{
|
||||
return m_MarketStartTime;
|
||||
}
|
||||
|
||||
public DateTime GetMarketEndTime()
|
||||
{
|
||||
return m_MarketEndTime;
|
||||
}
|
||||
|
||||
public async Task SellItem(string strCode, int iCnt, int iAskPrice)
|
||||
{
|
||||
if (iCnt <= 0 || m_SellingCode.ContainsKey(strCode) == true)
|
||||
@@ -486,9 +517,11 @@ namespace AutoSellerNS
|
||||
|
||||
public async Task SellItem(string strCode, int iCnt)
|
||||
{
|
||||
if (iCnt <= 0)
|
||||
if (iCnt <= 0 || m_SellingCode.ContainsKey(strCode) == true)
|
||||
return;
|
||||
|
||||
m_SellingCode.TryAdd(strCode, 0);
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
CPTRADELib.CpTd0311 Td0311 = new CPTRADELib.CpTd0311();
|
||||
@@ -499,6 +532,9 @@ namespace AutoSellerNS
|
||||
Td0311.SetInputValue(4, iCnt);
|
||||
Td0311.SetInputValue(8, "03");
|
||||
BlockRequest(Td0311);
|
||||
|
||||
int val;
|
||||
m_SellingCode.TryRemove(strCode, out val);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user