- 트레일링 매도 추가

This commit is contained in:
2017-02-01 09:43:04 +09:00
parent da9a59622b
commit 1d43655567
4 changed files with 339 additions and 158 deletions

View File

@@ -13,6 +13,7 @@ namespace AutoSellerNS
public AutoSeller m_Listener = null;
public CybosHelper m_CybosHelper = null;
public string m_strCode;
public string m_strCodeName;
public DSCBO1Lib.StockCur m_StockCur = null;
public DSCBO1Lib.StockJpbid m_Jpbid = null;
public int[] m_aiBidPrice = new int[10];
@@ -24,9 +25,14 @@ namespace AutoSellerNS
public int m_iMaxPrice = 0;
public int m_iCheckCount = 0;
public int m_iTrailingCount = 0;
public void OnRecievedPrice()
{
m_iCurPrice = m_StockCur.GetHeaderValue(13);
if(m_iCurPrice > m_iMaxPrice)
m_iTrailingCount = 0;
m_iMaxPrice = Math.Max(m_iCurPrice, m_iMaxPrice);
int iAskPrice = m_StockCur.GetHeaderValue(7);
@@ -36,8 +42,19 @@ namespace AutoSellerNS
else
m_iCheckCount = 0;
if (m_iCheckCount >= Config.GetBidCount() && m_Listener.IsSelling() == true)
if(m_iCheckCount >= Config.GetBidCount() && m_Listener.IsSelling() == true)
{
m_CybosHelper.SellItem(m_strCode, m_iCurPrice, m_Listener.GetSellableCount(m_strCode));
Util.Log(Util.LOG_TYPE.SELL, string.Format("[조건 완료 매도] {0} ({1}회)", m_strCodeName, Config.GetBidCount()));
}
if(m_iCurPrice < (m_iMaxPrice*(100.0f-Config.GetTrailingRate())/100.0f))
m_iTrailingCount++;
if(m_iTrailingCount >= Config.GetTrailingCnt() && m_Listener.IsSelling() == true)
{
m_CybosHelper.SellItem(m_strCode, m_iCurPrice, m_Listener.GetSellableCount(m_strCode));
Util.Log(Util.LOG_TYPE.SELL, string.Format("[트레일링 매도] {0} ({1}% {2}회)", m_strCodeName, Config.GetTrailingRate(), Config.GetTrailingCnt()));
}
m_Listener.OnReceivedCurPrice(m_strCode, m_iCurPrice, m_iMaxPrice, m_iCheckCount);
}
@@ -60,7 +77,7 @@ namespace AutoSellerNS
m_aiAskCount[i+5] = m_Jpbid.GetHeaderValue(29 + 4*i);
}
m_Listener.OnReceivedCall(m_strCode, m_aiBidPrice, m_aiBidCount, m_aiAskPrice, m_aiAskCount);
m_Listener.OnReceivedCall(m_strCode, 0, m_aiBidPrice, m_aiBidCount, m_aiAskPrice, m_aiAskCount);
}
}
@@ -128,21 +145,24 @@ namespace AutoSellerNS
AutoSeller.ITEM Item = new AutoSeller.ITEM();
Item.m_strCodeName = m_6033.GetDataValue(0, i);
Item.m_strCode = m_6033.GetDataValue(12, i);
Item.m_iItemCnt = m_6033.GetDataValue(7, i);
Item.m_iAssessedValue = m_6033.GetDataValue(9, i);
Item.m_iValuationGains = m_6033.GetDataValue(10, i);
Item.m_dYield = m_6033.GetDataValue(11, i);
Item.m_iAvailableQuantity = m_6033.GetDataValue(15, i);
Item.m_dBookUnitPrice = m_6033.GetDataValue(17, i);
Item.m_iProfitUnitPrice = m_6033.GetDataValue(18, i);
Item.m_iSellableCnt = m_6033.GetDataValue(15, i);
if(Item.m_strCodeName != "")
{
Item.m_strCode = m_6033.GetDataValue(12, i);
Item.m_iItemCnt = m_6033.GetDataValue(7, i);
Item.m_iAssessedValue = m_6033.GetDataValue(9, i);
Item.m_iValuationGains = m_6033.GetDataValue(10, i);
Item.m_dYield = m_6033.GetDataValue(11, i);
Item.m_iAvailableQuantity = m_6033.GetDataValue(15, i);
Item.m_dBookUnitPrice = m_6033.GetDataValue(17, i);
Item.m_iProfitUnitPrice = m_6033.GetDataValue(18, i);
Item.m_iSellableCnt = m_6033.GetDataValue(15, i);
if (strCodeList.Length > 0)
strCodeList += ",";
strCodeList += Item.m_strCode;
if(strCodeList.Length > 0)
strCodeList += ",";
strCodeList += Item.m_strCode;
aItems.Add(Item);
aItems.Add(Item);
}
}
if (strCodeList.Length > 0)
@@ -161,6 +181,20 @@ namespace AutoSellerNS
}
}
// sync
List<string> aRemoveKeys = new List<string>();
foreach(var Item in m_aStockCur)
{
if(aItems.Any(s => s.m_strCode == Item.Key) == false)
aRemoveKeys.Add(Item.Key);
}
foreach(var Key in aRemoveKeys)
{
m_aStockCur[Key].m_StockCur.Unsubscribe();
m_aStockCur[Key].m_Jpbid.Unsubscribe();
m_aStockCur.Remove(Key);
}
return aItems;
}
@@ -238,6 +272,7 @@ namespace AutoSellerNS
StockCur.m_Listener = m_Listener;
StockCur.m_CybosHelper = this;
StockCur.m_strCode = Item.m_strCode;
StockCur.m_strCodeName = Item.m_strCodeName;
StockCur.m_StockCur = new DSCBO1Lib.StockCur();
StockCur.m_StockCur.SetInputValue(0, Item.m_strCode);
StockCur.m_StockCur.Received += StockCur.OnRecievedPrice;