잔고 평가 dlg 추가
This commit is contained in:
104
ULBalanceDlg.cs
Normal file
104
ULBalanceDlg.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace upper_limit_crawler
|
||||
{
|
||||
public partial class ULBalanceDlg : Form
|
||||
{
|
||||
ULDataMgr m_DataMgr = null;
|
||||
CPTRADELib.CpTd6033 m_Td6033 = new CPTRADELib.CpTd6033();
|
||||
|
||||
public ULBalanceDlg(ULDataMgr DataMgr)
|
||||
{
|
||||
m_DataMgr = DataMgr;
|
||||
|
||||
InitializeComponent();
|
||||
MainForm.SetDoubleBuffered(lvBalance);
|
||||
btSell.Enabled = false;
|
||||
|
||||
RefreshData();
|
||||
}
|
||||
|
||||
private void RefreshData()
|
||||
{
|
||||
m_Td6033.SetInputValue(0, m_DataMgr.GetAccount());
|
||||
m_Td6033.SetInputValue(2, 50);
|
||||
|
||||
m_Td6033.BlockRequest2(0);
|
||||
|
||||
lvBalance.Items.Clear();
|
||||
|
||||
int iCnt = m_Td6033.GetHeaderValue(7);
|
||||
for (int i = 0; i < iCnt; i++)
|
||||
{
|
||||
string strCodeName = m_Td6033.GetDataValue(0, i);
|
||||
int iPayBalance = m_Td6033.GetDataValue(3, i); // 결제 잔고수량
|
||||
int iPayUnitPrice = m_Td6033.GetDataValue(4, i); // 결제 장부단가
|
||||
int iConclusionBalanceCnt = m_Td6033.GetDataValue(7, i); // 체결 잔고수량
|
||||
long iEvaluationPrice = m_Td6033.GetDataValue(9, i); // 평가금액 : 보유수량x현재가
|
||||
long iEvaluationProfit = m_Td6033.GetDataValue(10, i); // 평가손익
|
||||
double dReturn = m_Td6033.GetDataValue(11, i); // 수익률
|
||||
string strCode = m_Td6033.GetDataValue(12, i);
|
||||
int iAskableCnt = m_Td6033.GetDataValue(15, i); // 매도 가능 수량
|
||||
double dConclusionUnitPrice = m_Td6033.GetDataValue(17, i); // 체결 장부단가
|
||||
long iUnitBEP = m_Td6033.GetDataValue(18, i); // 손익단가 : 수수료 포함 순익 분기점 Break-Even Point
|
||||
|
||||
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.##")+"%" };
|
||||
var listViewItem = new ListViewItem(row);
|
||||
lvBalance.Items.Add(listViewItem);
|
||||
|
||||
UlUtil.Trace(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}",
|
||||
strCodeName, iPayBalance, iPayUnitPrice,
|
||||
iConclusionBalanceCnt, iEvaluationPrice, iEvaluationProfit,
|
||||
dReturn, strCode, iAskableCnt, dConclusionUnitPrice, iUnitBEP));
|
||||
}
|
||||
|
||||
foreach (ColumnHeader col in lvBalance.Columns)
|
||||
col.Width = -2;
|
||||
}
|
||||
|
||||
private void btRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
RefreshData();
|
||||
}
|
||||
|
||||
private void btSell_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach(ListViewItem item in lvBalance.SelectedItems)
|
||||
{
|
||||
string strCode = item.SubItems[chCode.Index].Text;
|
||||
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);
|
||||
m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt);
|
||||
|
||||
UlUtil.Trace("");
|
||||
}
|
||||
}
|
||||
|
||||
private void btSellAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (ListViewItem item in lvBalance.Items)
|
||||
{
|
||||
string strCode = item.SubItems[chCode.Index].Text;
|
||||
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);
|
||||
m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt);
|
||||
|
||||
UlUtil.Trace("");
|
||||
}
|
||||
}
|
||||
|
||||
private void lvBalance_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
||||
{
|
||||
btSell.Enabled = (lvBalance.SelectedItems.Count > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user