- monitor, balance subscribe로 수정

- UI 개선
This commit is contained in:
2016-07-20 23:46:28 +09:00
parent 069557e102
commit 7aec7e8361
14 changed files with 659 additions and 377 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,4 @@
bin/ bin/
obj/ obj/
*.suo *.suo
log/

32
MainForm.Designer.cs generated
View File

@@ -51,6 +51,8 @@
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = 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(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
@@ -102,7 +104,7 @@
this.tbBidAmount.Name = "tbBidAmount"; this.tbBidAmount.Name = "tbBidAmount";
this.tbBidAmount.Size = new System.Drawing.Size(100, 21); this.tbBidAmount.Size = new System.Drawing.Size(100, 21);
this.tbBidAmount.TabIndex = 9; this.tbBidAmount.TabIndex = 9;
this.tbBidAmount.Text = "1,000,000"; this.tbBidAmount.Text = "100,000";
this.tbBidAmount.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.tbBidAmount.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
// //
// tbTimeout // tbTimeout
@@ -201,7 +203,7 @@
this.tbSearchMin.Name = "tbSearchMin"; this.tbSearchMin.Name = "tbSearchMin";
this.tbSearchMin.Size = new System.Drawing.Size(37, 21); this.tbSearchMin.Size = new System.Drawing.Size(37, 21);
this.tbSearchMin.TabIndex = 14; this.tbSearchMin.TabIndex = 14;
this.tbSearchMin.Text = "9.0%"; this.tbSearchMin.Text = "7.0%";
this.tbSearchMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.tbSearchMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
// //
// btApply // btApply
@@ -281,6 +283,8 @@
// //
// splitContainer2.Panel2 // 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.btBalance);
this.splitContainer2.Panel2.Controls.Add(this.label1); this.splitContainer2.Panel2.Controls.Add(this.label1);
this.splitContainer2.Panel2.Controls.Add(this.label5); this.splitContainer2.Panel2.Controls.Add(this.label5);
@@ -314,6 +318,24 @@
this.splitContainer3.SplitterDistance = 231; this.splitContainer3.SplitterDistance = 231;
this.splitContainer3.TabIndex = 0; 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 // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -321,7 +343,7 @@
this.ClientSize = new System.Drawing.Size(886, 642); this.ClientSize = new System.Drawing.Size(886, 642);
this.Controls.Add(this.splitContainer1); this.Controls.Add(this.splitContainer1);
this.Name = "MainForm"; this.Name = "MainForm";
this.Text = "Form1"; this.Text = "Upper Limit";
this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout(); this.splitContainer1.Panel2.PerformLayout();
@@ -362,6 +384,8 @@
private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.SplitContainer splitContainer2; private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.SplitContainer splitContainer3; private System.Windows.Forms.SplitContainer splitContainer3;
} private System.Windows.Forms.Label lbRQCnt;
private System.Windows.Forms.Label lbSBCnt;
}
} }

View File

@@ -25,8 +25,6 @@ namespace upper_limit_crawler
int m_iLastTime = 0; int m_iLastTime = 0;
static ULDataMgr m_DataMgr = new ULDataMgr(); 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); ULOwn m_Own = new ULOwn(m_DataMgr);
ULMonitorDlg m_MonitorDlg = null; ULMonitorDlg m_MonitorDlg = null;
@@ -35,7 +33,10 @@ namespace upper_limit_crawler
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
//UlUtil.SetLogView(tbLog);
SetDoubleBuffered(tbLog);
UlUtil.Init(tbLog);
btApply_Click(null, null); btApply_Click(null, null);
@@ -96,10 +97,11 @@ namespace upper_limit_crawler
int iDeltaT = iCurTime - m_iLastTime; int iDeltaT = iCurTime - m_iLastTime;
m_Watch.Refresh(iCurTime);
m_Dealing.Refresh(iCurTime);
m_Own.Refresh(iCurTime); m_Own.Refresh(iCurTime);
lbRQCnt.Text = "RQ Count : " + UlUtil.GetLimitRemainCountRQ().ToString();
lbSBCnt.Text = "SB Count : " + UlUtil.GetLimitRemainCountSB().ToString();
m_iLastTime = iCurTime; m_iLastTime = iCurTime;
} }
@@ -115,10 +117,10 @@ namespace upper_limit_crawler
{ {
try try
{ {
m_DataMgr.m_Setting.m_fSearchMin = float.Parse(tbSearchMin.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("%", "")); m_DataMgr.m_Setting.m_fSearchMax = float.Parse(tbSearchMax.Text.Replace("%", ""))/100;
m_DataMgr.m_Setting.m_fBidMin = float.Parse(tbBidMin.Text.Replace("%", "")); m_DataMgr.m_Setting.m_fBidMin = float.Parse(tbBidMin.Text.Replace("%", ""))/100;
m_DataMgr.m_Setting.m_fBidMax = float.Parse(tbBidMax.Text.Replace("%", "")); 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_fBidAmount = float.Parse(tbBidAmount.Text);
m_DataMgr.m_Setting.m_fTimeout = float.Parse(tbTimeout.Text); m_DataMgr.m_Setting.m_fTimeout = float.Parse(tbTimeout.Text);
m_DataMgr.m_Setting.m_fTrailing = float.Parse(tbTrailing.Text.Replace("%", ""))/100; 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) private void btCancel_Click(object sender, EventArgs e)
{ {
tbSearchMin.Text = m_DataMgr.m_Setting.m_fSearchMin.ToString("0.0")+"%"; tbSearchMin.Text = (m_DataMgr.m_Setting.m_fSearchMin*100).ToString("0.0") + "%";
tbSearchMax.Text = m_DataMgr.m_Setting.m_fSearchMax.ToString("0.0") + "%"; tbSearchMax.Text = (m_DataMgr.m_Setting.m_fSearchMax*100).ToString("0.0") + "%";
tbBidMin.Text = m_DataMgr.m_Setting.m_fBidMin.ToString("0.0") + "%"; tbBidMin.Text = (m_DataMgr.m_Setting.m_fBidMin*100).ToString("0.0") + "%";
tbBidMax.Text = m_DataMgr.m_Setting.m_fBidMax.ToString("0.0") + "%"; tbBidMax.Text = (m_DataMgr.m_Setting.m_fBidMax*100).ToString("0.0") + "%";
tbBidAmount.Text = m_DataMgr.m_Setting.m_fBidAmount.ToString("###,###,###,###,###"); tbBidAmount.Text = m_DataMgr.m_Setting.m_fBidAmount.ToString("###,###,###,###,###");
tbTimeout.Text = m_DataMgr.m_Setting.m_fTimeout.ToString("0.###"); tbTimeout.Text = m_DataMgr.m_Setting.m_fTimeout.ToString("0.###");
tbTrailing.Text = m_DataMgr.m_Setting.m_fTrailing.ToString("0.0%"); tbTrailing.Text = (m_DataMgr.m_Setting.m_fTrailing*100).ToString("0.0") + "%";
tbLossCut.Text = m_DataMgr.m_Setting.m_fLossCut.ToString("0.0%"); tbLossCut.Text = (m_DataMgr.m_Setting.m_fLossCut*100).ToString("0.0") + "%";
} }
} }
} }

View File

@@ -34,7 +34,7 @@
this.chUnitBuyPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chUnitBuyPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chUnitBEP = ((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.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.chBalance = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chEvaluationPrice = ((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.chProfitRate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@@ -54,7 +54,7 @@
this.chUnitBuyPrice, this.chUnitBuyPrice,
this.chUnitBEP, this.chUnitBEP,
this.chCurPrice, this.chCurPrice,
this.chUnitProfit, this.chEvaluationProfit,
this.chBalance, this.chBalance,
this.chEvaluationPrice, this.chEvaluationPrice,
this.chProfitRate}); this.chProfitRate});
@@ -93,10 +93,10 @@
this.chCurPrice.Text = "현재가"; this.chCurPrice.Text = "현재가";
this.chCurPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.chCurPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
// //
// chUnitProfit // chEvaluationProfit
// //
this.chUnitProfit.Text = "평가손익"; this.chEvaluationProfit.Text = "평가손익";
this.chUnitProfit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.chEvaluationProfit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
// //
// chBalance // chBalance
// //
@@ -171,7 +171,7 @@
private System.Windows.Forms.ColumnHeader chCurPrice; private System.Windows.Forms.ColumnHeader chCurPrice;
private System.Windows.Forms.ColumnHeader chBalance; private System.Windows.Forms.ColumnHeader chBalance;
private System.Windows.Forms.ColumnHeader chUnitBEP; 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.ColumnHeader chProfitRate;
private System.Windows.Forms.Button btRefresh; private System.Windows.Forms.Button btRefresh;
private System.Windows.Forms.ColumnHeader chCode; private System.Windows.Forms.ColumnHeader chCode;

View File

@@ -5,6 +5,7 @@ using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@@ -13,7 +14,6 @@ namespace upper_limit_crawler
public partial class ULBalanceDlg : Form public partial class ULBalanceDlg : Form
{ {
const int BALANCE_DELAY = 10000; const int BALANCE_DELAY = 10000;
const int PRICE_DELAY = 500;
public class OWN_ITEM public class OWN_ITEM
{ {
@@ -23,7 +23,7 @@ namespace upper_limit_crawler
public int m_iConclusionBalanceCnt; public int m_iConclusionBalanceCnt;
public long m_iEvaluationPrice; public long m_iEvaluationPrice;
public long m_iEvaluationProfit; public long m_iEvaluationProfit;
public double m_dReturn; public double m_dProfitRate;
public string m_strCode; public string m_strCode;
public int m_iAskableCnt; public int m_iAskableCnt;
public double m_dConclusionUnitPrice; public double m_dConclusionUnitPrice;
@@ -42,18 +42,18 @@ namespace upper_limit_crawler
Timer m_MainTimer = new Timer(); Timer m_MainTimer = new Timer();
int m_iLastTime = 0; int m_iLastTime = 0;
int m_iBalanceDelay = BALANCE_DELAY; int m_iBalanceDelay = BALANCE_DELAY;
int m_iPriceDelay = PRICE_DELAY;
ULDataMgr m_DataMgr = null; ULDataMgr m_DataMgr = null;
CPTRADELib.CpTd6033 m_Td6033 = new CPTRADELib.CpTd6033(); CPTRADELib.CpTd6033 m_Td6033 = new CPTRADELib.CpTd6033();
DSCBO1Lib.StockCur m_StockCur = new DSCBO1Lib.StockCur();
bool m_bRequesting = false;
public ULBalanceDlg(ULDataMgr DataMgr) public ULBalanceDlg(ULDataMgr DataMgr)
{ {
InitializeComponent(); InitializeComponent();
MainForm.SetDoubleBuffered(lvBalance);
this.TopLevel = false; this.TopLevel = false;
m_DataMgr = DataMgr; m_DataMgr = DataMgr;
@@ -83,58 +83,60 @@ namespace upper_limit_crawler
int iCnt = m_Td6033.GetHeaderValue(7); int iCnt = m_Td6033.GetHeaderValue(7);
for(int i = 0; i<iCnt; i++) for(int i = 0; i<iCnt; i++)
{ {
string strCode = m_Td6033.GetDataValue(12, i);
string strCodeName = m_Td6033.GetDataValue(0, i); string strCodeName = m_Td6033.GetDataValue(0, i);
int iPayBalance = m_Td6033.GetDataValue(3, i); // 결제 잔고수량 int iPayBalance = m_Td6033.GetDataValue(3, i); // 결제 잔고수량
int iPayUnitPrice = m_Td6033.GetDataValue(4, 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 iEvaluationPrice = m_Td6033.GetDataValue(9, i); // 평가금액 : 보유수량x현재가
long iEvaluationProfit = m_Td6033.GetDataValue(10, i); // 평가손익 long iEvaluationProfit = m_Td6033.GetDataValue(10, i); // 평가손익
double dReturn = m_Td6033.GetDataValue(11, i); // 수익률 double dReturn = m_Td6033.GetDataValue(11, i); // 수익률
string strCode = m_Td6033.GetDataValue(12, i); int iAskableCnt = m_Td6033.GetDataValue(15, i); // 매도 가능 수량
int iAskableCnt = m_Td6033.GetDataValue(15, i); // 매도 가능 수량 double dConclusionUnitPrice = m_Td6033.GetDataValue(17, i); // 체결 장부단가
double dConclusionUnitPrice = m_Td6033.GetDataValue(17, i); // 체결 장부단가 long iUnitBEP = m_Td6033.GetDataValue(18, i); // 손익단가 : 수수료 포함 순익 분기점 Break-Even Point
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); m_DataMgr.AddWatch(strCode, strCodeName, iCurPrice, iCurPrice);
if (item == null)
OWN_ITEM OwnItem = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode);
if (OwnItem == null)
{ {
item = new OWN_ITEM(); OwnItem = new OWN_ITEM();
m_OwnList.Add(item); m_OwnList.Add(OwnItem);
} }
item.m_strCodeName = strCodeName; OwnItem.m_strCodeName = strCodeName;
item.m_iPayBalance = iPayBalance; OwnItem.m_iPayBalance = iPayBalance;
item.m_iPayUnitPrice = iPayUnitPrice; OwnItem.m_iPayUnitPrice = iPayUnitPrice;
item.m_iConclusionBalanceCnt = iConclusionBalanceCnt; OwnItem.m_iConclusionBalanceCnt = iConclusionBalanceCnt;
item.m_iEvaluationPrice = iEvaluationPrice; OwnItem.m_iEvaluationPrice = iEvaluationPrice;
item.m_iEvaluationProfit = iEvaluationProfit; OwnItem.m_iEvaluationProfit = iEvaluationProfit;
item.m_dReturn = dReturn; OwnItem.m_dProfitRate = dReturn;
item.m_strCode = strCode; OwnItem.m_strCode = strCode;
item.m_iAskableCnt = iAskableCnt; OwnItem.m_iAskableCnt = iAskableCnt;
item.m_dConclusionUnitPrice = dConclusionUnitPrice; OwnItem.m_dConclusionUnitPrice = dConclusionUnitPrice;
item.m_iUnitBEP = iUnitBEP; OwnItem.m_iUnitBEP = iUnitBEP;
item.m_iCurPrice = iCurPrice; OwnItem.m_iCurPrice = iCurPrice;
item.m_iMaxPrice = iCurPrice; OwnItem.m_iMaxPrice = iCurPrice;
item.m_bCheck = true; 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"), iUnitBEP.ToString("###,###,##0"), iCurPrice.ToString("###,###,##0"),
iEvaluationProfit.ToString("###,###,##0"), iConclusionBalanceCnt.ToString("###,###,##0"), iEvaluationProfit.ToString("###,###,##0"), iConclusionBalanceCnt.ToString("###,###,##0"),
iEvaluationPrice.ToString("###,###,##0"), dReturn.ToString("#,##0.00")+"%" }; iEvaluationPrice.ToString("###,###,##0"), dReturn.ToString("#,##0.00")+"%" });
ListViewItem listViewItem = new ListViewItem(row);
listViewItem.UseItemStyleForSubItems = false; listViewItem.UseItemStyleForSubItems = false;
if(iEvaluationProfit > 0)
listViewItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Red;
else
listViewItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Blue;
if (dReturn > 0) if (dReturn > 0)
listViewItem.SubItems[chProfitRate.Index].ForeColor = Color.Red; listViewItem.SubItems[chProfitRate.Index].ForeColor = Color.Red;
else if (dReturn < 0) else if (dReturn < 0)
listViewItem.SubItems[chProfitRate.Index].ForeColor = Color.Blue; 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}", lvBalance.Items.Add(listViewItem);
// strCodeName, iPayBalance, iPayUnitPrice,
// iConclusionBalanceCnt, iEvaluationPrice, iEvaluationProfit,
// dReturn, strCode, iAskableCnt, dConclusionUnitPrice, iUnitBEP));
} }
m_OwnList.RemoveAll(c => c.m_bCheck = false); m_OwnList.RemoveAll(c => c.m_bCheck = false);
@@ -145,59 +147,64 @@ namespace upper_limit_crawler
private void RefreshCurPrice() private void RefreshCurPrice()
{ {
if (m_bRequesting == true) Dictionary<string, WATCH_ITEM> WatchList = m_DataMgr.GetWatchList();
return; foreach (ListViewItem lvItem in lvBalance.Items)
m_bRequesting = true;
if (m_OwnList.Count <= 0)
return;
string strPriceList = "";
foreach(OWN_ITEM item in m_OwnList)
{ {
if (strPriceList.Length > 0) string strCode = lvItem.SubItems[chCode.Index].Text;
strPriceList += ","; if (WatchList.ContainsKey(strCode) == true)
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);
// 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)
{ {
lvItem.SubItems[chCurPrice.Index].Text = iCurPrice.ToString("###,###,##0"); WATCH_ITEM WatchItem = WatchList[strCode];
lvItem.SubItems[chUnitProfit.Index].Text = (iCurPrice - listItem.m_iUnitBEP).ToString("###,###,##0"); OWN_ITEM OwnItem = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode);
lvItem.SubItems[chEvaluationPrice.Index].Text = (iCurPrice*listItem.m_iConclusionBalanceCnt).ToString("###,###,##0"); int iDisplayCurPrice = 0;
lvItem.SubItems[chProfitRate.Index].Text = (iCurPrice / (float)listItem.m_iUnitBEP - 1.0f).ToString("#,##0.00%"); if (lvItem.SubItems[chCurPrice.Index].Text.Length > 0)
} iDisplayCurPrice = int.Parse(Regex.Replace(lvItem.SubItems[chCurPrice.Index].Text, @"\D", ""));
// cut loss and trailing if (WatchItem.m_iCurPrice != iDisplayCurPrice && iDisplayCurPrice != 0)
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)) int iCurPrice = WatchItem.m_iCurPrice;
{ int iComp = iCurPrice - (int)OwnItem.m_iUnitBEP; // or OwnItem.m_dConclusionUnitPrice
m_DataMgr.GetTrader().SellCurPrice(listItem.m_strCode, listItem.m_iPayBalance);
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[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;
OwnItem.m_iMaxPrice = Math.Max(iCurPrice, OwnItem.m_iMaxPrice);
// loss cut
if (iCurPrice <= OwnItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut))
{
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) private void RefreshData(object sender, EventArgs e)
@@ -217,13 +224,7 @@ namespace upper_limit_crawler
m_iBalanceDelay=BALANCE_DELAY; m_iBalanceDelay=BALANCE_DELAY;
} }
m_iPriceDelay -= iDeltaT; RefreshCurPrice();
if(m_iPriceDelay<= 0 && UlUtil.GetLimitRemainCountRQ() >= m_OwnList.Count)
{
RefreshCurPrice();
m_iPriceDelay = PRICE_DELAY;
}
m_iLastTime=iCurTime; m_iLastTime=iCurTime;
} }
@@ -237,11 +238,11 @@ namespace upper_limit_crawler
{ {
foreach(ListViewItem item in lvBalance.SelectedItems) foreach(ListViewItem item in lvBalance.SelectedItems)
{ {
UlUtil.Trace(string.Format("[{0}] 수동 매도", item.SubItems[chName.Index].Text));
string strCode = item.SubItems[chCode.Index].Text; string strCode = item.SubItems[chCode.Index].Text;
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text); int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);
m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt); m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt);
UlUtil.Trace("");
} }
} }
@@ -249,11 +250,11 @@ namespace upper_limit_crawler
{ {
foreach (ListViewItem item in lvBalance.Items) foreach (ListViewItem item in lvBalance.Items)
{ {
UlUtil.Trace(string.Format("[{0}] 모두 청산", item.SubItems[chName.Index].Text));
string strCode = item.SubItems[chCode.Index].Text; string strCode = item.SubItems[chCode.Index].Text;
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text); int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);
m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt); m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt);
UlUtil.Trace("");
} }
} }

View File

@@ -20,24 +20,10 @@ namespace upper_limit_crawler
public float m_fLossCut; 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 class WATCH_ITEM
{ {
public string m_strCode; public string m_strCode;
public string m_strCodeName;
public DSCBO1Lib.StockCur m_StockCur = null; public DSCBO1Lib.StockCur m_StockCur = null;
public int m_iCurPrice; public int m_iCurPrice;
@@ -56,7 +42,6 @@ namespace upper_limit_crawler
ULTrader m_Trader = new ULTrader(); 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>(); Dictionary<string, WATCH_ITEM> m_WatchList = new Dictionary<string, WATCH_ITEM>();
List<string> m_BlackList = new List<string>(); List<string> m_BlackList = new List<string>();
@@ -75,23 +60,14 @@ namespace upper_limit_crawler
return m_Trader; return m_Trader;
} }
public void ClearMonitor() public void AddWatch(string strCode, string strCodeName, int iCurPrice, int iPrevClosing)
{
m_MonitorList.Clear();
}
public void AddMonitor(MONITOR_ITEM Item)
{
m_MonitorList.Add(Item);
}
public void AddWatch(string strCode, int iCurPrice, int iPrevClosing)
{ {
if (m_WatchList.ContainsKey(strCode)) if (m_WatchList.ContainsKey(strCode))
return; return;
WATCH_ITEM item = new WATCH_ITEM(); WATCH_ITEM item = new WATCH_ITEM();
item.m_strCode = strCode; item.m_strCode = strCode;
item.m_strCodeName = strCodeName;
item.m_iCurPrice = iCurPrice; item.m_iCurPrice = iCurPrice;
item.m_iPrevClosing = iPrevClosing; item.m_iPrevClosing = iPrevClosing;
@@ -108,6 +84,7 @@ namespace upper_limit_crawler
foreach(KeyValuePair<string, WATCH_ITEM> item in m_WatchList) foreach(KeyValuePair<string, WATCH_ITEM> item in m_WatchList)
{ {
item.Value.m_iCurPrice = item.Value.m_StockCur.GetHeaderValue(13); 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_iStartPrice = item.Value.m_StockCur.GetHeaderValue(4);
item.Value.m_iHighestPrice = item.Value.m_StockCur.GetHeaderValue(5); item.Value.m_iHighestPrice = item.Value.m_StockCur.GetHeaderValue(5);
item.Value.m_iVolume = item.Value.m_StockCur.GetHeaderValue(9); item.Value.m_iVolume = item.Value.m_StockCur.GetHeaderValue(9);
@@ -126,11 +103,6 @@ namespace upper_limit_crawler
return m_BlackList.Contains(strCode); return m_BlackList.Contains(strCode);
} }
public List<MONITOR_ITEM> GetMonitor()
{
return m_MonitorList;
}
public Dictionary<string, WATCH_ITEM> GetWatchList() public Dictionary<string, WATCH_ITEM> GetWatchList()
{ {
return m_WatchList; return m_WatchList;

View File

@@ -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
View 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
View 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
View 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>

View File

@@ -53,6 +53,20 @@ namespace upper_limit_crawler
string strLog = ""; 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") // 체결 if (strResult == "1") // 체결
{ strLog += "체결"; } { strLog += "체결"; }
else if (strResult == "2") // 확인 else if (strResult == "2") // 확인
@@ -62,14 +76,6 @@ namespace upper_limit_crawler
else if (strResult == "4") // 접수 else if (strResult == "4") // 접수
{ strLog += "접수"; } { 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); UlUtil.Trace(strLog);
} }
@@ -118,7 +124,9 @@ namespace upper_limit_crawler
{ {
//lock(lockBuy) //lock(lockBuy)
{ {
int iCnt = iBidAmount / iUnitPrice; while (UlUtil.GetLimitRemainCountRQ() <= 0) ;
int iCnt = iBidAmount / iUnitPrice;
CPTRADELib.CpTd0311 Td0311Bid = new CPTRADELib.CpTd0311(); CPTRADELib.CpTd0311 Td0311Bid = new CPTRADELib.CpTd0311();
Td0311Bid.SetInputValue(0, "2"); Td0311Bid.SetInputValue(0, "2");
@@ -129,7 +137,7 @@ namespace upper_limit_crawler
Td0311Bid.SetInputValue(7, "0"); Td0311Bid.SetInputValue(7, "0");
Td0311Bid.SetInputValue(8, "03"); Td0311Bid.SetInputValue(8, "03");
Td0311Bid.BlockRequest(); Td0311Bid.BlockRequest2(1);
} }
} }
@@ -137,9 +145,12 @@ namespace upper_limit_crawler
{ {
//lock (lockSell) //lock (lockSell)
{ {
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice); //long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
//iCnt=1; //iCnt=1;
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
while (UlUtil.GetLimitRemainCountRQ() <= 0) ;
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
Td0311Ask.SetInputValue(0, "1"); Td0311Ask.SetInputValue(0, "1");
Td0311Ask.SetInputValue(1, m_astrAccounts[0]); Td0311Ask.SetInputValue(1, m_astrAccounts[0]);
@@ -149,7 +160,7 @@ namespace upper_limit_crawler
Td0311Ask.SetInputValue(7, "0"); Td0311Ask.SetInputValue(7, "0");
Td0311Ask.SetInputValue(8, "03"); Td0311Ask.SetInputValue(8, "03");
Td0311Ask.BlockRequest(); Td0311Ask.BlockRequest2(1);
} }
} }
@@ -157,8 +168,10 @@ namespace upper_limit_crawler
{ {
//lock (lockSell) //lock (lockSell)
{ {
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice); //long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
//iCnt=1; //iCnt=1;
while (UlUtil.GetLimitRemainCountRQ() <= 0);
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311(); CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
@@ -170,7 +183,7 @@ namespace upper_limit_crawler
Td0311Ask.SetInputValue(7, "0"); Td0311Ask.SetInputValue(7, "0");
Td0311Ask.SetInputValue(8, "03"); Td0311Ask.SetInputValue(8, "03");
Td0311Ask.BlockRequest(); Td0311Ask.BlockRequest2(1);
} }
} }
} }

View File

@@ -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);
}
}
}

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
@@ -11,14 +12,22 @@ namespace upper_limit_crawler
{ {
public static class UlUtil 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 CPUTILLib.CpCybos m_Util = new CPUTILLib.CpCybos();
static TextBox m_tbLog = null; static TextBox m_tbLog = null;
static string m_strLogFileName;
public static void SetLogView(TextBox tbLog) public static void Init(TextBox tbLog)
{ {
m_tbLog = 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() public static string GetCurTimeString()
@@ -66,8 +75,18 @@ namespace upper_limit_crawler
public static void Trace(string strMsg) public static void Trace(string strMsg)
{ {
string strLog = "["+GetCurTimeString()+"] "+strMsg; string strLog = "["+GetCurTimeString()+"] "+strMsg;
System.IO.File.AppendAllText(m_strLogFileName, strLog + Environment.NewLine);
Console.WriteLine(strLog); 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); //WebLog(m_strLogServer, strLog);
} }

View File

@@ -71,7 +71,6 @@
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ULDealing.cs" />
<Compile Include="ULDataMgr.cs" /> <Compile Include="ULDataMgr.cs" />
<Compile Include="ULMonitorDlg.cs"> <Compile Include="ULMonitorDlg.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
@@ -83,7 +82,6 @@
<Compile Include="ULOwn.cs" /> <Compile Include="ULOwn.cs" />
<Compile Include="ULTrader.cs" /> <Compile Include="ULTrader.cs" />
<Compile Include="UlUtil.cs" /> <Compile Include="UlUtil.cs" />
<Compile Include="ULWatch.cs" />
<EmbeddedResource Include="ULBalanceDlg.resx"> <EmbeddedResource Include="ULBalanceDlg.resx">
<DependentUpon>ULBalanceDlg.cs</DependentUpon> <DependentUpon>ULBalanceDlg.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>