잔고 리스트에서 현재가 갱신
This commit is contained in:
16
ULBalanceDlg.Designer.cs
generated
16
ULBalanceDlg.Designer.cs
generated
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<OWN_ITEM> m_OwnList = new List<OWN_ITEM>();
|
||||
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<iCnt; i++)
|
||||
@@ -63,8 +87,25 @@ namespace upper_limit_crawler
|
||||
|
||||
int iCurPrice = (int)(iEvaluationPrice/iConclusionBalanceCnt);
|
||||
|
||||
string[] row = { strCode, strCodeName, dConclusionUnitPrice.ToString("###,###,##0"), iCurPrice.ToString("###,###,##0"), iConclusionBalanceCnt.ToString("###,###,##0"),
|
||||
iUnitBEP.ToString("###,###,##0"), iEvaluationProfit.ToString("###,###,##0"), iEvaluationPrice.ToString("###,###,##0"), dReturn.ToString("#,##0.##")+"%" };
|
||||
OWN_ITEM item = new OWN_ITEM();
|
||||
item.m_strCodeName = strCodeName;
|
||||
item.m_iPayBalance = iPayBalance;
|
||||
item.m_iPayUnitPrice = iPayUnitPrice;
|
||||
item.m_iConclusionBalanceCnt = iConclusionBalanceCnt;
|
||||
item.m_iEvaluationPrice = iEvaluationPrice;
|
||||
item.m_iEvaluationProfit = iEvaluationProfit;
|
||||
item.m_dReturn = dReturn;
|
||||
item.m_strCode = strCode;
|
||||
item.m_iAskableCnt = iAskableCnt;
|
||||
item.m_dConclusionUnitPrice = dConclusionUnitPrice;
|
||||
item.m_iUnitBEP = iUnitBEP;
|
||||
item.m_iCurPrice = iCurPrice;
|
||||
m_OwnList.Add(item);
|
||||
|
||||
string[] row = { strCode, strCodeName, dConclusionUnitPrice.ToString("###,###,##0"),
|
||||
iUnitBEP.ToString("###,###,##0"), iCurPrice.ToString("###,###,##0"),
|
||||
iEvaluationProfit.ToString("###,###,##0"), iConclusionBalanceCnt.ToString("###,###,##0"),
|
||||
iEvaluationPrice.ToString("###,###,##0"), dReturn.ToString("#,##0.00")+"%" };
|
||||
var listViewItem = new ListViewItem(row);
|
||||
lvBalance.Items.Add(listViewItem);
|
||||
|
||||
@@ -78,7 +119,44 @@ namespace upper_limit_crawler
|
||||
col.Width=-2;
|
||||
}
|
||||
|
||||
private void RefreshData()
|
||||
private void RefreshCurPrice()
|
||||
{
|
||||
if (m_OwnList.Count <= 0)
|
||||
return;
|
||||
|
||||
string strPriceList = "";
|
||||
foreach(OWN_ITEM item in m_OwnList)
|
||||
{
|
||||
if (strPriceList.Length > 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<iCnt; i++)
|
||||
{
|
||||
string strCode = m_StockMst2.GetDataValue(0, i);
|
||||
int iCurPrice = m_StockMst2.GetDataValue(3, i);
|
||||
|
||||
OWN_ITEM listItem = m_OwnList.First(item => 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)
|
||||
|
||||
Reference in New Issue
Block a user