- monitor, balance subscribe로 수정
- UI 개선
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
bin/
|
||||
obj/
|
||||
*.suo
|
||||
log/
|
||||
|
||||
30
MainForm.Designer.cs
generated
30
MainForm.Designer.cs
generated
@@ -51,6 +51,8 @@
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
|
||||
this.lbSBCnt = new System.Windows.Forms.Label();
|
||||
this.lbRQCnt = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
@@ -102,7 +104,7 @@
|
||||
this.tbBidAmount.Name = "tbBidAmount";
|
||||
this.tbBidAmount.Size = new System.Drawing.Size(100, 21);
|
||||
this.tbBidAmount.TabIndex = 9;
|
||||
this.tbBidAmount.Text = "1,000,000";
|
||||
this.tbBidAmount.Text = "100,000";
|
||||
this.tbBidAmount.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// tbTimeout
|
||||
@@ -201,7 +203,7 @@
|
||||
this.tbSearchMin.Name = "tbSearchMin";
|
||||
this.tbSearchMin.Size = new System.Drawing.Size(37, 21);
|
||||
this.tbSearchMin.TabIndex = 14;
|
||||
this.tbSearchMin.Text = "9.0%";
|
||||
this.tbSearchMin.Text = "7.0%";
|
||||
this.tbSearchMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
// btApply
|
||||
@@ -281,6 +283,8 @@
|
||||
//
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.lbSBCnt);
|
||||
this.splitContainer2.Panel2.Controls.Add(this.lbRQCnt);
|
||||
this.splitContainer2.Panel2.Controls.Add(this.btBalance);
|
||||
this.splitContainer2.Panel2.Controls.Add(this.label1);
|
||||
this.splitContainer2.Panel2.Controls.Add(this.label5);
|
||||
@@ -314,6 +318,24 @@
|
||||
this.splitContainer3.SplitterDistance = 231;
|
||||
this.splitContainer3.TabIndex = 0;
|
||||
//
|
||||
// lbSBCnt
|
||||
//
|
||||
this.lbSBCnt.AutoSize = true;
|
||||
this.lbSBCnt.Location = new System.Drawing.Point(29, 278);
|
||||
this.lbSBCnt.Name = "lbSBCnt";
|
||||
this.lbSBCnt.Size = new System.Drawing.Size(70, 12);
|
||||
this.lbSBCnt.TabIndex = 19;
|
||||
this.lbSBCnt.Text = "SB Count : ";
|
||||
//
|
||||
// lbRQCnt
|
||||
//
|
||||
this.lbRQCnt.AutoSize = true;
|
||||
this.lbRQCnt.Location = new System.Drawing.Point(29, 254);
|
||||
this.lbRQCnt.Name = "lbRQCnt";
|
||||
this.lbRQCnt.Size = new System.Drawing.Size(71, 12);
|
||||
this.lbRQCnt.TabIndex = 18;
|
||||
this.lbRQCnt.Text = "RQ Count : ";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
@@ -321,7 +343,7 @@
|
||||
this.ClientSize = new System.Drawing.Size(886, 642);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Name = "MainForm";
|
||||
this.Text = "Form1";
|
||||
this.Text = "Upper Limit";
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
this.splitContainer1.Panel2.PerformLayout();
|
||||
@@ -362,6 +384,8 @@
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.SplitContainer splitContainer2;
|
||||
private System.Windows.Forms.SplitContainer splitContainer3;
|
||||
private System.Windows.Forms.Label lbRQCnt;
|
||||
private System.Windows.Forms.Label lbSBCnt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
32
MainForm.cs
32
MainForm.cs
@@ -25,8 +25,6 @@ namespace upper_limit_crawler
|
||||
int m_iLastTime = 0;
|
||||
|
||||
static ULDataMgr m_DataMgr = new ULDataMgr();
|
||||
ULWatch m_Watch = new ULWatch(m_DataMgr);
|
||||
ULDealing m_Dealing = new ULDealing(m_DataMgr);
|
||||
ULOwn m_Own = new ULOwn(m_DataMgr);
|
||||
|
||||
ULMonitorDlg m_MonitorDlg = null;
|
||||
@@ -35,7 +33,10 @@ namespace upper_limit_crawler
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
//UlUtil.SetLogView(tbLog);
|
||||
|
||||
SetDoubleBuffered(tbLog);
|
||||
|
||||
UlUtil.Init(tbLog);
|
||||
|
||||
btApply_Click(null, null);
|
||||
|
||||
@@ -96,10 +97,11 @@ namespace upper_limit_crawler
|
||||
|
||||
int iDeltaT = iCurTime - m_iLastTime;
|
||||
|
||||
m_Watch.Refresh(iCurTime);
|
||||
m_Dealing.Refresh(iCurTime);
|
||||
m_Own.Refresh(iCurTime);
|
||||
|
||||
lbRQCnt.Text = "RQ Count : " + UlUtil.GetLimitRemainCountRQ().ToString();
|
||||
lbSBCnt.Text = "SB Count : " + UlUtil.GetLimitRemainCountSB().ToString();
|
||||
|
||||
m_iLastTime = iCurTime;
|
||||
}
|
||||
|
||||
@@ -115,10 +117,10 @@ namespace upper_limit_crawler
|
||||
{
|
||||
try
|
||||
{
|
||||
m_DataMgr.m_Setting.m_fSearchMin = float.Parse(tbSearchMin.Text.Replace("%", ""));
|
||||
m_DataMgr.m_Setting.m_fSearchMax = float.Parse(tbSearchMax.Text.Replace("%", ""));
|
||||
m_DataMgr.m_Setting.m_fBidMin = float.Parse(tbBidMin.Text.Replace("%", ""));
|
||||
m_DataMgr.m_Setting.m_fBidMax = float.Parse(tbBidMax.Text.Replace("%", ""));
|
||||
m_DataMgr.m_Setting.m_fSearchMin = float.Parse(tbSearchMin.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fSearchMax = float.Parse(tbSearchMax.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fBidMin = float.Parse(tbBidMin.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fBidMax = float.Parse(tbBidMax.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fBidAmount = float.Parse(tbBidAmount.Text);
|
||||
m_DataMgr.m_Setting.m_fTimeout = float.Parse(tbTimeout.Text);
|
||||
m_DataMgr.m_Setting.m_fTrailing = float.Parse(tbTrailing.Text.Replace("%", ""))/100;
|
||||
@@ -134,14 +136,14 @@ namespace upper_limit_crawler
|
||||
|
||||
private void btCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
tbSearchMin.Text = m_DataMgr.m_Setting.m_fSearchMin.ToString("0.0")+"%";
|
||||
tbSearchMax.Text = m_DataMgr.m_Setting.m_fSearchMax.ToString("0.0") + "%";
|
||||
tbBidMin.Text = m_DataMgr.m_Setting.m_fBidMin.ToString("0.0") + "%";
|
||||
tbBidMax.Text = m_DataMgr.m_Setting.m_fBidMax.ToString("0.0") + "%";
|
||||
tbSearchMin.Text = (m_DataMgr.m_Setting.m_fSearchMin*100).ToString("0.0") + "%";
|
||||
tbSearchMax.Text = (m_DataMgr.m_Setting.m_fSearchMax*100).ToString("0.0") + "%";
|
||||
tbBidMin.Text = (m_DataMgr.m_Setting.m_fBidMin*100).ToString("0.0") + "%";
|
||||
tbBidMax.Text = (m_DataMgr.m_Setting.m_fBidMax*100).ToString("0.0") + "%";
|
||||
tbBidAmount.Text = m_DataMgr.m_Setting.m_fBidAmount.ToString("###,###,###,###,###");
|
||||
tbTimeout.Text = m_DataMgr.m_Setting.m_fTimeout.ToString("0.###");
|
||||
tbTrailing.Text = m_DataMgr.m_Setting.m_fTrailing.ToString("0.0%");
|
||||
tbLossCut.Text = m_DataMgr.m_Setting.m_fLossCut.ToString("0.0%");
|
||||
tbTrailing.Text = (m_DataMgr.m_Setting.m_fTrailing*100).ToString("0.0") + "%";
|
||||
tbLossCut.Text = (m_DataMgr.m_Setting.m_fLossCut*100).ToString("0.0") + "%";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
ULBalanceDlg.Designer.cs
generated
12
ULBalanceDlg.Designer.cs
generated
@@ -34,7 +34,7 @@
|
||||
this.chUnitBuyPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chUnitBEP = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chCurPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chUnitProfit = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
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.chProfitRate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
@@ -54,7 +54,7 @@
|
||||
this.chUnitBuyPrice,
|
||||
this.chUnitBEP,
|
||||
this.chCurPrice,
|
||||
this.chUnitProfit,
|
||||
this.chEvaluationProfit,
|
||||
this.chBalance,
|
||||
this.chEvaluationPrice,
|
||||
this.chProfitRate});
|
||||
@@ -93,10 +93,10 @@
|
||||
this.chCurPrice.Text = "현재가";
|
||||
this.chCurPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chUnitProfit
|
||||
// chEvaluationProfit
|
||||
//
|
||||
this.chUnitProfit.Text = "평가손익";
|
||||
this.chUnitProfit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
this.chEvaluationProfit.Text = "평가손익";
|
||||
this.chEvaluationProfit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chBalance
|
||||
//
|
||||
@@ -171,7 +171,7 @@
|
||||
private System.Windows.Forms.ColumnHeader chCurPrice;
|
||||
private System.Windows.Forms.ColumnHeader chBalance;
|
||||
private System.Windows.Forms.ColumnHeader chUnitBEP;
|
||||
private System.Windows.Forms.ColumnHeader chUnitProfit;
|
||||
private System.Windows.Forms.ColumnHeader chEvaluationProfit;
|
||||
private System.Windows.Forms.ColumnHeader chProfitRate;
|
||||
private System.Windows.Forms.Button btRefresh;
|
||||
private System.Windows.Forms.ColumnHeader chCode;
|
||||
|
||||
175
ULBalanceDlg.cs
175
ULBalanceDlg.cs
@@ -5,6 +5,7 @@ using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -13,7 +14,6 @@ namespace upper_limit_crawler
|
||||
public partial class ULBalanceDlg : Form
|
||||
{
|
||||
const int BALANCE_DELAY = 10000;
|
||||
const int PRICE_DELAY = 500;
|
||||
|
||||
public class OWN_ITEM
|
||||
{
|
||||
@@ -23,7 +23,7 @@ namespace upper_limit_crawler
|
||||
public int m_iConclusionBalanceCnt;
|
||||
public long m_iEvaluationPrice;
|
||||
public long m_iEvaluationProfit;
|
||||
public double m_dReturn;
|
||||
public double m_dProfitRate;
|
||||
public string m_strCode;
|
||||
public int m_iAskableCnt;
|
||||
public double m_dConclusionUnitPrice;
|
||||
@@ -42,18 +42,18 @@ namespace upper_limit_crawler
|
||||
Timer m_MainTimer = new Timer();
|
||||
int m_iLastTime = 0;
|
||||
int m_iBalanceDelay = BALANCE_DELAY;
|
||||
int m_iPriceDelay = PRICE_DELAY;
|
||||
|
||||
ULDataMgr m_DataMgr = null;
|
||||
|
||||
CPTRADELib.CpTd6033 m_Td6033 = new CPTRADELib.CpTd6033();
|
||||
|
||||
bool m_bRequesting = false;
|
||||
DSCBO1Lib.StockCur m_StockCur = new DSCBO1Lib.StockCur();
|
||||
|
||||
public ULBalanceDlg(ULDataMgr DataMgr)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
MainForm.SetDoubleBuffered(lvBalance);
|
||||
|
||||
this.TopLevel = false;
|
||||
|
||||
m_DataMgr = DataMgr;
|
||||
@@ -83,58 +83,60 @@ namespace upper_limit_crawler
|
||||
int iCnt = m_Td6033.GetHeaderValue(7);
|
||||
for(int i = 0; i<iCnt; i++)
|
||||
{
|
||||
string strCode = m_Td6033.GetDataValue(12, 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); // 체결 잔고수량
|
||||
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);
|
||||
int iCurPrice = 0;
|
||||
|
||||
OWN_ITEM item = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode);
|
||||
if (item == null)
|
||||
m_DataMgr.AddWatch(strCode, strCodeName, iCurPrice, iCurPrice);
|
||||
|
||||
OWN_ITEM OwnItem = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode);
|
||||
if (OwnItem == null)
|
||||
{
|
||||
item = new OWN_ITEM();
|
||||
m_OwnList.Add(item);
|
||||
OwnItem = new OWN_ITEM();
|
||||
m_OwnList.Add(OwnItem);
|
||||
}
|
||||
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;
|
||||
item.m_iMaxPrice = iCurPrice;
|
||||
item.m_bCheck = true;
|
||||
OwnItem.m_strCodeName = strCodeName;
|
||||
OwnItem.m_iPayBalance = iPayBalance;
|
||||
OwnItem.m_iPayUnitPrice = iPayUnitPrice;
|
||||
OwnItem.m_iConclusionBalanceCnt = iConclusionBalanceCnt;
|
||||
OwnItem.m_iEvaluationPrice = iEvaluationPrice;
|
||||
OwnItem.m_iEvaluationProfit = iEvaluationProfit;
|
||||
OwnItem.m_dProfitRate = dReturn;
|
||||
OwnItem.m_strCode = strCode;
|
||||
OwnItem.m_iAskableCnt = iAskableCnt;
|
||||
OwnItem.m_dConclusionUnitPrice = dConclusionUnitPrice;
|
||||
OwnItem.m_iUnitBEP = iUnitBEP;
|
||||
OwnItem.m_iCurPrice = iCurPrice;
|
||||
OwnItem.m_iMaxPrice = iCurPrice;
|
||||
OwnItem.m_bCheck = true;
|
||||
|
||||
|
||||
string[] row = { strCode, strCodeName, dConclusionUnitPrice.ToString("###,###,##0"),
|
||||
ListViewItem listViewItem = new ListViewItem(new string[] { strCode, strCodeName, dConclusionUnitPrice.ToString("###,###,##0"),
|
||||
iUnitBEP.ToString("###,###,##0"), iCurPrice.ToString("###,###,##0"),
|
||||
iEvaluationProfit.ToString("###,###,##0"), iConclusionBalanceCnt.ToString("###,###,##0"),
|
||||
iEvaluationPrice.ToString("###,###,##0"), dReturn.ToString("#,##0.00")+"%" };
|
||||
ListViewItem listViewItem = new ListViewItem(row);
|
||||
iEvaluationPrice.ToString("###,###,##0"), dReturn.ToString("#,##0.00")+"%" });
|
||||
listViewItem.UseItemStyleForSubItems = false;
|
||||
|
||||
if(iEvaluationProfit > 0)
|
||||
listViewItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Red;
|
||||
else
|
||||
listViewItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Blue;
|
||||
|
||||
if (dReturn > 0)
|
||||
listViewItem.SubItems[chProfitRate.Index].ForeColor = Color.Red;
|
||||
else if (dReturn < 0)
|
||||
listViewItem.SubItems[chProfitRate.Index].ForeColor = Color.Blue;
|
||||
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));
|
||||
lvBalance.Items.Add(listViewItem);
|
||||
}
|
||||
|
||||
m_OwnList.RemoveAll(c => c.m_bCheck = false);
|
||||
@@ -145,59 +147,64 @@ namespace upper_limit_crawler
|
||||
|
||||
private void RefreshCurPrice()
|
||||
{
|
||||
if (m_bRequesting == true)
|
||||
return;
|
||||
m_bRequesting = true;
|
||||
|
||||
if (m_OwnList.Count <= 0)
|
||||
return;
|
||||
|
||||
string strPriceList = "";
|
||||
foreach(OWN_ITEM item in m_OwnList)
|
||||
Dictionary<string, WATCH_ITEM> WatchList = m_DataMgr.GetWatchList();
|
||||
foreach (ListViewItem lvItem in lvBalance.Items)
|
||||
{
|
||||
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 = lvItem.SubItems[chCode.Index].Text;
|
||||
if (WatchList.ContainsKey(strCode) == true)
|
||||
{
|
||||
string strCode = m_StockMst2.GetDataValue(0, i);
|
||||
int iCurPrice = m_StockMst2.GetDataValue(3, i);
|
||||
WATCH_ITEM WatchItem = WatchList[strCode];
|
||||
OWN_ITEM OwnItem = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode);
|
||||
int iDisplayCurPrice = 0;
|
||||
if (lvItem.SubItems[chCurPrice.Index].Text.Length > 0)
|
||||
iDisplayCurPrice = int.Parse(Regex.Replace(lvItem.SubItems[chCurPrice.Index].Text, @"\D", ""));
|
||||
|
||||
// data update
|
||||
OWN_ITEM listItem = m_OwnList.First(item => item.m_strCode == strCode);
|
||||
if (listItem == null)
|
||||
continue;
|
||||
|
||||
listItem.m_iCurPrice = iCurPrice;
|
||||
listItem.m_iMaxPrice = Math.Max(iCurPrice, listItem.m_iMaxPrice);
|
||||
|
||||
ListViewItem lvItem = lvBalance.FindItemWithText(strCode);
|
||||
if (lvItem != null)
|
||||
if (WatchItem.m_iCurPrice != iDisplayCurPrice && iDisplayCurPrice != 0)
|
||||
{
|
||||
int iCurPrice = WatchItem.m_iCurPrice;
|
||||
int iComp = iCurPrice - (int)OwnItem.m_iUnitBEP; // or OwnItem.m_dConclusionUnitPrice
|
||||
|
||||
OwnItem.m_iCurPrice = iCurPrice;
|
||||
OwnItem.m_iEvaluationPrice = iCurPrice * OwnItem.m_iConclusionBalanceCnt;
|
||||
OwnItem.m_iEvaluationProfit = iComp * OwnItem.m_iConclusionBalanceCnt;
|
||||
OwnItem.m_dProfitRate = iComp / (float)OwnItem.m_iUnitBEP;
|
||||
|
||||
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%");
|
||||
}
|
||||
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")+"%";
|
||||
if (OwnItem.m_dProfitRate > 0)
|
||||
lvItem.SubItems[chProfitRate.Index].ForeColor = Color.Red;
|
||||
else
|
||||
lvItem.SubItems[chProfitRate.Index].ForeColor = Color.Blue;
|
||||
|
||||
// cut loss and trailing
|
||||
if (iCurPrice <= listItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut) ||
|
||||
iCurPrice <= listItem.m_iMaxPrice * (1.0f - m_DataMgr.m_Setting.m_fTrailing))
|
||||
|
||||
OwnItem.m_iMaxPrice = Math.Max(iCurPrice, OwnItem.m_iMaxPrice);
|
||||
|
||||
// loss cut
|
||||
if (iCurPrice <= OwnItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut))
|
||||
{
|
||||
m_DataMgr.GetTrader().SellCurPrice(listItem.m_strCode, listItem.m_iPayBalance);
|
||||
UlUtil.Trace(string.Format("[{0}] 손절({1})", OwnItem.m_strCodeName, iCurPrice));
|
||||
m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
m_OwnList.Remove(OwnItem);
|
||||
|
||||
// 미체결 잔량 취소
|
||||
}
|
||||
// trailing
|
||||
else if (iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[{0}] 트레일링 매도({1})", OwnItem.m_strCodeName, iCurPrice));
|
||||
m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
m_OwnList.Remove(OwnItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_bRequesting = false;
|
||||
}
|
||||
|
||||
private void RefreshData(object sender, EventArgs e)
|
||||
@@ -217,13 +224,7 @@ namespace upper_limit_crawler
|
||||
m_iBalanceDelay=BALANCE_DELAY;
|
||||
}
|
||||
|
||||
m_iPriceDelay -= iDeltaT;
|
||||
if(m_iPriceDelay<= 0 && UlUtil.GetLimitRemainCountRQ() >= m_OwnList.Count)
|
||||
{
|
||||
RefreshCurPrice();
|
||||
m_iPriceDelay = PRICE_DELAY;
|
||||
}
|
||||
|
||||
|
||||
m_iLastTime=iCurTime;
|
||||
}
|
||||
@@ -237,11 +238,11 @@ namespace upper_limit_crawler
|
||||
{
|
||||
foreach(ListViewItem item in lvBalance.SelectedItems)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[{0}] 수동 매도", item.SubItems[chName.Index].Text));
|
||||
|
||||
string strCode = item.SubItems[chCode.Index].Text;
|
||||
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);
|
||||
m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt);
|
||||
|
||||
UlUtil.Trace("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,11 +250,11 @@ namespace upper_limit_crawler
|
||||
{
|
||||
foreach (ListViewItem item in lvBalance.Items)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[{0}] 모두 청산", item.SubItems[chName.Index].Text));
|
||||
|
||||
string strCode = item.SubItems[chCode.Index].Text;
|
||||
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);
|
||||
m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt);
|
||||
|
||||
UlUtil.Trace("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
ULDataMgr.cs
36
ULDataMgr.cs
@@ -20,24 +20,10 @@ namespace upper_limit_crawler
|
||||
public float m_fLossCut;
|
||||
}
|
||||
|
||||
public struct MONITOR_ITEM
|
||||
{
|
||||
public string Code;
|
||||
public string Name;
|
||||
public int CurPrice;
|
||||
public object flag;
|
||||
public int Comp;
|
||||
public float CompRate;
|
||||
public int Volume;
|
||||
public int StartPrice;
|
||||
public int StartPriceComp;
|
||||
public float StartPriceCompRate;
|
||||
public int SerialDay;
|
||||
}
|
||||
|
||||
public class WATCH_ITEM
|
||||
{
|
||||
public string m_strCode;
|
||||
public string m_strCodeName;
|
||||
public DSCBO1Lib.StockCur m_StockCur = null;
|
||||
|
||||
public int m_iCurPrice;
|
||||
@@ -56,7 +42,6 @@ namespace upper_limit_crawler
|
||||
|
||||
ULTrader m_Trader = new ULTrader();
|
||||
|
||||
List<MONITOR_ITEM> m_MonitorList = new List<MONITOR_ITEM>();
|
||||
Dictionary<string, WATCH_ITEM> m_WatchList = new Dictionary<string, WATCH_ITEM>();
|
||||
List<string> m_BlackList = new List<string>();
|
||||
|
||||
@@ -75,23 +60,14 @@ namespace upper_limit_crawler
|
||||
return m_Trader;
|
||||
}
|
||||
|
||||
public void ClearMonitor()
|
||||
{
|
||||
m_MonitorList.Clear();
|
||||
}
|
||||
|
||||
public void AddMonitor(MONITOR_ITEM Item)
|
||||
{
|
||||
m_MonitorList.Add(Item);
|
||||
}
|
||||
|
||||
public void AddWatch(string strCode, int iCurPrice, int iPrevClosing)
|
||||
public void AddWatch(string strCode, string strCodeName, int iCurPrice, int iPrevClosing)
|
||||
{
|
||||
if (m_WatchList.ContainsKey(strCode))
|
||||
return;
|
||||
|
||||
WATCH_ITEM item = new WATCH_ITEM();
|
||||
item.m_strCode = strCode;
|
||||
item.m_strCodeName = strCodeName;
|
||||
item.m_iCurPrice = iCurPrice;
|
||||
item.m_iPrevClosing = iPrevClosing;
|
||||
|
||||
@@ -108,6 +84,7 @@ namespace upper_limit_crawler
|
||||
foreach(KeyValuePair<string, WATCH_ITEM> item in m_WatchList)
|
||||
{
|
||||
item.Value.m_iCurPrice = item.Value.m_StockCur.GetHeaderValue(13);
|
||||
item.Value.m_iPrevClosing = item.Value.m_StockCur.GetHeaderValue(2);
|
||||
item.Value.m_iStartPrice = item.Value.m_StockCur.GetHeaderValue(4);
|
||||
item.Value.m_iHighestPrice = item.Value.m_StockCur.GetHeaderValue(5);
|
||||
item.Value.m_iVolume = item.Value.m_StockCur.GetHeaderValue(9);
|
||||
@@ -126,11 +103,6 @@ namespace upper_limit_crawler
|
||||
return m_BlackList.Contains(strCode);
|
||||
}
|
||||
|
||||
public List<MONITOR_ITEM> GetMonitor()
|
||||
{
|
||||
return m_MonitorList;
|
||||
}
|
||||
|
||||
public Dictionary<string, WATCH_ITEM> GetWatchList()
|
||||
{
|
||||
return m_WatchList;
|
||||
|
||||
27
ULDealing.cs
27
ULDealing.cs
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace upper_limit_crawler
|
||||
{
|
||||
class ULDealing : ULObj
|
||||
{
|
||||
public ULDealing(ULDataMgr DataMgr) : base(DataMgr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Refresh(int iCurTime)
|
||||
{
|
||||
if(m_iLastTime == 0)
|
||||
{
|
||||
base.Refresh(iCurTime);
|
||||
return;
|
||||
}
|
||||
|
||||
base.Refresh(iCurTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
136
ULMonitorDlg.Designer.cs
generated
Normal file
136
ULMonitorDlg.Designer.cs
generated
Normal file
@@ -0,0 +1,136 @@
|
||||
namespace upper_limit_crawler
|
||||
{
|
||||
partial class ULMonitorDlg
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lvWatch = new System.Windows.Forms.ListView();
|
||||
this.chOrder = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chCurPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chComp = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chCompRate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
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.SuspendLayout();
|
||||
//
|
||||
// lvWatch
|
||||
//
|
||||
this.lvWatch.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lvWatch.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.chOrder,
|
||||
this.chCode,
|
||||
this.chName,
|
||||
this.chCurPrice,
|
||||
this.chComp,
|
||||
this.chCompRate,
|
||||
this.chVolume,
|
||||
this.chBidPrice,
|
||||
this.chBidCnt});
|
||||
this.lvWatch.FullRowSelect = true;
|
||||
this.lvWatch.GridLines = true;
|
||||
this.lvWatch.Location = new System.Drawing.Point(12, 12);
|
||||
this.lvWatch.Name = "lvWatch";
|
||||
this.lvWatch.Size = new System.Drawing.Size(826, 296);
|
||||
this.lvWatch.TabIndex = 5;
|
||||
this.lvWatch.UseCompatibleStateImageBehavior = false;
|
||||
this.lvWatch.View = System.Windows.Forms.View.Details;
|
||||
//
|
||||
// chOrder
|
||||
//
|
||||
this.chOrder.Text = "순위";
|
||||
//
|
||||
// chCode
|
||||
//
|
||||
this.chCode.Text = "종목코드";
|
||||
//
|
||||
// chName
|
||||
//
|
||||
this.chName.Text = "종목명";
|
||||
//
|
||||
// chCurPrice
|
||||
//
|
||||
this.chCurPrice.Text = "현재가";
|
||||
this.chCurPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chComp
|
||||
//
|
||||
this.chComp.Text = "전일대비";
|
||||
this.chComp.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chCompRate
|
||||
//
|
||||
this.chCompRate.Text = "대비율";
|
||||
this.chCompRate.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chVolume
|
||||
//
|
||||
this.chVolume.Text = "거래량";
|
||||
this.chVolume.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chBidPrice
|
||||
//
|
||||
this.chBidPrice.Text = "매수호가";
|
||||
this.chBidPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chBidCnt
|
||||
//
|
||||
this.chBidCnt.Text = "호가잔량";
|
||||
this.chBidCnt.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// ULMonitorDlg
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(850, 320);
|
||||
this.Controls.Add(this.lvWatch);
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Name = "ULMonitorDlg";
|
||||
this.Text = "ULMonitorDlg";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListView lvWatch;
|
||||
private System.Windows.Forms.ColumnHeader chOrder;
|
||||
private System.Windows.Forms.ColumnHeader chName;
|
||||
private System.Windows.Forms.ColumnHeader chCurPrice;
|
||||
private System.Windows.Forms.ColumnHeader chComp;
|
||||
private System.Windows.Forms.ColumnHeader chCompRate;
|
||||
private System.Windows.Forms.ColumnHeader chVolume;
|
||||
private System.Windows.Forms.ColumnHeader chBidPrice;
|
||||
private System.Windows.Forms.ColumnHeader chBidCnt;
|
||||
private System.Windows.Forms.ColumnHeader chCode;
|
||||
}
|
||||
}
|
||||
192
ULMonitorDlg.cs
Normal file
192
ULMonitorDlg.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace upper_limit_crawler
|
||||
{
|
||||
public partial class ULMonitorDlg : Form
|
||||
{
|
||||
const int MONITOR_DELAY = 1500;
|
||||
|
||||
ULDataMgr m_DataMgr;
|
||||
CPSYSDIBLib.CpSvrNew7043 m_7043 = new CPSYSDIBLib.CpSvrNew7043();
|
||||
Timer m_Timer = new Timer();
|
||||
int m_iMonitorDelay = 0;
|
||||
int m_iLastTime = 0;
|
||||
bool m_bRequesting = false;
|
||||
|
||||
DSCBO1Lib.StockCur m_StockCur = new DSCBO1Lib.StockCur();
|
||||
|
||||
public ULMonitorDlg(ULDataMgr DataMgr)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
MainForm.SetDoubleBuffered(lvWatch);
|
||||
|
||||
this.TopLevel = false;
|
||||
|
||||
m_DataMgr = DataMgr;
|
||||
|
||||
m_7043.SetInputValue(0, '0');
|
||||
m_7043.SetInputValue(1, '2');
|
||||
m_7043.SetInputValue(2, '1');
|
||||
m_7043.SetInputValue(3, 21);
|
||||
m_7043.SetInputValue(4, '1');
|
||||
m_7043.SetInputValue(5, '0');
|
||||
m_7043.SetInputValue(6, '0');
|
||||
m_7043.SetInputValue(7, (short)(m_DataMgr.m_Setting.m_fSearchMin*100));
|
||||
m_7043.SetInputValue(8, (short)((m_DataMgr.m_Setting.m_fSearchMax+0.009)*100));
|
||||
|
||||
m_StockCur.Received += StockCur_Received;
|
||||
|
||||
m_Timer.Interval = 100;
|
||||
m_Timer.Tick += Refresh;
|
||||
m_Timer.Start();
|
||||
}
|
||||
|
||||
private void StockCur_Received()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Check()
|
||||
{
|
||||
if (m_bRequesting == true || UlUtil.GetLimitRemainCountRQ() < 30)
|
||||
return false;
|
||||
|
||||
m_bRequesting = true;
|
||||
m_7043.SetInputValue(7, (short)(m_DataMgr.m_Setting.m_fSearchMin * 100));
|
||||
m_7043.SetInputValue(8, (short)((m_DataMgr.m_Setting.m_fSearchMax + 0.009) * 100));
|
||||
int iResult = m_7043.BlockRequest2(1);
|
||||
|
||||
lvWatch.Items.Clear();
|
||||
int iIdx = 1;
|
||||
|
||||
bool bContinue = true;
|
||||
while (bContinue)
|
||||
{
|
||||
int iCnt = m_7043.GetHeaderValue(0);
|
||||
for (int i = 0; i < iCnt; i++)
|
||||
{
|
||||
string strCode = m_7043.GetDataValue(0, i);
|
||||
string strCodeName = m_7043.GetDataValue(1, i);
|
||||
int iCurPrice = m_7043.GetDataValue(2, i);
|
||||
object flag = m_7043.GetDataValue(3, i);
|
||||
int iComp = m_7043.GetDataValue(4, i);
|
||||
float fCompRate = m_7043.GetDataValue(5, i);
|
||||
int iVolume = m_7043.GetDataValue(6, i);
|
||||
int iStartPrice = m_7043.GetDataValue(7, i);
|
||||
int iStartPriceComp = m_7043.GetDataValue(8, i);
|
||||
float fStartPriceCompRate = m_7043.GetDataValue(9, i);
|
||||
int iSerialDay = m_7043.GetDataValue(10, i);
|
||||
|
||||
ListViewItem searchItem = null;
|
||||
if(lvWatch.Items.Count > 0)
|
||||
searchItem = lvWatch.FindItemWithText(strCode, true, 0, false);
|
||||
|
||||
if(searchItem != null)
|
||||
{
|
||||
searchItem.SubItems[chOrder.Index].Text = iIdx.ToString();
|
||||
searchItem.SubItems[chCurPrice.Index].Text = iCurPrice.ToString("###,###,###,###");
|
||||
searchItem.SubItems[chComp.Index].Text = iComp.ToString("###,###,###,###");
|
||||
searchItem.SubItems[chCompRate.Index].Text = fCompRate.ToString("#,##0.00");
|
||||
searchItem.SubItems[chVolume.Index].Text = iVolume.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() });
|
||||
lvWatch.Items.Add(listViewItem);
|
||||
}
|
||||
|
||||
iIdx++;
|
||||
|
||||
if (fCompRate >= m_DataMgr.m_Setting.m_fSearchMin * 100 && fCompRate <= m_DataMgr.m_Setting.m_fSearchMax * 100)
|
||||
{
|
||||
m_DataMgr.AddWatch(strCode, strCodeName, iCurPrice, iStartPrice);
|
||||
}
|
||||
}
|
||||
|
||||
bContinue = (m_7043.Continue == 1);
|
||||
if (bContinue == true && UlUtil.GetLimitRemainCountRQ() >= 30)
|
||||
iResult = m_7043.BlockRequest2(1);
|
||||
}
|
||||
|
||||
//foreach (ColumnHeader col in lvWatch.Columns)
|
||||
// col.Width = -2;
|
||||
|
||||
m_bRequesting = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RefreshData()
|
||||
{
|
||||
Dictionary<string, WATCH_ITEM> WatchList = m_DataMgr.GetWatchList();
|
||||
foreach (ListViewItem lvItem in lvWatch.Items)
|
||||
{
|
||||
string strCode = lvItem.SubItems[chCode.Index].Text;
|
||||
if (WatchList.ContainsKey(strCode) == true)
|
||||
{
|
||||
WATCH_ITEM item = WatchList[strCode];
|
||||
|
||||
int iDisplayCurPrice = 0;
|
||||
if (lvItem.SubItems[chCurPrice.Index].Text.Length > 0)
|
||||
iDisplayCurPrice = int.Parse(Regex.Replace(lvItem.SubItems[chCurPrice.Index].Text, @"\D", ""));
|
||||
|
||||
if (item.m_iCurPrice != iDisplayCurPrice && item.m_iCurPrice != 0)
|
||||
{
|
||||
int iComp = item.m_iCurPrice - item.m_iPrevClosing;
|
||||
float fCompRate = item.m_iCurPrice / (float)item.m_iPrevClosing - 1.0f;
|
||||
|
||||
lvItem.SubItems[chCurPrice.Index].Text = item.m_iCurPrice.ToString("###,###,###,###");
|
||||
lvItem.SubItems[chComp.Index].Text = iComp.ToString("###,###,###,###");
|
||||
lvItem.SubItems[chCompRate.Index].Text = fCompRate.ToString("#,##0.00%") + "%";
|
||||
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 &&
|
||||
m_DataMgr.IsInBlackList(strCode) == false)
|
||||
{
|
||||
// bid and add to black list
|
||||
UlUtil.Trace(string.Format("[{0}] 조건 매수 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate));
|
||||
|
||||
m_DataMgr.GetTrader().Buy(strCode, item.m_iCurPrice, (int)m_DataMgr.m_Setting.m_fBidAmount);
|
||||
m_DataMgr.AddBlackList(strCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Refresh(object sender, EventArgs e)
|
||||
{
|
||||
int iCurTime = Environment.TickCount;
|
||||
if (m_iLastTime == 0)
|
||||
{
|
||||
m_iLastTime = iCurTime;
|
||||
return;
|
||||
}
|
||||
|
||||
int iDeltaT = iCurTime - m_iLastTime;
|
||||
m_iMonitorDelay -= iDeltaT;
|
||||
if (m_iMonitorDelay <= 0)
|
||||
{
|
||||
bool bRequest = Check();
|
||||
m_iMonitorDelay = (bRequest == true) ? MONITOR_DELAY : 1000;
|
||||
}
|
||||
|
||||
RefreshData();
|
||||
|
||||
m_iLastTime = iCurTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
ULMonitorDlg.resx
Normal file
120
ULMonitorDlg.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
35
ULTrader.cs
35
ULTrader.cs
@@ -53,6 +53,20 @@ namespace upper_limit_crawler
|
||||
|
||||
string strLog = "";
|
||||
|
||||
if (strTradeType == "1") // 정상주문
|
||||
{ strLog += "[정상주문]"; }
|
||||
else if (strTradeType == "2") // 정정주문
|
||||
{ strLog += "[정정주문]"; }
|
||||
else if (strTradeType == "3") // 취소주문
|
||||
{ strLog += "[취소주문]"; }
|
||||
|
||||
if (bBuy == true)
|
||||
strLog += "(매수) ";
|
||||
else
|
||||
strLog += "(매도) ";
|
||||
|
||||
strLog += string.Format("[{0}:{1}] {2:###,###,##0}원 {3:###,###,##0}주 (총{4:###,###,##0}원) ", strCodeName, strCode, iPrice, iCount, iPrice * iCount);
|
||||
|
||||
if (strResult == "1") // 체결
|
||||
{ strLog += "체결"; }
|
||||
else if (strResult == "2") // 확인
|
||||
@@ -62,14 +76,6 @@ namespace upper_limit_crawler
|
||||
else if (strResult == "4") // 접수
|
||||
{ strLog += "접수"; }
|
||||
|
||||
strLog += string.Format("[{0}:{1}] {2:###,###,###}원 {3:###,###,###}주 (총{4:###,###,###}원) ", strCodeName, strCode, iPrice, iCount, iPrice * iCount);
|
||||
|
||||
if (strTradeType == "1") // 정상주문
|
||||
{ strLog += " (정상주문)"; }
|
||||
else if (strTradeType == "2") // 정정주문
|
||||
{ strLog += " (정정주문)"; }
|
||||
else if (strTradeType == "3") // 취소주문
|
||||
{ strLog += " (취소주문)"; }
|
||||
|
||||
UlUtil.Trace(strLog);
|
||||
}
|
||||
@@ -118,6 +124,8 @@ namespace upper_limit_crawler
|
||||
{
|
||||
//lock(lockBuy)
|
||||
{
|
||||
while (UlUtil.GetLimitRemainCountRQ() <= 0) ;
|
||||
|
||||
int iCnt = iBidAmount / iUnitPrice;
|
||||
|
||||
CPTRADELib.CpTd0311 Td0311Bid = new CPTRADELib.CpTd0311();
|
||||
@@ -129,7 +137,7 @@ namespace upper_limit_crawler
|
||||
Td0311Bid.SetInputValue(7, "0");
|
||||
Td0311Bid.SetInputValue(8, "03");
|
||||
|
||||
Td0311Bid.BlockRequest();
|
||||
Td0311Bid.BlockRequest2(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +147,9 @@ namespace upper_limit_crawler
|
||||
{
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
|
||||
while (UlUtil.GetLimitRemainCountRQ() <= 0) ;
|
||||
|
||||
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
|
||||
|
||||
Td0311Ask.SetInputValue(0, "1");
|
||||
@@ -149,7 +160,7 @@ namespace upper_limit_crawler
|
||||
Td0311Ask.SetInputValue(7, "0");
|
||||
Td0311Ask.SetInputValue(8, "03");
|
||||
|
||||
Td0311Ask.BlockRequest();
|
||||
Td0311Ask.BlockRequest2(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +171,8 @@ namespace upper_limit_crawler
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
|
||||
while (UlUtil.GetLimitRemainCountRQ() <= 0);
|
||||
|
||||
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
|
||||
|
||||
Td0311Ask.SetInputValue(0, "1");
|
||||
@@ -170,7 +183,7 @@ namespace upper_limit_crawler
|
||||
Td0311Ask.SetInputValue(7, "0");
|
||||
Td0311Ask.SetInputValue(8, "03");
|
||||
|
||||
Td0311Ask.BlockRequest();
|
||||
Td0311Ask.BlockRequest2(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
169
ULWatch.cs
169
ULWatch.cs
@@ -1,169 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace upper_limit_crawler
|
||||
{
|
||||
class ULWatch : ULObj
|
||||
{
|
||||
const int WATCH_DELAY = 3000;
|
||||
|
||||
DSCBO1Lib.StockMst2 m_StockMst2 = new DSCBO1Lib.StockMst2();
|
||||
int m_iWatchDelay = 0;
|
||||
//bool m_bWatching = false;
|
||||
|
||||
public ULWatch(ULDataMgr DataMgr) : base(DataMgr)
|
||||
{
|
||||
}
|
||||
|
||||
void Check()
|
||||
{
|
||||
////0 - (string) 종목 코드
|
||||
////1 - (string) 종목명
|
||||
////2 - (long) 시간(HHMM)
|
||||
////3 - (long) 현재가
|
||||
////4 - (long) 전일대비
|
||||
////5 - (char) 상태구분
|
||||
//// 코드 내용
|
||||
//// '1' 상한
|
||||
//// '2' 상승
|
||||
//// '3' 보합
|
||||
//// '4' 하한
|
||||
//// '5' 하락
|
||||
//// '6' 기세상한
|
||||
//// '7' 기세상승
|
||||
//// '8' 기세하한
|
||||
//// '9' 기세하락
|
||||
|
||||
////6 - (long) 시가
|
||||
////7 - (long) 고가
|
||||
////8 - (long) 저가
|
||||
////9 - (long) 매도호가
|
||||
////10 - (long) 매수호가
|
||||
////11 - (unsigned long) 거래량 [주의] 단위 1주
|
||||
////12 - (long) 거래대금 [주의] 단위 천원
|
||||
////13 - (long) 총매도잔량
|
||||
////14 - (long) 총매수잔량
|
||||
////15 - (long) 매도잔량
|
||||
////16 - (long) 매수잔량
|
||||
////17 - (unsigned long) 상장주식수
|
||||
////18 - (long) 외국인보유비율(%)
|
||||
////19 - (long) 전일종가
|
||||
////20 - (unsigned long) 전일거래량
|
||||
////21 - (long) 체결강도
|
||||
////22 - (unsigned long) 순간체결량
|
||||
////23 - (char) 체결가비교 Flag
|
||||
//// 코드 내용
|
||||
//// 'O' 매도
|
||||
//// 'B' 매수
|
||||
|
||||
////24 - (char) 호가비교 Flag
|
||||
//// 코드 내용
|
||||
//// 'O' 매도
|
||||
//// 'B' 매수
|
||||
|
||||
////25- (char) 동시호가구분
|
||||
//// 코드 내용
|
||||
//// '1' 동시호가
|
||||
//// '2' 장중
|
||||
|
||||
////26 - (long) 예상체결가
|
||||
////27 - (long) 예상체결가 전일대비
|
||||
////28 - (long) 예상체결가 상태구분
|
||||
//// 코드 내용
|
||||
//// '1' 상한
|
||||
//// '2' 상승
|
||||
//// '3' 보합
|
||||
//// '4' 하한
|
||||
//// '5' 하락
|
||||
//// '6' 기세상한
|
||||
//// '7' 기세상승
|
||||
//// '8' 기세하한
|
||||
//// '9' 기세하락
|
||||
|
||||
////29- (unsigned long) 예상체결가 거래량
|
||||
|
||||
//if (m_bWatching == true || UlUtil.GetLimitRemainCountRQ() < 30)
|
||||
// return;
|
||||
|
||||
//List<WATCH_ITEM> WatchList = m_DataMgr.GetWatchList();
|
||||
//if (WatchList.Count <= 0)
|
||||
// return;
|
||||
|
||||
//string strCodes = "";
|
||||
//for (int i = 0; i < WatchList.Count; i++)
|
||||
//{
|
||||
// if (i > 0)
|
||||
// strCodes += ",";
|
||||
// strCodes += WatchList[i].m_strCode;
|
||||
//}
|
||||
//m_StockMst2.SetInputValue(0, strCodes);
|
||||
|
||||
|
||||
//int iResult = 0;
|
||||
//m_bWatching = true;
|
||||
//iResult = m_StockMst2.BlockRequest2(1);
|
||||
//bool bContinue = true;
|
||||
|
||||
//while (bContinue == true)
|
||||
//{
|
||||
// int iCnt = m_StockMst2.GetHeaderValue(0);
|
||||
// for (int i = 0; i < iCnt; i++)
|
||||
// {
|
||||
// object Code = m_StockMst2.GetDataValue(0, i);
|
||||
// object Name = m_StockMst2.GetDataValue(1, i);
|
||||
// object Time = m_StockMst2.GetDataValue(2, i);
|
||||
// object CurPrice = m_StockMst2.GetDataValue(3, i);
|
||||
// object StartPrice = m_StockMst2.GetDataValue(6, i);
|
||||
// object AskPrice = m_StockMst2.GetDataValue(9, i);
|
||||
// object BidPrice = m_StockMst2.GetDataValue(10, i);
|
||||
// object TradingVolume = m_StockMst2.GetDataValue(11, i);
|
||||
// object AskCount = m_StockMst2.GetDataValue(15, i);
|
||||
// object BidCount = m_StockMst2.GetDataValue(16, i);
|
||||
// float fRatePerStart = ((int)CurPrice - (int)StartPrice) * 100 / (float)(int)StartPrice;
|
||||
|
||||
// //if(fRatePerStart >= 9.5 && fRatePerStart <= 10.0 &&
|
||||
// // m_DataMgr.HasOwnList((string)Code) == false && m_DataMgr.HasDealingList((string)Code) == false)
|
||||
// //{
|
||||
// // m_DataMgr.GetTrader().Buy((string)Code);
|
||||
// // m_DataMgr.AddDealingList((string)Code);
|
||||
// //}
|
||||
// // insert to db
|
||||
|
||||
// // extract if loss
|
||||
|
||||
// // extract if trailing loss
|
||||
// }
|
||||
|
||||
|
||||
// bContinue = (m_StockMst2.Continue == 1);
|
||||
// if (bContinue == true && UlUtil.GetLimitRemainCountRQ() >= 30)
|
||||
// iResult = m_StockMst2.BlockRequest2(1);
|
||||
//}
|
||||
|
||||
//m_bWatching = false;
|
||||
}
|
||||
|
||||
public override void Refresh(int iCurTime)
|
||||
{
|
||||
if (m_iLastTime == 0)
|
||||
{
|
||||
base.Refresh(iCurTime);
|
||||
return;
|
||||
}
|
||||
|
||||
int iDeltaT = iCurTime - m_iLastTime;
|
||||
m_iWatchDelay -= iDeltaT;
|
||||
if(m_iWatchDelay <= 0)
|
||||
{
|
||||
Check();
|
||||
m_iWatchDelay = WATCH_DELAY;
|
||||
}
|
||||
|
||||
base.Refresh(iCurTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
UlUtil.cs
25
UlUtil.cs
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -11,14 +12,22 @@ namespace upper_limit_crawler
|
||||
{
|
||||
public static class UlUtil
|
||||
{
|
||||
static string m_strLogServer = "http://mjjo53.us.to:8000";
|
||||
//static string m_strLogServer = "http://mjjo53.us.to:8000";
|
||||
|
||||
static CPUTILLib.CpCybos m_Util = new CPUTILLib.CpCybos();
|
||||
static TextBox m_tbLog = null;
|
||||
static string m_strLogFileName;
|
||||
|
||||
public static void SetLogView(TextBox tbLog)
|
||||
public static void Init(TextBox tbLog)
|
||||
{
|
||||
m_tbLog = tbLog;
|
||||
|
||||
if (Debugger.IsAttached == true)
|
||||
m_strLogFileName = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName+"\\";
|
||||
m_strLogFileName += "log\\";
|
||||
if (Directory.Exists(m_strLogFileName) == false)
|
||||
Directory.CreateDirectory(m_strLogFileName);
|
||||
m_strLogFileName += "log-" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
}
|
||||
|
||||
public static string GetCurTimeString()
|
||||
@@ -66,8 +75,18 @@ namespace upper_limit_crawler
|
||||
public static void Trace(string strMsg)
|
||||
{
|
||||
string strLog = "["+GetCurTimeString()+"] "+strMsg;
|
||||
|
||||
System.IO.File.AppendAllText(m_strLogFileName, strLog + Environment.NewLine);
|
||||
Console.WriteLine(strLog);
|
||||
//m_tbLog.Text += strLog;
|
||||
|
||||
bool bScrollToEnd = (m_tbLog.SelectionStart == m_tbLog.Text.Length);
|
||||
m_tbLog.Text += strLog + Environment.NewLine;
|
||||
if(bScrollToEnd == true)
|
||||
{
|
||||
m_tbLog.SelectionStart = m_tbLog.Text.Length;
|
||||
m_tbLog.ScrollToCaret();
|
||||
}
|
||||
|
||||
//WebLog(m_strLogServer, strLog);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ULDealing.cs" />
|
||||
<Compile Include="ULDataMgr.cs" />
|
||||
<Compile Include="ULMonitorDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
@@ -83,7 +82,6 @@
|
||||
<Compile Include="ULOwn.cs" />
|
||||
<Compile Include="ULTrader.cs" />
|
||||
<Compile Include="UlUtil.cs" />
|
||||
<Compile Include="ULWatch.cs" />
|
||||
<EmbeddedResource Include="ULBalanceDlg.resx">
|
||||
<DependentUpon>ULBalanceDlg.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
Reference in New Issue
Block a user