검증 개발 중
This commit is contained in:
98
MainForm.cs
98
MainForm.cs
@@ -259,31 +259,101 @@ namespace upper_limit_crawler
|
||||
|
||||
private void btMATest_Click(object sender, EventArgs e)
|
||||
{
|
||||
string strCode = "A010240";
|
||||
|
||||
CPSYSDIBLib.StockChart stockChart = new CPSYSDIBLib.StockChart();
|
||||
stockChart.SetInputValue(0, "A043580");
|
||||
stockChart.SetInputValue(0, strCode);
|
||||
stockChart.SetInputValue(1, '1');
|
||||
stockChart.SetInputValue(2, "20160722");
|
||||
stockChart.SetInputValue(3, "20160722");
|
||||
stockChart.SetInputValue(2, "20160725");
|
||||
stockChart.SetInputValue(3, "20160725");
|
||||
stockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5, 6, 10 });
|
||||
stockChart.SetInputValue(6, 'm');
|
||||
stockChart.SetInputValue(6, 'T');
|
||||
stockChart.BlockRequest2(1);
|
||||
|
||||
int iCnt = (int)stockChart.GetHeaderValue(3);
|
||||
|
||||
ULWatchItem item = new ULWatchItem();
|
||||
item.m_strCode = strCode;
|
||||
item.m_strCodeName = "흥국";
|
||||
item.m_iCurPrice = 0;
|
||||
item.m_iPrevClosing = 0;
|
||||
|
||||
ULBalanceDlg.OWN_ITEM OwnItem = new ULBalanceDlg.OWN_ITEM();
|
||||
|
||||
int iFieldCnt = stockChart.GetHeaderValue(1);
|
||||
string[] astrFieldName = stockChart.GetHeaderValue(2);
|
||||
|
||||
ULWatchItem item = new ULWatchItem();
|
||||
|
||||
for (int i=iCnt-1; i>=0; i--)
|
||||
while (true)
|
||||
{
|
||||
int iTime = (int)stockChart.GetDataValue(1, i);
|
||||
int iPrice = (int)stockChart.GetDataValue(5, i);
|
||||
int iVolume = (int)stockChart.GetDataValue(5, i);
|
||||
int iCnt = (int)stockChart.GetHeaderValue(3);
|
||||
for (int i = iCnt - 1; i >= 0; i--)
|
||||
{
|
||||
int iTime = (int)stockChart.GetDataValue(1, i);
|
||||
iTime *= 100;
|
||||
|
||||
iTime *= 100;
|
||||
int iPrice = (int)stockChart.GetDataValue(5, i);
|
||||
int iVolume = (int)stockChart.GetDataValue(5, i);
|
||||
|
||||
item.m_iCurPrice = iPrice;
|
||||
item.InsertPriceNode(iTime, iPrice);
|
||||
if (item.m_iPrevClosing == 0)
|
||||
item.m_iPrevClosing = (int)stockChart.GetHeaderValue(6);
|
||||
|
||||
item.m_iCurPrice = iPrice;
|
||||
item.InsertPriceNode(iTime, iPrice);
|
||||
|
||||
float fCompRate = item.m_iCurPrice / (float)item.m_iPrevClosing - 1.0f;
|
||||
if (fCompRate >= m_DataMgr.m_Setting.m_fBidMin && fCompRate <= m_DataMgr.m_Setting.m_fBidMax)
|
||||
{
|
||||
if (item.Is5MAGoingUp() == false)
|
||||
{
|
||||
//UlUtil.Trace(string.Format("[{0}] 조건 매수 실패. 5ma 상승하지 않음 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%")));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_DataMgr.IsInBlackList(iTime, strCode) == true)
|
||||
{
|
||||
//UlUtil.Trace(string.Format("[{0}] 조건 매수 실패. black list {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%")));
|
||||
continue;
|
||||
}
|
||||
|
||||
// bid and add to black list
|
||||
UlUtil.Trace(string.Format("[{0}] 조건 매수 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%")));
|
||||
|
||||
//m_DataMgr.GetTrader().Buy(strCode, item.m_iCurPrice, (int)m_DataMgr.m_Setting.m_fBidAmount);
|
||||
m_DataMgr.AddBlackList(iTime, strCode);
|
||||
}
|
||||
|
||||
|
||||
// loss cut
|
||||
if (iPrice <= OwnItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut))
|
||||
{
|
||||
UlUtil.Trace(string.Format("[{0}] 손절 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%")));
|
||||
//m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
//m_OwnList.Remove(OwnItem);
|
||||
//m_DataMgr.RemoveWatch(strCode);
|
||||
|
||||
// own에서 삭제하고 미체결 리스트에 넣고, watch에서도 뺀다
|
||||
|
||||
// 미체결 잔량 취소
|
||||
}
|
||||
// trailing
|
||||
else if (iPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
{
|
||||
if (WatchItem.Is5MAGoingUp() == true)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[{0}] 트레일링 매도 대기. 5ma 상승 중 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%")));
|
||||
continue;
|
||||
}
|
||||
|
||||
UlUtil.Trace(string.Format("[{0}] 트레일링 매도 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%")));
|
||||
//m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
//m_OwnList.Remove(OwnItem);
|
||||
//m_DataMgr.RemoveWatch(strCode);
|
||||
}
|
||||
}
|
||||
|
||||
if (stockChart.Continue == 1)
|
||||
stockChart.BlockRequest2(1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
item.PrintChart();
|
||||
|
||||
@@ -210,8 +210,14 @@ namespace upper_limit_crawler
|
||||
// 미체결 잔량 취소
|
||||
}
|
||||
// trailing
|
||||
else if (iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing && WatchItem.Is5MAGoingUp() == false)
|
||||
else if (iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
{
|
||||
if (WatchItem.Is5MAGoingUp() == true)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[{0}] 트레일링 매도 대기. 5ma 상승 중 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%")));
|
||||
continue;
|
||||
}
|
||||
|
||||
UlUtil.Trace(string.Format("[{0}] 트레일링 매도 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f).ToString("0.00%")));
|
||||
m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
m_OwnList.Remove(OwnItem);
|
||||
|
||||
10
ULDataMgr.cs
10
ULDataMgr.cs
@@ -109,22 +109,20 @@ namespace upper_limit_crawler
|
||||
}
|
||||
}
|
||||
|
||||
public void AddBlackList(string strCode)
|
||||
public void AddBlackList(int iTime, string strCode)
|
||||
{
|
||||
int iTime = int.Parse(UlUtil.GetCurTime().ToString("HHmmss"));
|
||||
BLACKLIST black = new BLACKLIST(strCode, iTime);
|
||||
m_BlackList.Add(black);
|
||||
}
|
||||
|
||||
bool IsIn5Min(int iTime)
|
||||
bool IsIn5Min(int iTime, int iCurTime)
|
||||
{
|
||||
int iCurTime = int.Parse(UlUtil.GetCurTime().ToString("HHmmss"));
|
||||
return (iTime >= iCurTime - 500);
|
||||
}
|
||||
|
||||
public bool IsInBlackList(string strCode)
|
||||
public bool IsInBlackList(int iTime, string strCode)
|
||||
{
|
||||
return m_BlackList.Any(r => r.m_strCode == strCode && IsIn5Min(r.m_iTime));
|
||||
return m_BlackList.Any(r => r.m_strCode == strCode && IsIn5Min(r.m_iTime, iTime));
|
||||
}
|
||||
|
||||
public Dictionary<string, ULWatchItem> GetWatchList()
|
||||
|
||||
9
ULMonitorDlg.Designer.cs
generated
9
ULMonitorDlg.Designer.cs
generated
@@ -38,6 +38,7 @@
|
||||
this.chVolume = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chBidPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chBidCnt = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chPrevClosing = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lvWatch
|
||||
@@ -54,7 +55,8 @@
|
||||
this.chCompRate,
|
||||
this.chVolume,
|
||||
this.chBidPrice,
|
||||
this.chBidCnt});
|
||||
this.chBidCnt,
|
||||
this.chPrevClosing});
|
||||
this.lvWatch.FullRowSelect = true;
|
||||
this.lvWatch.GridLines = true;
|
||||
this.lvWatch.Location = new System.Drawing.Point(12, 12);
|
||||
@@ -106,6 +108,10 @@
|
||||
this.chBidCnt.Text = "호가잔량";
|
||||
this.chBidCnt.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chPrevClosing
|
||||
//
|
||||
this.chPrevClosing.Text = "전일종가";
|
||||
//
|
||||
// ULMonitorDlg
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
@@ -132,5 +138,6 @@
|
||||
private System.Windows.Forms.ColumnHeader chBidPrice;
|
||||
private System.Windows.Forms.ColumnHeader chBidCnt;
|
||||
private System.Windows.Forms.ColumnHeader chCode;
|
||||
private System.Windows.Forms.ColumnHeader chPrevClosing;
|
||||
}
|
||||
}
|
||||
@@ -102,12 +102,13 @@ namespace upper_limit_crawler
|
||||
searchItem.SubItems[chComp.Index].Text = iComp.ToString("###,###,###,###");
|
||||
searchItem.SubItems[chCompRate.Index].Text = fCompRate.ToString("#,##0.00");
|
||||
searchItem.SubItems[chVolume.Index].Text = iVolume.ToString("###,###,###,###");
|
||||
searchItem.SubItems[chPrevClosing.Index].Text = (iCurPrice - iComp).ToString("###,###,###,###");
|
||||
}
|
||||
else
|
||||
{
|
||||
ListViewItem listViewItem = new ListViewItem(new string[] { iIdx.ToString(), strCode.ToString(), strCodeName.ToString(),
|
||||
iCurPrice.ToString("###,###,###,###"), iComp.ToString("###,###,###,###"), fCompRate.ToString("#,##0.00")+"%",
|
||||
iVolume.ToString("###,###,###,###"), 0.ToString(), 0.ToString() });
|
||||
iVolume.ToString("###,###,###,###"), 0.ToString(), 0.ToString(), (iCurPrice - iComp).ToString("###,###,###,###") });
|
||||
lvWatch.Items.Add(listViewItem);
|
||||
}
|
||||
|
||||
@@ -156,16 +157,27 @@ namespace upper_limit_crawler
|
||||
lvItem.SubItems[chVolume.Index].Text = item.m_iVolume.ToString("###,###,###,###");
|
||||
lvItem.SubItems[chBidPrice.Index].Text = item.m_iBidPrice.ToString("###,###,###,###");
|
||||
|
||||
if (fCompRate >= m_DataMgr.m_Setting.m_fBidMin &&
|
||||
fCompRate <= m_DataMgr.m_Setting.m_fBidMax &&
|
||||
item.Is5MAGoingUp() == true &&
|
||||
m_DataMgr.IsInBlackList(strCode) == false)
|
||||
if (fCompRate >= m_DataMgr.m_Setting.m_fBidMin && fCompRate <= m_DataMgr.m_Setting.m_fBidMax)
|
||||
{
|
||||
if(item.Is5MAGoingUp() == false)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[{0}] 조건 매수 실패. 5ma 상승하지 않음 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%")));
|
||||
continue;
|
||||
}
|
||||
|
||||
int iCurTime = int.Parse(UlUtil.GetCurTime().ToString("HHmmss"));
|
||||
if (m_DataMgr.IsInBlackList(iCurTime, strCode) == true)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[{0}] 조건 매수 실패. black list {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%")));
|
||||
continue;
|
||||
}
|
||||
|
||||
// bid and add to black list
|
||||
UlUtil.Trace(string.Format("[{0}] 조건 매수 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%")));
|
||||
|
||||
m_DataMgr.GetTrader().Buy(strCode, item.m_iCurPrice, (int)m_DataMgr.m_Setting.m_fBidAmount);
|
||||
m_DataMgr.AddBlackList(strCode);
|
||||
int iTime = int.Parse(UlUtil.GetCurTime().ToString("HHmmss"));
|
||||
m_DataMgr.AddBlackList(iTime, strCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ namespace upper_limit_crawler
|
||||
{
|
||||
try
|
||||
{
|
||||
UlUtil.Trace("TimeSync trying [server:{0}]", server);
|
||||
|
||||
// Connect to the server (at port 13) and get the response
|
||||
string serverResponse = string.Empty;
|
||||
using (var reader = new StreamReader(new System.Net.Sockets.TcpClient(server, 13).GetStream()))
|
||||
@@ -199,6 +201,11 @@ namespace upper_limit_crawler
|
||||
//WebLog(m_strLogServer, strLog);
|
||||
}
|
||||
|
||||
public static void Trace(string strMsg, params object[] args)
|
||||
{
|
||||
Trace(string.Format(strMsg, args));
|
||||
}
|
||||
|
||||
public static int GetLimitRemainCountTrace()
|
||||
{
|
||||
return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_TRADE_REQUEST);
|
||||
|
||||
Reference in New Issue
Block a user