가격 체크 기능 추가
This commit is contained in:
@@ -14,6 +14,7 @@ namespace NewsCrawler
|
||||
CPFORETRADELib.CpForeTdUtil m_CPUtil = new CPFORETRADELib.CpForeTdUtil();
|
||||
DSCBO1Lib.StockMst m_CPStockMst = new DSCBO1Lib.StockMst();
|
||||
CPTRADELib.CpTd0311 m_CP0311 = new CPTRADELib.CpTd0311();
|
||||
CPSYSDIBLib.StockChart m_StockChart = new CPSYSDIBLib.StockChart();
|
||||
bool m_bInitialized = false;
|
||||
|
||||
System.Timers.Timer m_timer = new System.Timers.Timer();
|
||||
@@ -85,7 +86,7 @@ namespace NewsCrawler
|
||||
{
|
||||
m_timer.Enabled = false;
|
||||
|
||||
if(GetLimitRemainCountTrace() < 5)
|
||||
if(GetLimitRemainCountRQ() < 5)
|
||||
return;
|
||||
|
||||
CPSYSDIBLib.CpMarketWatch Watch = new CPSYSDIBLib.CpMarketWatch();
|
||||
@@ -132,7 +133,7 @@ namespace NewsCrawler
|
||||
return m_CPUtil.AccountNumber;
|
||||
}
|
||||
|
||||
public int GetLimitRemainCountTrace()
|
||||
public int GetLimitRemainCountTrade()
|
||||
{
|
||||
return m_CPCybos.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_TRADE_REQUEST);
|
||||
}
|
||||
@@ -152,6 +153,63 @@ namespace NewsCrawler
|
||||
return (m_CPCybos.IsConnect==1);
|
||||
}
|
||||
|
||||
public int GetCurPrice(CodeList.CODE_VALUE Code)
|
||||
{
|
||||
m_CPStockMst.SetInputValue(0, Code.m_strCode);
|
||||
m_CPStockMst.BlockRequest2(0);
|
||||
int iCurPrice = m_CPStockMst.GetHeaderValue(13);
|
||||
return iCurPrice;
|
||||
}
|
||||
|
||||
public void GetLowHighPrice(CodeList.CODE_VALUE Code, DateTime StartTime, int iAfterMin, out int iPriceLow, out int iPriceHigh)
|
||||
{
|
||||
iPriceLow = 1000000;
|
||||
iPriceHigh = 0;
|
||||
|
||||
if(GetLimitRemainCountRQ() < 5)
|
||||
return;
|
||||
|
||||
string strTime = StartTime.ToString("yyyyMMdd");
|
||||
|
||||
m_StockChart.SetInputValue(0, Code.m_strCode);
|
||||
m_StockChart.SetInputValue(1, '1');
|
||||
m_StockChart.SetInputValue(2, strTime);
|
||||
m_StockChart.SetInputValue(3, strTime);
|
||||
m_StockChart.SetInputValue(4, 20);
|
||||
m_StockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5, });
|
||||
m_StockChart.SetInputValue(6, 'm');
|
||||
m_StockChart.SetInputValue(7, 1);
|
||||
m_StockChart.BlockRequest2(0);
|
||||
|
||||
int iTimeStart;
|
||||
int.TryParse(StartTime.ToString("HHmm"), out iTimeStart);
|
||||
|
||||
int iCheckCnt = 0;
|
||||
|
||||
int iCount = m_StockChart.GetHeaderValue(3);
|
||||
for(int i=0; i<iCount; i++)
|
||||
{
|
||||
uint uiDate = m_StockChart.GetDataValue(0, i);
|
||||
long iTime = m_StockChart.GetDataValue(1, i);
|
||||
|
||||
if(iTime >= iTimeStart && iTime <= iTimeStart+iAfterMin)
|
||||
{
|
||||
long iPriceStartLocal = m_StockChart.GetDataValue(2, i);
|
||||
long iPriceHighLocal = m_StockChart.GetDataValue(3, i);
|
||||
long iPriceLowLocal = m_StockChart.GetDataValue(4, i);
|
||||
long iPriceEndLocal = m_StockChart.GetDataValue(5, i);
|
||||
|
||||
iPriceLow = Math.Min(iPriceLow, (int)iPriceLowLocal);
|
||||
iPriceHigh = Math.Max(iPriceLow, (int)iPriceHighLocal);
|
||||
|
||||
iCheckCnt++;
|
||||
}
|
||||
|
||||
if(iCheckCnt >= 5)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Buy(CodeList.CODE_VALUE Code, int iMaxPrice)
|
||||
{
|
||||
if(m_bInitialized == false)
|
||||
@@ -160,10 +218,7 @@ namespace NewsCrawler
|
||||
return;
|
||||
}
|
||||
|
||||
m_CPStockMst.SetInputValue(0, Code.m_strCode);
|
||||
m_CPStockMst.BlockRequest2(0);
|
||||
int iCurPrice = m_CPStockMst.GetHeaderValue(13);
|
||||
|
||||
int iCurPrice = GetCurPrice(Code);
|
||||
int iCount = iMaxPrice/iCurPrice;
|
||||
|
||||
m_CP0311.SetInputValue(0, 2);
|
||||
|
||||
77
NewsForm.Designer.cs
generated
77
NewsForm.Designer.cs
generated
@@ -29,10 +29,15 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lvList = new System.Windows.Forms.ListView();
|
||||
this.chId = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chResT = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chReference = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chResponseT = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chPriceS = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chPriceLow = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chPriceHigh = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.chLink = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.wbView = new System.Windows.Forms.WebBrowser();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
@@ -44,7 +49,7 @@
|
||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
this.tbLog = new System.Windows.Forms.RichTextBox();
|
||||
this.chBuy = new System.Windows.Forms.CheckBox();
|
||||
this.chResT = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.cbPriceCheck = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
@@ -58,11 +63,15 @@
|
||||
// lvList
|
||||
//
|
||||
this.lvList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.chId,
|
||||
this.chTime,
|
||||
this.chResT,
|
||||
this.chReference,
|
||||
this.chTitle,
|
||||
this.chResponseT,
|
||||
this.chPriceS,
|
||||
this.chPriceLow,
|
||||
this.chPriceHigh,
|
||||
this.chLink});
|
||||
this.lvList.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lvList.FullRowSelect = true;
|
||||
@@ -71,32 +80,57 @@
|
||||
this.lvList.Location = new System.Drawing.Point(0, 0);
|
||||
this.lvList.MultiSelect = false;
|
||||
this.lvList.Name = "lvList";
|
||||
this.lvList.Size = new System.Drawing.Size(862, 603);
|
||||
this.lvList.Size = new System.Drawing.Size(1100, 603);
|
||||
this.lvList.TabIndex = 0;
|
||||
this.lvList.UseCompatibleStateImageBehavior = false;
|
||||
this.lvList.View = System.Windows.Forms.View.Details;
|
||||
this.lvList.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.lvList_ColumnClick);
|
||||
this.lvList.SelectedIndexChanged += new System.EventHandler(this.lvList_SelectedIndexChanged);
|
||||
//
|
||||
// chId
|
||||
//
|
||||
this.chId.Text = "ID";
|
||||
this.chId.Width = 29;
|
||||
//
|
||||
// chTime
|
||||
//
|
||||
this.chTime.Text = "시간";
|
||||
//
|
||||
// chTitle
|
||||
// chResT
|
||||
//
|
||||
this.chTitle.Text = "제목";
|
||||
this.chTitle.Width = 366;
|
||||
this.chResT.Text = "받은 시간";
|
||||
this.chResT.Width = 66;
|
||||
//
|
||||
// chReference
|
||||
//
|
||||
this.chReference.Text = "출처";
|
||||
this.chReference.Width = 72;
|
||||
//
|
||||
// chTitle
|
||||
//
|
||||
this.chTitle.Text = "제목";
|
||||
this.chTitle.Width = 366;
|
||||
//
|
||||
// chResponseT
|
||||
//
|
||||
this.chResponseT.Text = "요청 시간";
|
||||
this.chResponseT.Width = 69;
|
||||
//
|
||||
// chPriceS
|
||||
//
|
||||
this.chPriceS.Text = "시가";
|
||||
this.chPriceS.Width = 66;
|
||||
//
|
||||
// chPriceLow
|
||||
//
|
||||
this.chPriceLow.Text = "최저가";
|
||||
this.chPriceLow.Width = 75;
|
||||
//
|
||||
// chPriceHigh
|
||||
//
|
||||
this.chPriceHigh.Text = "최고가";
|
||||
this.chPriceHigh.Width = 73;
|
||||
//
|
||||
// chLink
|
||||
//
|
||||
this.chLink.Text = "링크";
|
||||
@@ -108,7 +142,7 @@
|
||||
this.wbView.Location = new System.Drawing.Point(0, 0);
|
||||
this.wbView.MinimumSize = new System.Drawing.Size(20, 20);
|
||||
this.wbView.Name = "wbView";
|
||||
this.wbView.Size = new System.Drawing.Size(862, 27);
|
||||
this.wbView.Size = new System.Drawing.Size(1100, 27);
|
||||
this.wbView.TabIndex = 1;
|
||||
//
|
||||
// splitContainer1
|
||||
@@ -125,7 +159,7 @@
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.wbView);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(862, 634);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(1100, 634);
|
||||
this.splitContainer1.SplitterDistance = 603;
|
||||
this.splitContainer1.TabIndex = 2;
|
||||
//
|
||||
@@ -175,7 +209,7 @@
|
||||
// btnConfig
|
||||
//
|
||||
this.btnConfig.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnConfig.Location = new System.Drawing.Point(788, 1);
|
||||
this.btnConfig.Location = new System.Drawing.Point(1026, 1);
|
||||
this.btnConfig.Name = "btnConfig";
|
||||
this.btnConfig.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnConfig.TabIndex = 7;
|
||||
@@ -199,7 +233,7 @@
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.tbLog);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(862, 803);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(1100, 803);
|
||||
this.splitContainer2.SplitterDistance = 634;
|
||||
this.splitContainer2.TabIndex = 8;
|
||||
//
|
||||
@@ -211,7 +245,7 @@
|
||||
this.tbLog.Name = "tbLog";
|
||||
this.tbLog.ReadOnly = true;
|
||||
this.tbLog.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
|
||||
this.tbLog.Size = new System.Drawing.Size(862, 165);
|
||||
this.tbLog.Size = new System.Drawing.Size(1100, 165);
|
||||
this.tbLog.TabIndex = 0;
|
||||
this.tbLog.Text = "";
|
||||
//
|
||||
@@ -219,7 +253,7 @@
|
||||
//
|
||||
this.chBuy.Appearance = System.Windows.Forms.Appearance.Button;
|
||||
this.chBuy.AutoSize = true;
|
||||
this.chBuy.Location = new System.Drawing.Point(274, 1);
|
||||
this.chBuy.Location = new System.Drawing.Point(356, 1);
|
||||
this.chBuy.Name = "chBuy";
|
||||
this.chBuy.Size = new System.Drawing.Size(39, 22);
|
||||
this.chBuy.TabIndex = 9;
|
||||
@@ -227,16 +261,22 @@
|
||||
this.chBuy.UseVisualStyleBackColor = true;
|
||||
this.chBuy.CheckedChanged += new System.EventHandler(this.chBuy_CheckedChanged);
|
||||
//
|
||||
// chResT
|
||||
// cbPriceCheck
|
||||
//
|
||||
this.chResT.Text = "받은 시간";
|
||||
this.chResT.Width = 66;
|
||||
this.cbPriceCheck.AutoSize = true;
|
||||
this.cbPriceCheck.Location = new System.Drawing.Point(274, 4);
|
||||
this.cbPriceCheck.Name = "cbPriceCheck";
|
||||
this.cbPriceCheck.Size = new System.Drawing.Size(76, 16);
|
||||
this.cbPriceCheck.TabIndex = 10;
|
||||
this.cbPriceCheck.Text = "가격 체크";
|
||||
this.cbPriceCheck.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// NewsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(864, 829);
|
||||
this.ClientSize = new System.Drawing.Size(1102, 829);
|
||||
this.Controls.Add(this.cbPriceCheck);
|
||||
this.Controls.Add(this.chBuy);
|
||||
this.Controls.Add(this.splitContainer2);
|
||||
this.Controls.Add(this.btnConfig);
|
||||
@@ -279,6 +319,11 @@
|
||||
private System.Windows.Forms.CheckBox chBuy;
|
||||
private System.Windows.Forms.ColumnHeader chResponseT;
|
||||
private System.Windows.Forms.ColumnHeader chResT;
|
||||
private System.Windows.Forms.ColumnHeader chId;
|
||||
private System.Windows.Forms.ColumnHeader chPriceS;
|
||||
private System.Windows.Forms.ColumnHeader chPriceLow;
|
||||
private System.Windows.Forms.ColumnHeader chPriceHigh;
|
||||
private System.Windows.Forms.CheckBox cbPriceCheck;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
160
NewsForm.cs
160
NewsForm.cs
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@@ -17,6 +18,17 @@ namespace NewsCrawler
|
||||
{
|
||||
public partial class NewsForm : Form
|
||||
{
|
||||
class PRICE_CHECK_DATA
|
||||
{
|
||||
public int m_iID;
|
||||
public CodeList.CODE_VALUE m_Code;
|
||||
public int m_iPriceStart = 0;
|
||||
public int m_iPriceLow = 0;
|
||||
public int m_iPriceHigh = 0;
|
||||
public DateTime m_StartTime;
|
||||
}
|
||||
|
||||
|
||||
CybosHelper m_CybosHelper = null;
|
||||
CodeList m_CodeList = null;
|
||||
TextCondition m_Condition = null;
|
||||
@@ -27,7 +39,8 @@ namespace NewsCrawler
|
||||
bool m_bBrowserReload = false;
|
||||
bool m_bBuy = false;
|
||||
|
||||
|
||||
ConcurrentQueue<PRICE_CHECK_DATA> m_PriceCheckList = new ConcurrentQueue<PRICE_CHECK_DATA>();
|
||||
System.Timers.Timer m_PriceCheckTimer = new System.Timers.Timer();
|
||||
|
||||
public NewsForm()
|
||||
{
|
||||
@@ -37,6 +50,8 @@ namespace NewsCrawler
|
||||
Util.SetLogView(tbLog);
|
||||
m_CodeList = new CodeList();
|
||||
m_Condition = new TextCondition();
|
||||
m_CybosHelper = new CybosHelper(this);
|
||||
|
||||
MessageBox.Show("Keywords : \n\n" + m_Condition.GetKeywordsCnt());
|
||||
|
||||
|
||||
@@ -52,7 +67,7 @@ namespace NewsCrawler
|
||||
ReadFinacialNews(true);
|
||||
|
||||
|
||||
lvList.ListViewItemSorter = new ListViewItemComparer(0, SortOrder.Ascending);
|
||||
lvList.ListViewItemSorter = new ListViewItemComparer(chId.Index, SortOrder.Ascending);
|
||||
lvList.Sorting = SortOrder.Ascending;
|
||||
lvList.Sort();
|
||||
|
||||
@@ -66,15 +81,18 @@ namespace NewsCrawler
|
||||
lvList.Columns[chTime.Index].TextAlign = HorizontalAlignment.Right;
|
||||
lvList.Columns[chResponseT.Index].TextAlign = HorizontalAlignment.Right;
|
||||
lvList.Columns[chResT.Index].TextAlign = HorizontalAlignment.Right;
|
||||
lvList.Columns[chId.Index].TextAlign = HorizontalAlignment.Right;
|
||||
lvList.Columns[chPriceS.Index].TextAlign = HorizontalAlignment.Right;
|
||||
lvList.Columns[chPriceLow.Index].TextAlign = HorizontalAlignment.Right;
|
||||
lvList.Columns[chPriceHigh.Index].TextAlign = HorizontalAlignment.Right;
|
||||
|
||||
Console.WriteLine(string.Format("{0} ddd", m_CrawlTimer.SynchronizingObject));
|
||||
Console.WriteLine(string.Format("init thread {0}", System.Threading.Thread.CurrentThread.ManagedThreadId.ToString()));
|
||||
m_CrawlTimer.Elapsed+=CrawlTimer_Tick;
|
||||
m_CrawlTimer.Interval=m_iCrawlInterval;
|
||||
m_CrawlTimer.Start();
|
||||
|
||||
|
||||
m_CybosHelper = new CybosHelper(this);
|
||||
m_PriceCheckTimer.Interval = 5000;
|
||||
m_PriceCheckTimer.Elapsed += PriceCheckTimer_Elapsed;
|
||||
m_PriceCheckTimer.Start();
|
||||
|
||||
Test();
|
||||
}
|
||||
@@ -116,7 +134,16 @@ namespace NewsCrawler
|
||||
BuyItem(Code);
|
||||
}
|
||||
|
||||
void ProcessSearchAndBuy(string strTitle, string strName, string strCode, string strRef)
|
||||
void CheckPrice(int iID, CodeList.CODE_VALUE Code)
|
||||
{
|
||||
PRICE_CHECK_DATA CheckData = new PRICE_CHECK_DATA();
|
||||
CheckData.m_iID = iID;
|
||||
CheckData.m_Code = Code;
|
||||
CheckData.m_StartTime = DateTime.Now;
|
||||
m_PriceCheckList.Enqueue(CheckData);
|
||||
}
|
||||
|
||||
void ProcessSearchAndBuy(string strTitle, string strName, string strCode, string strRef, int iID)
|
||||
{
|
||||
CodeList.CODE_VALUE Code;
|
||||
if(strCode == "")
|
||||
@@ -169,6 +196,9 @@ namespace NewsCrawler
|
||||
Util.Log(Util.LOG_TYPE.DEBUG, string.Format("[NOT_MATCHED] [{0}] {1}({2})", strRef, strTitle, Code.ToString()));
|
||||
break;
|
||||
}
|
||||
|
||||
if(cbPriceCheck.Checked == true)
|
||||
CheckPrice(iID, Code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,21 +216,38 @@ namespace NewsCrawler
|
||||
if(strURL != "" && lvList.Items.Cast<ListViewItem>().Any(s => s.SubItems[chLink.Index].Text == strURL))
|
||||
return;
|
||||
|
||||
lvList.Items.Add(new ListViewItem(new string[] { time.ToString("HH:mm:ss"), ResTime.ToString("HH:mm:ss:fff"), strRef, strTitle, string.Format("{0:0.0000} ms", responseT), strURL }));
|
||||
int iID = lvList.Items.Count+1;
|
||||
|
||||
lvList.Items.Add(new ListViewItem(new string[] {
|
||||
iID.ToString(),
|
||||
time.ToString("HH:mm:ss"),
|
||||
ResTime.ToString("HH:mm:ss:fff"),
|
||||
strRef,
|
||||
strTitle,
|
||||
string.Format("{0:0.0000} ms", responseT),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
strURL }));
|
||||
|
||||
if(bInitial == false && chAutoSelect.Checked == true)
|
||||
{
|
||||
m_bBrowserReload = true;
|
||||
}
|
||||
|
||||
foreach(ColumnHeader col in lvList.Columns)
|
||||
col.Width = -2;
|
||||
|
||||
if(bInitial == false)
|
||||
{
|
||||
foreach(ColumnHeader col in lvList.Columns)
|
||||
{
|
||||
if(!(col == chPriceS || col == chPriceLow || col == chPriceHigh))
|
||||
col.Width = -2;
|
||||
}
|
||||
}
|
||||
|
||||
if(bInitial == false)
|
||||
{
|
||||
lvList.Sort();
|
||||
ProcessSearchAndBuy(strTitle, strName, strCode, strRef);
|
||||
ProcessSearchAndBuy(strTitle, strName, strCode, strRef, iID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -744,6 +791,78 @@ namespace NewsCrawler
|
||||
m_CrawlTimer.Enabled = true;
|
||||
}
|
||||
|
||||
private void UpdateStartPrice(int iID, int iPrice)
|
||||
{
|
||||
if(lvList.InvokeRequired)
|
||||
{
|
||||
lvList.BeginInvoke((MethodInvoker)delegate ()
|
||||
{
|
||||
ListViewItem item = lvList.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chId.Index].Text == iID.ToString());
|
||||
item.SubItems[chPriceS.Index].Text = iPrice.ToString("n0");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ListViewItem item = lvList.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chId.Index].Text == iID.ToString());
|
||||
item.SubItems[chPriceS.Index].Text = iPrice.ToString("n0");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateLowHighPrice(int iID, int iPriceStart, int iPriceLow, int iPriceHigh)
|
||||
{
|
||||
if(lvList.InvokeRequired)
|
||||
{
|
||||
lvList.BeginInvoke((MethodInvoker)delegate ()
|
||||
{
|
||||
ListViewItem item = lvList.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chId.Index].Text == iID.ToString());
|
||||
item.SubItems[chPriceLow.Index].Text = string.Format("{0:n0}({1:n}%)", iPriceLow, iPriceLow/(float)iPriceStart);
|
||||
item.SubItems[chPriceHigh.Index].Text = string.Format("{0:0}({1:n}%)", iPriceHigh, iPriceHigh/(float)iPriceStart);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ListViewItem item = lvList.Items.Cast<ListViewItem>().FirstOrDefault(s => s.SubItems[chId.Index].Text == iID.ToString());
|
||||
item.SubItems[chPriceLow.Index].Text = string.Format("{0:n0}({1:n}%)", iPriceLow, iPriceLow/(float)iPriceStart);
|
||||
item.SubItems[chPriceHigh.Index].Text = string.Format("{0:0}({1:n}%)", iPriceHigh, iPriceHigh/(float)iPriceStart);
|
||||
}
|
||||
}
|
||||
|
||||
private void PriceCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
m_PriceCheckTimer.Enabled = false;
|
||||
|
||||
DateTime CurTime = DateTime.Now;
|
||||
foreach(PRICE_CHECK_DATA data in m_PriceCheckList)
|
||||
{
|
||||
if(data.m_iPriceStart == 0)
|
||||
{
|
||||
data.m_iPriceStart = m_CybosHelper.GetCurPrice(data.m_Code);
|
||||
UpdateStartPrice(data.m_iID, data.m_iPriceStart);
|
||||
}
|
||||
else if(data.m_iPriceHigh == 0 && (CurTime - data.m_StartTime).Minutes >= 1)
|
||||
{
|
||||
m_CybosHelper.GetLowHighPrice(data.m_Code, data.m_StartTime, 5, out data.m_iPriceLow, out data.m_iPriceHigh);
|
||||
if(data.m_iPriceHigh > 0)
|
||||
UpdateLowHighPrice(data.m_iID, data.m_iPriceStart, data.m_iPriceLow, data.m_iPriceHigh);
|
||||
}
|
||||
}
|
||||
|
||||
while(m_PriceCheckList.Count > 0)
|
||||
{
|
||||
PRICE_CHECK_DATA data;
|
||||
if(m_PriceCheckList.TryPeek(out data) == false)
|
||||
break;
|
||||
|
||||
if(data.m_iPriceHigh == 0)
|
||||
break;
|
||||
|
||||
m_PriceCheckList.TryDequeue(out data);
|
||||
}
|
||||
|
||||
|
||||
m_PriceCheckTimer.Enabled = true;
|
||||
}
|
||||
|
||||
private void lvList_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(lvList.SelectedItems.Count <= 0)
|
||||
@@ -889,10 +1008,21 @@ namespace NewsCrawler
|
||||
{
|
||||
ListViewItem item1 = (ListViewItem)x;
|
||||
ListViewItem item2 = (ListViewItem)y;
|
||||
if(m_Order == SortOrder.Ascending)
|
||||
return string.Compare(item1.SubItems[m_iColumn].Text, item2.SubItems[m_iColumn].Text);
|
||||
|
||||
double num1;
|
||||
double num2;
|
||||
if(double.TryParse(item1.SubItems[m_iColumn].Text, out num1) &&
|
||||
double.TryParse(item2.SubItems[m_iColumn].Text, out num2))
|
||||
{
|
||||
return (num1>num2)?1:-1;
|
||||
}
|
||||
else
|
||||
return string.Compare(item2.SubItems[m_iColumn].Text, item1.SubItems[m_iColumn].Text);
|
||||
{
|
||||
if(m_Order == SortOrder.Ascending)
|
||||
return string.Compare(item1.SubItems[m_iColumn].Text, item2.SubItems[m_iColumn].Text);
|
||||
else
|
||||
return string.Compare(item2.SubItems[m_iColumn].Text, item1.SubItems[m_iColumn].Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user