현재가, 매수 후 최고가 디버그
This commit is contained in:
@@ -376,7 +376,7 @@ namespace upper_limit_crawler
|
||||
WatchItem.InsertPriceNode(iTime, iCurPrice);
|
||||
|
||||
if (OwnItem.m_iUnitBEP != 0)
|
||||
OwnItem.m_iMaxPrice = Math.Max(OwnItem.m_iMaxPrice, iCurPrice);
|
||||
OwnItem.m_iMaxPriceAfterBid = Math.Max(iCurPrice, OwnItem.m_iMaxPriceAfterBid);
|
||||
|
||||
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)
|
||||
@@ -446,7 +446,7 @@ namespace upper_limit_crawler
|
||||
// 미체결 잔량 취소
|
||||
}
|
||||
// trailing
|
||||
else if (iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
else if (iCurPrice <= OwnItem.m_iMaxPriceAfterBid - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
{
|
||||
float f5MASlope = WatchItem.GetPrev5MASlope(iTime);
|
||||
if (float.IsNaN(f5MASlope) || f5MASlope > -0.0100f)
|
||||
|
||||
14
ULBalanceDlg.Designer.cs
generated
14
ULBalanceDlg.Designer.cs
generated
@@ -37,11 +37,11 @@
|
||||
this.chEvaluationProfit = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chBalance = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chEvaluationPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chHighPriceAfterBid = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chProfitRate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.btRefresh = new System.Windows.Forms.Button();
|
||||
this.btSellAll = new System.Windows.Forms.Button();
|
||||
this.btSell = new System.Windows.Forms.Button();
|
||||
this.chHighestPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lvBalance
|
||||
@@ -58,7 +58,7 @@
|
||||
this.chEvaluationProfit,
|
||||
this.chBalance,
|
||||
this.chEvaluationPrice,
|
||||
this.chHighestPrice,
|
||||
this.chHighPriceAfterBid,
|
||||
this.chProfitRate});
|
||||
this.lvBalance.FullRowSelect = true;
|
||||
this.lvBalance.GridLines = true;
|
||||
@@ -110,6 +110,10 @@
|
||||
this.chEvaluationPrice.Text = "평가금액";
|
||||
this.chEvaluationPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chHighPriceAfterBid
|
||||
//
|
||||
this.chHighPriceAfterBid.Text = "매수후 최고가";
|
||||
//
|
||||
// chProfitRate
|
||||
//
|
||||
this.chProfitRate.Text = "수익률";
|
||||
@@ -149,10 +153,6 @@
|
||||
this.btSell.UseVisualStyleBackColor = true;
|
||||
this.btSell.Click += new System.EventHandler(this.btSell_Click);
|
||||
//
|
||||
// chHighestPrice
|
||||
//
|
||||
this.chHighestPrice.Text = "최고가";
|
||||
//
|
||||
// ULBalanceDlg
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
@@ -185,6 +185,6 @@
|
||||
private System.Windows.Forms.ColumnHeader chEvaluationPrice;
|
||||
private System.Windows.Forms.Button btSellAll;
|
||||
private System.Windows.Forms.Button btSell;
|
||||
private System.Windows.Forms.ColumnHeader chHighestPrice;
|
||||
private System.Windows.Forms.ColumnHeader chHighPriceAfterBid;
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,9 @@ namespace upper_limit_crawler
|
||||
public double m_dConclusionUnitPrice;
|
||||
public long m_iUnitBEP;
|
||||
|
||||
public int m_iBidTime;
|
||||
public int m_iCurPrice;
|
||||
public int m_iMaxPrice;
|
||||
public int m_iMaxPriceAfterBid;
|
||||
|
||||
public bool m_bCheck;
|
||||
};
|
||||
@@ -126,14 +127,15 @@ namespace upper_limit_crawler
|
||||
|
||||
int iCurPrice = 0;
|
||||
|
||||
m_DataMgr.AddWatch(strCode, strCodeName, iCurPrice, iCurPrice);
|
||||
|
||||
OWN_ITEM OwnItem = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode);
|
||||
if (OwnItem == null)
|
||||
{
|
||||
OwnItem = new OWN_ITEM();
|
||||
m_OwnList.Add(OwnItem);
|
||||
}
|
||||
|
||||
m_DataMgr.AddWatch(strCode, strCodeName);
|
||||
|
||||
OwnItem.m_strCodeName = strCodeName;
|
||||
OwnItem.m_iPayBalance = iPayBalance;
|
||||
OwnItem.m_iPayUnitPrice = iPayUnitPrice;
|
||||
@@ -146,7 +148,8 @@ namespace upper_limit_crawler
|
||||
OwnItem.m_dConclusionUnitPrice = dConclusionUnitPrice;
|
||||
OwnItem.m_iUnitBEP = iUnitBEP;
|
||||
OwnItem.m_iCurPrice = iCurPrice;
|
||||
OwnItem.m_iMaxPrice = iCurPrice;
|
||||
OwnItem.m_iMaxPriceAfterBid = Math.Max(iCurPrice, OwnItem.m_iMaxPriceAfterBid);
|
||||
OwnItem.m_iBidTime=m_DataMgr.GetBidTime(strCode);
|
||||
OwnItem.m_bCheck = true;
|
||||
|
||||
ListViewItem listViewItem = new ListViewItem(new string[] { strCode, strCodeName, dConclusionUnitPrice.ToString("###,###,##0"),
|
||||
@@ -194,9 +197,28 @@ namespace upper_limit_crawler
|
||||
OwnItem.m_iEvaluationPrice = iCurPrice * OwnItem.m_iConclusionBalanceCnt;
|
||||
OwnItem.m_iEvaluationProfit = iComp * OwnItem.m_iConclusionBalanceCnt;
|
||||
OwnItem.m_dProfitRate = iComp / (float)OwnItem.m_iUnitBEP;
|
||||
OwnItem.m_iMaxPrice = WatchItem.m_iHighestPrice;
|
||||
OwnItem.m_iMaxPriceAfterBid=WatchItem.GetHighestPriceAfter(OwnItem.m_iBidTime);
|
||||
|
||||
if(iCurPrice > 0)
|
||||
ListViewItem lvItem = lvBalance.FindItemWithText(strCode);
|
||||
if(lvItem != null)
|
||||
{
|
||||
lvItem.SubItems[chCurPrice.Index].Text = iCurPrice.ToString("###,###,##0");
|
||||
lvItem.SubItems[chEvaluationPrice.Index].Text = OwnItem.m_iEvaluationPrice.ToString("###,###,##0");
|
||||
lvItem.SubItems[chEvaluationProfit.Index].Text = OwnItem.m_iEvaluationProfit.ToString("###,###,##0");
|
||||
if(OwnItem.m_iEvaluationProfit > 0)
|
||||
lvItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Red;
|
||||
else
|
||||
lvItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Blue;
|
||||
lvItem.SubItems[chEvaluationPrice.Index].Text = OwnItem.m_iEvaluationPrice.ToString("###,###,##0");
|
||||
lvItem.SubItems[chProfitRate.Index].Text = OwnItem.m_dProfitRate.ToString("#,##0.00%");
|
||||
lvItem.SubItems[chHighPriceAfterBid.Index].Text = OwnItem.m_iMaxPriceAfterBid.ToString("###,###,##0");
|
||||
if(OwnItem.m_dProfitRate > 0)
|
||||
lvItem.SubItems[chProfitRate.Index].ForeColor = Color.Red;
|
||||
else
|
||||
lvItem.SubItems[chProfitRate.Index].ForeColor = Color.Blue;
|
||||
}
|
||||
|
||||
if(ULUtil.IsTradingTime() == true && iCurPrice > 0)
|
||||
{
|
||||
// loss cut
|
||||
if(iCurPrice <= OwnItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut))
|
||||
@@ -218,12 +240,12 @@ namespace upper_limit_crawler
|
||||
// 미체결 잔량 취소
|
||||
}
|
||||
// trailing
|
||||
else if(iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
else if(iCurPrice <= OwnItem.m_iMaxPriceAfterBid - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
{
|
||||
float f5MASlope = WatchItem.GetPrev5MASlope(iTime);
|
||||
if(float.IsNaN(f5MASlope) || f5MASlope > -0.0100f)
|
||||
{
|
||||
Console.WriteLine(string.Format("[{0}] [{1}] 트레일링 매도 대기. 5ma 상승 중 {2}원 ({3})", iTime, OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%")));
|
||||
ULUtil.Trace(string.Format("[{0}] [{1}] 트레일링 매도 대기. 5ma 상승 중 {2}원 ({3})", iTime, OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%")));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -244,25 +266,21 @@ namespace upper_limit_crawler
|
||||
ULUtil.TraceCSV("트레일링 매도", OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, fProfitRate.ToString("0.00%"), f5MASlope.ToString("0.00%"), WatchItem.m_iHighestPrice);
|
||||
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, f5MASlope, false, iProfit, fProfitRate, true);
|
||||
}
|
||||
}
|
||||
// steadiness
|
||||
else if(ULUtil.GetTimeDiff(OwnItem.m_iBidTime, iTime) > 3000)
|
||||
{
|
||||
m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
m_OwnList.Remove(OwnItem);
|
||||
m_DataMgr.RemoveWatch(strCode);
|
||||
|
||||
ListViewItem lvItem = lvBalance.FindItemWithText(strCode);
|
||||
if(lvItem != null)
|
||||
{
|
||||
lvItem.SubItems[chCurPrice.Index].Text = iCurPrice.ToString("###,###,##0");
|
||||
lvItem.SubItems[chEvaluationPrice.Index].Text = OwnItem.m_iEvaluationPrice.ToString("###,###,##0");
|
||||
lvItem.SubItems[chEvaluationProfit.Index].Text = OwnItem.m_iEvaluationProfit.ToString("###,###,##0");
|
||||
if(OwnItem.m_iEvaluationProfit > 0)
|
||||
lvItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Red;
|
||||
else
|
||||
lvItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Blue;
|
||||
lvItem.SubItems[chEvaluationPrice.Index].Text = OwnItem.m_iEvaluationPrice.ToString("###,###,##0");
|
||||
lvItem.SubItems[chProfitRate.Index].Text = OwnItem.m_dProfitRate.ToString("#,##0.00%");
|
||||
lvItem.SubItems[chHighestPrice.Index].Text = WatchItem.m_iHighestPrice.ToString("###,###,##0");
|
||||
if(OwnItem.m_dProfitRate > 0)
|
||||
lvItem.SubItems[chProfitRate.Index].ForeColor = Color.Red;
|
||||
else
|
||||
lvItem.SubItems[chProfitRate.Index].ForeColor = Color.Blue;
|
||||
ULUtil.Trace("[{0}] 보합 처리 {1}원 ({2}:{3}) {4}",
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
19
ULDataMgr.cs
19
ULDataMgr.cs
@@ -110,7 +110,7 @@ namespace upper_limit_crawler
|
||||
return m_Trader;
|
||||
}
|
||||
|
||||
public void AddWatch(string strCode, string strCodeName, int iCurPrice, int iPrevClosing)
|
||||
public void AddWatch(string strCode, string strCodeName)
|
||||
{
|
||||
if (m_WatchList.ContainsKey(strCode))
|
||||
return;
|
||||
@@ -118,8 +118,6 @@ namespace upper_limit_crawler
|
||||
ULWatchItem item = new ULWatchItem();
|
||||
item.m_strCode = strCode;
|
||||
item.m_strCodeName = strCodeName;
|
||||
item.m_iCurPrice = iCurPrice;
|
||||
item.m_iPrevClosing = iPrevClosing;
|
||||
|
||||
item.FillPrice();
|
||||
|
||||
@@ -296,6 +294,21 @@ namespace upper_limit_crawler
|
||||
return new List<ASK_LOG>();
|
||||
}
|
||||
|
||||
public int GetBidTime(string strCode)
|
||||
{
|
||||
int iTime = 0;
|
||||
List<BID_LOG> BidLog = m_BidLogs.Where(r => r.m_strCode==strCode).ToList();
|
||||
BidLog.Reverse();
|
||||
foreach(BID_LOG bid in BidLog)
|
||||
{
|
||||
if(m_AskLogs.Any(r => r.m_strCode==strCode && r.m_iTime>bid.m_iTime)==false)
|
||||
iTime=bid.m_iTime;
|
||||
else
|
||||
break;
|
||||
}
|
||||
return iTime;
|
||||
}
|
||||
|
||||
public void DumpLog(bool bReal)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace upper_limit_crawler
|
||||
|
||||
if (fCompRate >= m_DataMgr.m_Setting.m_fSearchMin * 100 && fCompRate <= m_DataMgr.m_Setting.m_fSearchMax * 100)
|
||||
{
|
||||
m_DataMgr.AddWatch(strCode, strCodeName, iCurPrice, iCurPrice-iComp);
|
||||
m_DataMgr.AddWatch(strCode, strCodeName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ namespace upper_limit_crawler
|
||||
public int m_iBidPrice;
|
||||
public int m_iBidCnt;
|
||||
|
||||
|
||||
List<PriceNode> m_PriceList = new List<PriceNode>();
|
||||
|
||||
// key : time(HH:mm:ss)
|
||||
@@ -115,7 +114,7 @@ namespace upper_limit_crawler
|
||||
string strDate = ULUtil.GetCurTime().ToString("yyyyMMdd");
|
||||
stockChart.SetInputValue(2, strDate);
|
||||
stockChart.SetInputValue(3, strDate);
|
||||
stockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5 });
|
||||
stockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5, 6, 37 });
|
||||
stockChart.SetInputValue(6, 'm');
|
||||
stockChart.BlockRequest2(1);
|
||||
|
||||
@@ -123,13 +122,18 @@ namespace upper_limit_crawler
|
||||
int iFieldCnt = stockChart.GetHeaderValue(1);
|
||||
string[] astrFieldName = stockChart.GetHeaderValue(2);
|
||||
|
||||
m_iPrevClosing = (int)stockChart.GetHeaderValue(6);
|
||||
m_iCurPrice = m_iPrevClosing;
|
||||
|
||||
for (int i = iCnt - 1; i >= 0; i--)
|
||||
{
|
||||
int iTime = (int)stockChart.GetDataValue(1, i);
|
||||
int iPrice = (int)stockChart.GetDataValue(5, i);
|
||||
|
||||
int iTime = (int)stockChart.GetDataValue(1, i);
|
||||
iTime *= 100;
|
||||
|
||||
m_iCurPrice = iPrice;
|
||||
m_iCurTime = iTime;
|
||||
|
||||
InsertPriceNode(iTime, iPrice);
|
||||
}
|
||||
}
|
||||
@@ -360,5 +364,14 @@ namespace upper_limit_crawler
|
||||
float fSum = itor.Sum(r => r.Value.m_iHighest-r.Value.m_iLowest);
|
||||
return fSum / (itor.Count());
|
||||
}
|
||||
|
||||
public int GetHighestPriceAfter(int iTime)
|
||||
{
|
||||
List<PriceNode> AfterList = m_PriceList.Where(r => r.m_iTime > iTime).ToList();
|
||||
if(AfterList.Count() > 0)
|
||||
return AfterList.Max(r => r.m_iPrice);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
UlUtil.cs
20
UlUtil.cs
@@ -23,6 +23,9 @@ namespace upper_limit_crawler
|
||||
static string m_strCSVFileName;
|
||||
static TimeSpan m_TimeDiff = TimeSpan.Zero;
|
||||
|
||||
static int m_iTradingStartTime;
|
||||
static int m_iTradingEndTime;
|
||||
|
||||
public static void Init(TextBox tbLog)
|
||||
{
|
||||
m_CPUtil = new CPUTILLib.CpCybos();
|
||||
@@ -38,6 +41,11 @@ namespace upper_limit_crawler
|
||||
|
||||
m_strLogFileName = m_strLogDir + "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".txt";
|
||||
m_strCSVFileName = m_strLogDir + "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".csv";
|
||||
|
||||
m_iTradingStartTime = (int)m_CPCodeMgr.GetMarketStartTime();
|
||||
m_iTradingStartTime *= 100;
|
||||
m_iTradingEndTime = (int)m_CPCodeMgr.GetMarketEndTime();
|
||||
m_iTradingEndTime *= 100;
|
||||
}
|
||||
|
||||
public static void SyncServerTime()
|
||||
@@ -160,6 +168,12 @@ namespace upper_limit_crawler
|
||||
return int.Parse(GetCurTime().ToString("HHmmss"));
|
||||
}
|
||||
|
||||
public static int GetTimeDiff(int iTime1, int iTime2)
|
||||
{
|
||||
TimeSpan Diff = DateTime.Parse(iTime2.ToString()) - DateTime.Parse(iTime1.ToString());
|
||||
return int.Parse(Diff.ToString("HHmmss"));
|
||||
}
|
||||
|
||||
public static void WebLog(string strURL, string strMsg)
|
||||
{
|
||||
try
|
||||
@@ -297,5 +311,11 @@ namespace upper_limit_crawler
|
||||
Thread.Sleep(500);
|
||||
return obj.BlockRequest2(1);
|
||||
}
|
||||
|
||||
public static bool IsTradingTime()
|
||||
{
|
||||
int iCurTime = GetCurTimeInt();
|
||||
return (iCurTime >= m_iTradingStartTime && iCurTime <= m_iTradingEndTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user