- 시간 계산식 수정
- 보합 처리 추가
This commit is contained in:
74
MainForm.cs
74
MainForm.cs
@@ -275,10 +275,12 @@ namespace upper_limit_crawler
|
||||
|
||||
private void btMATest_Click(object sender, EventArgs e)
|
||||
{
|
||||
string strCode = "A010240";
|
||||
string strCodeName = "흥국";
|
||||
string strDate = "20160725";
|
||||
string strPrevDate = "20160722";
|
||||
Console.WriteLine("시뮬레이션 시작");
|
||||
|
||||
string strCode = "A096040";
|
||||
string strCodeName = "이트론";
|
||||
string strPrevDate = "20160725";
|
||||
string strDate = "20160726";
|
||||
|
||||
List<chart_data> DataList = new List<chart_data>();
|
||||
|
||||
@@ -331,11 +333,11 @@ namespace upper_limit_crawler
|
||||
|
||||
|
||||
|
||||
ULWatchItem item = new ULWatchItem();
|
||||
item.m_strCode = strCode;
|
||||
item.m_strCodeName = strCodeName;
|
||||
item.m_iCurPrice = 0;
|
||||
item.m_iPrevClosing = 0;
|
||||
ULWatchItem WatchItem = new ULWatchItem();
|
||||
WatchItem.m_strCode = strCode;
|
||||
WatchItem.m_strCodeName = strCodeName;
|
||||
WatchItem.m_iCurPrice = 0;
|
||||
WatchItem.m_iPrevClosing = 0;
|
||||
|
||||
ULBalanceDlg.OWN_ITEM OwnItem = new ULBalanceDlg.OWN_ITEM();
|
||||
|
||||
@@ -345,16 +347,16 @@ namespace upper_limit_crawler
|
||||
int iTime = data.iTime;
|
||||
int iCurPrice = data.iPrice;
|
||||
|
||||
if (item.m_iPrevClosing == 0)
|
||||
item.m_iPrevClosing = iPrevClosing;
|
||||
if (WatchItem.m_iPrevClosing == 0)
|
||||
WatchItem.m_iPrevClosing = iPrevClosing;
|
||||
|
||||
item.m_iCurPrice = iCurPrice;
|
||||
item.InsertPriceNode(iTime, iCurPrice);
|
||||
WatchItem.m_iCurPrice = iCurPrice;
|
||||
WatchItem.InsertPriceNode(iTime, iCurPrice);
|
||||
|
||||
if(OwnItem.m_iUnitBEP != 0)
|
||||
OwnItem.m_iMaxPrice = Math.Max(OwnItem.m_iMaxPrice, iCurPrice);
|
||||
|
||||
float fCompRate = item.m_iCurPrice / (float)item.m_iPrevClosing - 1.0f;
|
||||
float fCompRate = WatchItem.m_iCurPrice / (float)WatchItem.m_iPrevClosing - 1.0f;
|
||||
if (fCompRate >= m_DataMgr.m_Setting.m_fBidMin && fCompRate <= m_DataMgr.m_Setting.m_fBidMax)
|
||||
{
|
||||
if (m_DataMgr.IsInBlackList(iTime, strCode) == true)
|
||||
@@ -363,7 +365,7 @@ namespace upper_limit_crawler
|
||||
continue;
|
||||
}
|
||||
|
||||
float f5MASlope = item.GetPrev5MASlope(iTime);
|
||||
float f5MASlope = WatchItem.GetPrev5MASlope(iTime);
|
||||
if (f5MASlope <= 0)
|
||||
{
|
||||
//Console.WriteLine("[{0}] 조건 매수 실패. 5ma 상승하지 않음 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"));
|
||||
@@ -371,11 +373,13 @@ namespace upper_limit_crawler
|
||||
}
|
||||
|
||||
// bid and add to black list
|
||||
Console.WriteLine(string.Format("[{0}] [{1}] 조건 매수 {2}원 ({3}) (5MA slop:{4:0.00})", iTime, item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"), f5MASlope));
|
||||
ULUtil.TraceCSV("조건 매수", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"), f5MASlope);
|
||||
Console.WriteLine("[{0}] [{1}] 조건 매수 {2}원 ({3}) (5MA slop:{4:0.00})", iTime, WatchItem.m_strCodeName, WatchItem.m_iCurPrice, fCompRate.ToString("0.00%"), f5MASlope);
|
||||
ULUtil.TraceCSV("조건 매수", WatchItem.m_strCodeName, WatchItem.m_iCurPrice, fCompRate.ToString("0.00%"), f5MASlope);
|
||||
|
||||
OwnItem.m_iUnitBEP = iCurPrice;
|
||||
OwnItem.m_strCodeName = item.m_strCodeName;
|
||||
OwnItem.m_iUnitBEP = (OwnItem.m_iUnitBEP*OwnItem.m_iConclusionBalanceCnt + iCurPrice)/ (OwnItem.m_iConclusionBalanceCnt+1);
|
||||
OwnItem.m_iConclusionBalanceCnt++;
|
||||
|
||||
OwnItem.m_strCodeName = WatchItem.m_strCodeName;
|
||||
|
||||
//m_DataMgr.GetTrader().Buy(strCode, item.m_iCurPrice, (int)m_DataMgr.m_Setting.m_fBidAmount);
|
||||
m_DataMgr.AddBlackList(iTime, strCode);
|
||||
@@ -387,9 +391,10 @@ namespace upper_limit_crawler
|
||||
// loss cut
|
||||
if (iCurPrice <= OwnItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut))
|
||||
{
|
||||
Console.WriteLine(string.Format("[{0}] [{1}] 손절 {2}원 ({3}:{4})", iTime, OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%")));
|
||||
Console.WriteLine("[{0}] [{1}] 손절 {2}원 ({3}:{4})", iTime, OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"));
|
||||
ULUtil.TraceCSV("손절", OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"));
|
||||
OwnItem.m_iUnitBEP = 0;
|
||||
OwnItem.m_iConclusionBalanceCnt = 0;
|
||||
|
||||
//m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
//m_OwnList.Remove(OwnItem);
|
||||
@@ -402,28 +407,45 @@ namespace upper_limit_crawler
|
||||
// trailing
|
||||
else if (iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
{
|
||||
float f5MASlope = item.GetPrev5MASlope(iTime);
|
||||
float f5MASlope = WatchItem.GetPrev5MASlope(iTime);
|
||||
if (f5MASlope > 0)
|
||||
{
|
||||
//Console.WriteLine(string.Format("[{0}] [{1}] 트레일링 매도 대기. 5ma 상승 중 {2}원 ({3})", iTime, OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%")));
|
||||
//Console.WriteLine("[{0}] [{1}] 트레일링 매도 대기. 5ma 상승 중 {2}원 ({3})", iTime, OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"));
|
||||
continue;
|
||||
}
|
||||
|
||||
Console.WriteLine(string.Format("[{0}] [{1}] 트레일링 매도 {2}원 ({3}:{4}) (5MA slop:{5:0.00})", iTime, OwnItem.m_strCodeName, iCurPrice, iCurPrice- OwnItem.m_iUnitBEP, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), f5MASlope));
|
||||
Console.WriteLine("[{0}] [{1}] 트레일링 매도 {2}원 ({3}:{4}) (5MA slop:{5:0.00})", iTime, OwnItem.m_strCodeName, iCurPrice, iCurPrice- OwnItem.m_iUnitBEP, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), f5MASlope);
|
||||
ULUtil.TraceCSV("트레일링 매도", OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), f5MASlope);
|
||||
|
||||
OwnItem.m_iUnitBEP = 0;
|
||||
OwnItem.m_iConclusionBalanceCnt = 0;
|
||||
|
||||
//m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
//m_OwnList.Remove(OwnItem);
|
||||
//m_DataMgr.RemoveWatch(strCode);
|
||||
}
|
||||
// steadiness
|
||||
else if (WatchItem.GetAvgDiff(iTime) < WatchItem.m_iPrevClosing*0.01)
|
||||
{
|
||||
//m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
//m_OwnList.Remove(OwnItem);
|
||||
//m_DataMgr.RemoveWatch(strCode);
|
||||
|
||||
Console.WriteLine("[{0}] [{1}] 보합 처리 {2}원 ({3}:{4}) {5}",
|
||||
iTime,
|
||||
OwnItem.m_strCodeName,
|
||||
WatchItem.m_iCurPrice,
|
||||
WatchItem.m_iCurPrice - OwnItem.m_iUnitBEP,
|
||||
(WatchItem.m_iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"),
|
||||
WatchItem.m_iHighestPrice);
|
||||
ULUtil.TraceCSV("보합 처리", OwnItem.m_strCodeName, WatchItem.m_iCurPrice, WatchItem.m_iCurPrice - OwnItem.m_iUnitBEP, (WatchItem.m_iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), WatchItem.m_iHighestPrice);
|
||||
|
||||
OwnItem.m_iUnitBEP = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//item.PrintChart();
|
||||
Console.WriteLine("시뮬레이션 끝");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user