170 lines
4.2 KiB
C#
170 lines
4.2 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|