기본적인 프레임워크 구현
This commit is contained in:
316
Form1.cs
316
Form1.cs
@@ -1,316 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using MySql.Data.MySqlClient;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace upper_limit_crawler
|
|
||||||
{
|
|
||||||
//struct ITEM
|
|
||||||
//{
|
|
||||||
// string m_strCode;
|
|
||||||
// DateTime m_Time;
|
|
||||||
// int m_iCurPrice;
|
|
||||||
// int m_iAskCount;
|
|
||||||
// int m_iBidCount;
|
|
||||||
// int m_iStartPrice;
|
|
||||||
// int m_iTradingVolume;
|
|
||||||
// float m_fRatePerStart;
|
|
||||||
//}
|
|
||||||
|
|
||||||
public partial class Form1 : Form
|
|
||||||
{
|
|
||||||
CPSYSDIBLib.CpSvrNew7043 m_7043 = new CPSYSDIBLib.CpSvrNew7043();
|
|
||||||
DSCBO1Lib.StockMst2 m_StockMst2 = new DSCBO1Lib.StockMst2();
|
|
||||||
|
|
||||||
ArrayList m_TraceList = new ArrayList();
|
|
||||||
|
|
||||||
MySqlConnection m_DBCon;
|
|
||||||
|
|
||||||
Timer timerWatch = new Timer();
|
|
||||||
Timer timerTrace = new Timer();
|
|
||||||
|
|
||||||
public Form1()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
string strConn = "Server=mjjo53.us.to;Database=upperlimit;Uid=mjjo;Pwd=whaudwls;charset=utf8;";
|
|
||||||
m_DBCon = new MySqlConnection(strConn);
|
|
||||||
m_DBCon.Open();
|
|
||||||
|
|
||||||
InitWatch();
|
|
||||||
|
|
||||||
|
|
||||||
timerWatch.Interval = 10 * 1000;
|
|
||||||
timerWatch.Tick += timerWatch_Tick;
|
|
||||||
//timerWatch.Start();
|
|
||||||
|
|
||||||
timerTrace.Interval = 10 * 1000;
|
|
||||||
timerTrace.Tick += timerTrace_Tick;
|
|
||||||
//timerTrace.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitWatch()
|
|
||||||
{
|
|
||||||
m_7043.SetInputValue(0, '1');
|
|
||||||
m_7043.SetInputValue(1, '2');
|
|
||||||
m_7043.SetInputValue(2, '1');
|
|
||||||
m_7043.SetInputValue(3, 41);
|
|
||||||
m_7043.SetInputValue(4, '1');
|
|
||||||
m_7043.SetInputValue(5, '0');
|
|
||||||
m_7043.SetInputValue(6, '0');
|
|
||||||
m_7043.SetInputValue(7, 0);
|
|
||||||
m_7043.SetInputValue(8, 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddTrace(string strCode)
|
|
||||||
{
|
|
||||||
if (m_TraceList.Contains(strCode) == true)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_TraceList.Add(strCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsOnTime()
|
|
||||||
{
|
|
||||||
DateTime CurTime = DateTime.Now;
|
|
||||||
if(CurTime.DayOfWeek == DayOfWeek.Sunday || CurTime.DayOfWeek == DayOfWeek.Saturday)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(CurTime.Hour < 8 || CurTime.Hour > 15)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(CurTime.Hour == 8 && CurTime.Minute < 50)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(CurTime.Hour == 15 && CurTime.Minute > 15)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void timerWatch_Tick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (IsOnTime() == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int iResult = m_7043.BlockRequest2(1);
|
|
||||||
if (iResult != 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("요청 에러");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//string strMsg = string.Format("종목/현재가/대비플래그/대비/대비율/거래량/시가/시가대비/시가대비율/연속일");
|
|
||||||
//Console.WriteLine(strMsg);
|
|
||||||
//textBox1.Clear();
|
|
||||||
//textBox1.AppendText(strMsg + "\n");
|
|
||||||
|
|
||||||
bool bContinue = true;
|
|
||||||
while (bContinue)
|
|
||||||
{
|
|
||||||
int iCnt = m_7043.GetHeaderValue(0);
|
|
||||||
for (int i = 0; i < iCnt; i++)
|
|
||||||
{
|
|
||||||
object Code = m_7043.GetDataValue(0, i);
|
|
||||||
object Name = m_7043.GetDataValue(1, i);
|
|
||||||
object CurPrice = m_7043.GetDataValue(2, i);
|
|
||||||
object flag = m_7043.GetDataValue(3, i);
|
|
||||||
object Comp = m_7043.GetDataValue(4, i);
|
|
||||||
object CompRate = m_7043.GetDataValue(5, i);
|
|
||||||
object DealAmount = m_7043.GetDataValue(6, i);
|
|
||||||
object StartPrice = m_7043.GetDataValue(7, i);
|
|
||||||
object StartPriceComp = m_7043.GetDataValue(8, i);
|
|
||||||
object StartPriceCompRate = m_7043.GetDataValue(9, i);
|
|
||||||
object SerialDay = m_7043.GetDataValue(10, i);
|
|
||||||
|
|
||||||
if ((float)StartPriceCompRate >= 9.0f && (float)StartPriceCompRate <= 10.0f)
|
|
||||||
AddTrace((string)Code);
|
|
||||||
|
|
||||||
//cmd.CommandText = string.Format("insert into trace(code, name, time, curprice, askcount, bidcount, startprice, tradingvolume, rateperstart) values('{0}', '{1}', '{2}', now, {3}, {4}, {5}, {6}, {7})",
|
|
||||||
// Code, Name, CurPrice, );
|
|
||||||
//cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
//strMsg = string.Format("[{0}:{1}]/{2}/{3}/{4}/{5}/{6}/{7}/{8}/{9}/{10}",
|
|
||||||
// Name.GetType(), Code.GetType(),
|
|
||||||
// CurPrice.GetType(), flag.GetType(), Comp.GetType(), CompRate.GetType(),
|
|
||||||
// DealAmount.GetType(), StartPrice.GetType(), StartPriceComp.GetType(), StartPriceCompRate.GetType(),
|
|
||||||
// SerialDay.GetType());
|
|
||||||
//Console.WriteLine(strMsg);
|
|
||||||
//textBox1.AppendText(strMsg + "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
bContinue = (m_7043.Continue == 1);
|
|
||||||
if (bContinue == true)
|
|
||||||
iResult = m_7043.BlockRequest2(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void timerTrace_Tick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
//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(IsOnTime() == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_TraceList.Count <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
string strCodes = "";
|
|
||||||
for (int i = 0; i < m_TraceList.Count; i++)
|
|
||||||
{
|
|
||||||
if (i > 0)
|
|
||||||
strCodes += ",";
|
|
||||||
strCodes += m_TraceList[i];
|
|
||||||
}
|
|
||||||
m_StockMst2.SetInputValue(0, strCodes);
|
|
||||||
|
|
||||||
|
|
||||||
int iResult = 0;
|
|
||||||
iResult = m_StockMst2.BlockRequest2(1);
|
|
||||||
bool bContinue = true;
|
|
||||||
|
|
||||||
MySqlTransaction trans = m_DBCon.BeginTransaction();
|
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
|
||||||
cmd.Connection = m_DBCon;
|
|
||||||
cmd.Transaction = trans;
|
|
||||||
|
|
||||||
DateTime CurTime = DateTime.Now;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
string time = CurTime.ToString("yyyy-MM-dd hh:mm:ss");
|
|
||||||
time = time.Substring(0, 10) + " " + (int)Time / 100 + ":" + (int)Time % 100 + ":00";
|
|
||||||
|
|
||||||
// insert to db
|
|
||||||
string query = string.Format("insert into trace(code, name, time, startprice, curprice, rateperstart, askprice, askcount, bidprice, bidcount, tradingvolume) values('{0}', '{1}', '{2}', {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10})",
|
|
||||||
Code, Name, time, StartPrice, CurPrice, fRatePerStart, AskPrice, AskCount, BidPrice, BidCount, TradingVolume);
|
|
||||||
Console.WriteLine(query);
|
|
||||||
|
|
||||||
cmd.CommandText = query;
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
|
|
||||||
// extract if loss
|
|
||||||
|
|
||||||
// extract if trailing loss
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bContinue = (m_StockMst2.Continue == 1);
|
|
||||||
if (bContinue == true)
|
|
||||||
iResult = m_StockMst2.BlockRequest2(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
trans.Commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void btSearch_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cbSearch_CheckedChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (cbSearch.Checked == true)
|
|
||||||
{
|
|
||||||
timerWatch.Start();
|
|
||||||
timerTrace.Start();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
timerWatch.Stop();
|
|
||||||
timerTrace.Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
Form1.Designer.cs → MainForm.Designer.cs
generated
2
Form1.Designer.cs → MainForm.Designer.cs
generated
@@ -1,6 +1,6 @@
|
|||||||
namespace upper_limit_crawler
|
namespace upper_limit_crawler
|
||||||
{
|
{
|
||||||
partial class Form1
|
partial class MainForm
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
343
MainForm.cs
Normal file
343
MainForm.cs
Normal file
@@ -0,0 +1,343 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace upper_limit_crawler
|
||||||
|
{
|
||||||
|
//struct ITEM
|
||||||
|
//{
|
||||||
|
// string m_strCode;
|
||||||
|
// DateTime m_Time;
|
||||||
|
// int m_iCurPrice;
|
||||||
|
// int m_iAskCount;
|
||||||
|
// int m_iBidCount;
|
||||||
|
// int m_iStartPrice;
|
||||||
|
// int m_iTradingVolume;
|
||||||
|
// float m_fRatePerStart;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public partial class MainForm : Form
|
||||||
|
{
|
||||||
|
CPSYSDIBLib.CpSvrNew7043 m_7043 = new CPSYSDIBLib.CpSvrNew7043();
|
||||||
|
DSCBO1Lib.StockMst2 m_StockMst2 = new DSCBO1Lib.StockMst2();
|
||||||
|
|
||||||
|
ArrayList m_TraceList = new ArrayList();
|
||||||
|
|
||||||
|
MySqlConnection m_DBCon;
|
||||||
|
|
||||||
|
Timer timerWatch = new Timer();
|
||||||
|
Timer timerTrace = new Timer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Timer m_MainTimer = new Timer();
|
||||||
|
int m_iLastTime = 0;
|
||||||
|
|
||||||
|
static ULDataMgr m_DataMgr = new ULDataMgr();
|
||||||
|
ULMonitor m_Monitor = new ULMonitor(m_DataMgr);
|
||||||
|
ULWatch m_Watch = new ULWatch(m_DataMgr);
|
||||||
|
ULDealing m_Dealing = new ULDealing(m_DataMgr);
|
||||||
|
|
||||||
|
public MainForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
string strConn = "Server=mjjo53.us.to;Database=upperlimit;Uid=mjjo;Pwd=whaudwls;charset=utf8;";
|
||||||
|
m_DBCon = new MySqlConnection(strConn);
|
||||||
|
m_DBCon.Open();
|
||||||
|
|
||||||
|
InitWatch();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
m_MainTimer.Interval = 10;
|
||||||
|
m_MainTimer.Tick += Refresh;
|
||||||
|
m_MainTimer.Start();
|
||||||
|
|
||||||
|
//timerWatch.Interval = 1 * 1000;
|
||||||
|
//timerWatch.Tick += timerWatch_Tick;
|
||||||
|
//timerWatch.Start();
|
||||||
|
|
||||||
|
//timerTrace.Interval = 1 * 1000;
|
||||||
|
//timerTrace.Tick += timerTrace_Tick;
|
||||||
|
//timerTrace.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitWatch()
|
||||||
|
{
|
||||||
|
m_7043.SetInputValue(0, '1');
|
||||||
|
m_7043.SetInputValue(1, '2');
|
||||||
|
m_7043.SetInputValue(2, '1');
|
||||||
|
m_7043.SetInputValue(3, 41);
|
||||||
|
m_7043.SetInputValue(4, '1');
|
||||||
|
m_7043.SetInputValue(5, '0');
|
||||||
|
m_7043.SetInputValue(6, '0');
|
||||||
|
m_7043.SetInputValue(7, 0);
|
||||||
|
m_7043.SetInputValue(8, 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Refresh(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int iCurTime = Environment.TickCount;
|
||||||
|
int iDeltaT = iCurTime - m_iLastTime;
|
||||||
|
|
||||||
|
m_Monitor.Refresh(iCurTime);
|
||||||
|
|
||||||
|
m_iLastTime = iCurTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddTrace(string strCode)
|
||||||
|
{
|
||||||
|
if (m_TraceList.Contains(strCode) == true)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_TraceList.Add(strCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsOnTime()
|
||||||
|
{
|
||||||
|
DateTime CurTime = DateTime.Now;
|
||||||
|
if (CurTime.DayOfWeek == DayOfWeek.Sunday || CurTime.DayOfWeek == DayOfWeek.Saturday)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (CurTime.Hour < 8 || CurTime.Hour > 15)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (CurTime.Hour == 8 && CurTime.Minute < 50)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (CurTime.Hour == 15 && CurTime.Minute > 15)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void timerWatch_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (IsOnTime() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int iResult = m_7043.BlockRequest2(1);
|
||||||
|
if (iResult != 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("요청 에러");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string strMsg = string.Format("종목/현재가/대비플래그/대비/대비율/거래량/시가/시가대비/시가대비율/연속일");
|
||||||
|
Console.WriteLine(strMsg);
|
||||||
|
textBox1.Clear();
|
||||||
|
textBox1.AppendText(strMsg + "\n");
|
||||||
|
|
||||||
|
bool bContinue = true;
|
||||||
|
while (bContinue)
|
||||||
|
{
|
||||||
|
int iCnt = m_7043.GetHeaderValue(0);
|
||||||
|
for (int i = 0; i < iCnt; i++)
|
||||||
|
{
|
||||||
|
object Code = m_7043.GetDataValue(0, i);
|
||||||
|
object Name = m_7043.GetDataValue(1, i);
|
||||||
|
object CurPrice = m_7043.GetDataValue(2, i);
|
||||||
|
object flag = m_7043.GetDataValue(3, i);
|
||||||
|
object Comp = m_7043.GetDataValue(4, i);
|
||||||
|
object CompRate = m_7043.GetDataValue(5, i);
|
||||||
|
object DealAmount = m_7043.GetDataValue(6, i);
|
||||||
|
object StartPrice = m_7043.GetDataValue(7, i);
|
||||||
|
object StartPriceComp = m_7043.GetDataValue(8, i);
|
||||||
|
object StartPriceCompRate = m_7043.GetDataValue(9, i);
|
||||||
|
object SerialDay = m_7043.GetDataValue(10, i);
|
||||||
|
|
||||||
|
if ((float)StartPriceCompRate >= 9.0f && (float)StartPriceCompRate <= 10.0f)
|
||||||
|
AddTrace((string)Code);
|
||||||
|
|
||||||
|
//cmd.CommandText = string.Format("insert into trace(code, name, time, curprice, askcount, bidcount, startprice, tradingvolume, rateperstart) values('{0}', '{1}', '{2}', now, {3}, {4}, {5}, {6}, {7})",
|
||||||
|
// Code, Name, CurPrice, );
|
||||||
|
//cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
strMsg = string.Format("[{0}:{1}]/{2}/{3}/{4}/{5}/{6}/{7}/{8}/{9}/{10}",
|
||||||
|
Name.GetType(), Code.GetType(),
|
||||||
|
CurPrice.GetType(), flag.GetType(), Comp.GetType(), CompRate.GetType(),
|
||||||
|
DealAmount.GetType(), StartPrice.GetType(), StartPriceComp.GetType(), StartPriceCompRate.GetType(),
|
||||||
|
SerialDay.GetType());
|
||||||
|
Console.WriteLine(strMsg);
|
||||||
|
textBox1.AppendText(strMsg + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
bContinue = (m_7043.Continue == 1);
|
||||||
|
if (bContinue == true)
|
||||||
|
iResult = m_7043.BlockRequest2(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void timerTrace_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//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 (IsOnTime() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_TraceList.Count <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string strCodes = "";
|
||||||
|
for (int i = 0; i < m_TraceList.Count; i++)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
strCodes += ",";
|
||||||
|
strCodes += m_TraceList[i];
|
||||||
|
}
|
||||||
|
m_StockMst2.SetInputValue(0, strCodes);
|
||||||
|
|
||||||
|
|
||||||
|
int iResult = 0;
|
||||||
|
iResult = m_StockMst2.BlockRequest2(1);
|
||||||
|
bool bContinue = true;
|
||||||
|
|
||||||
|
MySqlTransaction trans = m_DBCon.BeginTransaction();
|
||||||
|
MySqlCommand cmd = new MySqlCommand();
|
||||||
|
cmd.Connection = m_DBCon;
|
||||||
|
cmd.Transaction = trans;
|
||||||
|
|
||||||
|
DateTime CurTime = DateTime.Now;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
string time = CurTime.ToString("yyyy-MM-dd hh:mm:ss");
|
||||||
|
time = time.Substring(0, 10) + " " + (int)Time / 100 + ":" + (int)Time % 100 + ":00";
|
||||||
|
|
||||||
|
// insert to db
|
||||||
|
string query = string.Format("insert into trace(code, name, time, startprice, curprice, rateperstart, askprice, askcount, bidprice, bidcount, tradingvolume) values('{0}', '{1}', '{2}', {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10})",
|
||||||
|
Code, Name, time, StartPrice, CurPrice, fRatePerStart, AskPrice, AskCount, BidPrice, BidCount, TradingVolume);
|
||||||
|
Console.WriteLine(query);
|
||||||
|
|
||||||
|
cmd.CommandText = query;
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
|
||||||
|
// extract if loss
|
||||||
|
|
||||||
|
// extract if trailing loss
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bContinue = (m_StockMst2.Continue == 1);
|
||||||
|
if (bContinue == true)
|
||||||
|
iResult = m_StockMst2.BlockRequest2(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void btSearch_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cbSearch_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (cbSearch.Checked == true)
|
||||||
|
{
|
||||||
|
timerWatch.Start();
|
||||||
|
timerTrace.Start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timerWatch.Stop();
|
||||||
|
timerTrace.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ namespace upper_limit_crawler
|
|||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new Form1());
|
Application.Run(new MainForm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
ULDataMgr.cs
Normal file
12
ULDataMgr.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace upper_limit_crawler
|
||||||
|
{
|
||||||
|
class ULDataMgr
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
27
ULDealing.cs
Normal file
27
ULDealing.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
ULMonitor.cs
Normal file
26
ULMonitor.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace upper_limit_crawler
|
||||||
|
{
|
||||||
|
class ULMonitor : ULObj
|
||||||
|
{
|
||||||
|
public ULMonitor(ULDataMgr DataMgr) : base(DataMgr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Refresh(int iCurTime)
|
||||||
|
{
|
||||||
|
if(m_iLastTime == 0)
|
||||||
|
{
|
||||||
|
base.Refresh(iCurTime);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Refresh(iCurTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
ULObj.cs
Normal file
24
ULObj.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace upper_limit_crawler
|
||||||
|
{
|
||||||
|
class ULObj
|
||||||
|
{
|
||||||
|
protected ULDataMgr m_DataMgr = null;
|
||||||
|
protected int m_iLastTime = 0;
|
||||||
|
|
||||||
|
public ULObj(ULDataMgr DataMgr)
|
||||||
|
{
|
||||||
|
m_DataMgr = DataMgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Refresh(int iCurTime)
|
||||||
|
{
|
||||||
|
m_iLastTime = iCurTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
ULOwn.cs
Normal file
26
ULOwn.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace upper_limit_crawler
|
||||||
|
{
|
||||||
|
class ULOwn : ULObj
|
||||||
|
{
|
||||||
|
public ULOwn(ULDataMgr DataMgr) : base(DataMgr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Refresh(int iCurTime)
|
||||||
|
{
|
||||||
|
if (m_iLastTime == 0)
|
||||||
|
{
|
||||||
|
base.Refresh(iCurTime);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Refresh(iCurTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
ULWatch.cs
Normal file
26
ULWatch.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace upper_limit_crawler
|
||||||
|
{
|
||||||
|
class ULWatch : ULObj
|
||||||
|
{
|
||||||
|
public ULWatch(ULDataMgr DataMgr) : base(DataMgr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Refresh(int iCurTime)
|
||||||
|
{
|
||||||
|
if (m_iLastTime == 0)
|
||||||
|
{
|
||||||
|
base.Refresh(iCurTime);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Refresh(iCurTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,16 +57,22 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Form1.cs">
|
<Compile Include="MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Form1.Designer.cs">
|
<Compile Include="MainForm.Designer.cs">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="Form1.resx">
|
<Compile Include="ULDealing.cs" />
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<Compile Include="ULDataMgr.cs" />
|
||||||
|
<Compile Include="ULMonitor.cs" />
|
||||||
|
<Compile Include="ULObj.cs" />
|
||||||
|
<Compile Include="ULOwn.cs" />
|
||||||
|
<Compile Include="ULWatch.cs" />
|
||||||
|
<EmbeddedResource Include="MainForm.resx">
|
||||||
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
|||||||
Reference in New Issue
Block a user