From 2b179e6df69ef5ee9ef0752f3039661ee33e6850 Mon Sep 17 00:00:00 2001 From: mjjo Date: Fri, 8 Jul 2016 00:56:43 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=94=EA=B3=A0=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=97=90=EC=84=9C=20=ED=98=84=EC=9E=AC=EA=B0=80=20?= =?UTF-8?q?=EA=B0=B1=EC=8B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ULBalanceDlg.Designer.cs | 16 +++---- ULBalanceDlg.cs | 98 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 98 insertions(+), 16 deletions(-) diff --git a/ULBalanceDlg.Designer.cs b/ULBalanceDlg.Designer.cs index a5c4785..ed360f9 100644 --- a/ULBalanceDlg.Designer.cs +++ b/ULBalanceDlg.Designer.cs @@ -36,7 +36,7 @@ this.chBalance = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chUnitBEP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chUnitProfit = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chProfit = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chEvaluationPrice = ((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(); @@ -52,11 +52,11 @@ this.chCode, this.chName, this.chUnitBuyPrice, - this.chCurPrice, - this.chBalance, this.chUnitBEP, + this.chCurPrice, this.chUnitProfit, - this.chProfit, + this.chBalance, + this.chEvaluationPrice, this.chProfitRate}); this.lvBalance.FullRowSelect = true; this.lvBalance.GridLines = true; @@ -103,10 +103,10 @@ this.chUnitProfit.Text = "평가손익"; this.chUnitProfit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // - // chProfit + // chEvaluationPrice // - this.chProfit.Text = "평가금액"; - this.chProfit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.chEvaluationPrice.Text = "평가금액"; + this.chEvaluationPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // chProfitRate // @@ -174,7 +174,7 @@ private System.Windows.Forms.Button btRefresh; private System.Windows.Forms.ColumnHeader chCode; private System.Windows.Forms.ColumnHeader chUnitBuyPrice; - private System.Windows.Forms.ColumnHeader chProfit; + private System.Windows.Forms.ColumnHeader chEvaluationPrice; private System.Windows.Forms.Button btSellAll; private System.Windows.Forms.Button btSell; } diff --git a/ULBalanceDlg.cs b/ULBalanceDlg.cs index b04dc96..f9b0e76 100644 --- a/ULBalanceDlg.cs +++ b/ULBalanceDlg.cs @@ -12,11 +12,34 @@ namespace upper_limit_crawler { public partial class ULBalanceDlg : Form { - const int BALANCE_DELAY = 15000; + const int BALANCE_DELAY = 10000; + const int PRICE_DELAY = 500; + + public class OWN_ITEM + { + public string m_strCodeName; + public int m_iPayBalance; + public int m_iPayUnitPrice; + public int m_iConclusionBalanceCnt; + public long m_iEvaluationPrice; + public long m_iEvaluationProfit; + public double m_dReturn; + public string m_strCode; + public int m_iAskableCnt; + public double m_dConclusionUnitPrice; + public long m_iUnitBEP; + + public int m_iCurPrice; + }; + + + List m_OwnList = new List(); + DSCBO1Lib.StockMst2 m_StockMst2 = new DSCBO1Lib.StockMst2(); Timer m_MainTimer = new Timer(); int m_iLastTime = 0; int m_iBalanceDelay = BALANCE_DELAY; + int m_iPriceDelay = PRICE_DELAY; ULDataMgr m_DataMgr = null; @@ -42,9 +65,10 @@ namespace upper_limit_crawler m_Td6033.SetInputValue(0, m_DataMgr.GetAccount()); m_Td6033.SetInputValue(2, 50); - m_Td6033.BlockRequest2(0); + m_Td6033.BlockRequest2(1); lvBalance.Items.Clear(); + m_OwnList.Clear(); int iCnt = m_Td6033.GetHeaderValue(7); for(int i = 0; i 0) + strPriceList += ","; + strPriceList += item.m_strCode; + } + + m_StockMst2.SetInputValue(0, strPriceList); + m_StockMst2.BlockRequest2(1); + + int iCnt = m_StockMst2.GetHeaderValue(0); + for(int i=0; i item.m_strCode == strCode); + if (listItem != null) + listItem.m_iCurPrice = iCurPrice; + + ListViewItem lvItem = lvBalance.FindItemWithText(strCode); + if (lvItem != null) + { + lvItem.SubItems[chCurPrice.Index].Text = iCurPrice.ToString("###,###,##0"); + lvItem.SubItems[chUnitProfit.Index].Text = (iCurPrice - listItem.m_iUnitBEP).ToString("###,###,##0"); + lvItem.SubItems[chEvaluationPrice.Index].Text = (iCurPrice*listItem.m_iConclusionBalanceCnt).ToString("###,###,##0"); + lvItem.SubItems[chProfitRate.Index].Text = (iCurPrice / (float)listItem.m_iUnitBEP - 1.0f).ToString("#,##0.00%"); + } + } + } + + private void RefreshData(object sender, EventArgs e) { int iCurTime = Environment.TickCount; if(m_iLastTime==0) @@ -89,22 +167,26 @@ namespace upper_limit_crawler int iDeltaT = iCurTime-m_iLastTime; m_iBalanceDelay-=iDeltaT; - if(m_iBalanceDelay<=0) + if(m_iBalanceDelay<=0 && UlUtil.GetLimitRemainCountRQ() > 20) { RefreshBalance(); m_iBalanceDelay=BALANCE_DELAY; } + m_iPriceDelay -= iDeltaT; + if(m_iPriceDelay<= 0 && UlUtil.GetLimitRemainCountRQ() >= m_OwnList.Count) { - int iCurPrice = 0; + RefreshCurPrice(); + m_iPriceDelay = PRICE_DELAY; } + m_iLastTime=iCurTime; } private void btRefresh_Click(object sender, EventArgs e) { - RefreshData(); + RefreshBalance(); } private void btSell_Click(object sender, EventArgs e)