- ULWatchItem.Is5MAGoingUp() 함수 추가
- ULWatchItem.FillPrice() 함수 추가
This commit is contained in:
290
MainForm.cs
290
MainForm.cs
@@ -20,7 +20,7 @@ namespace upper_limit_crawler
|
||||
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
ArrayList m_TraceList = new ArrayList();
|
||||
ArrayList m_TraceList = new ArrayList();
|
||||
|
||||
Timer m_MainTimer = new Timer();
|
||||
int m_iLastTime = 0;
|
||||
@@ -58,15 +58,15 @@ namespace upper_limit_crawler
|
||||
UlUtil.Trace("시작");
|
||||
}
|
||||
|
||||
public static void SetDoubleBuffered(Control control)
|
||||
{
|
||||
// set instance non-public property with name "DoubleBuffered" to true
|
||||
typeof(Control).InvokeMember("DoubleBuffered",
|
||||
BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
|
||||
null, control, new object[] { true });
|
||||
}
|
||||
public static void SetDoubleBuffered(Control control)
|
||||
{
|
||||
// set instance non-public property with name "DoubleBuffered" to true
|
||||
typeof(Control).InvokeMember("DoubleBuffered",
|
||||
BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
|
||||
null, control, new object[] { true });
|
||||
}
|
||||
|
||||
private bool IsOnTime()
|
||||
private bool IsOnTime()
|
||||
{
|
||||
DateTime CurTime = UlUtil.GetCurTime();
|
||||
if (CurTime.DayOfWeek == DayOfWeek.Sunday || CurTime.DayOfWeek == DayOfWeek.Saturday)
|
||||
@@ -96,62 +96,62 @@ namespace upper_limit_crawler
|
||||
return;
|
||||
}
|
||||
|
||||
if(cbStart.Checked == true && UlUtil.IsConnected() == false)
|
||||
{
|
||||
cbStart.Checked = false;
|
||||
return;
|
||||
}
|
||||
if(cbStart.Checked == true && UlUtil.IsConnected() == false)
|
||||
{
|
||||
cbStart.Checked = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int iDeltaT = iCurTime - m_iLastTime;
|
||||
|
||||
m_Own.Refresh(iCurTime);
|
||||
|
||||
lbRQCnt.Text = "RQ Count : " + UlUtil.GetLimitRemainCountRQ().ToString();
|
||||
lbSBCnt.Text = "SB Count : " + UlUtil.GetLimitRemainCountSB().ToString();
|
||||
lbRQCnt.Text = "RQ Count : " + UlUtil.GetLimitRemainCountRQ().ToString();
|
||||
lbSBCnt.Text = "SB Count : " + UlUtil.GetLimitRemainCountSB().ToString();
|
||||
|
||||
statusBar1.Panels[1].Text = UlUtil.GetCurTimeString() + " ";
|
||||
statusBar1.Panels[1].Text = UlUtil.GetCurTimeString() + " ";
|
||||
|
||||
m_iLastTime = iCurTime;
|
||||
}
|
||||
|
||||
void StartAll()
|
||||
{
|
||||
m_MonitorDlg.Start();
|
||||
m_BalanceDlg.Start();
|
||||
m_DataMgr.StartAll();
|
||||
}
|
||||
void StartAll()
|
||||
{
|
||||
m_MonitorDlg.Start();
|
||||
m_BalanceDlg.Start();
|
||||
m_DataMgr.StartAll();
|
||||
}
|
||||
|
||||
void StopAll()
|
||||
{
|
||||
m_MonitorDlg.Stop();
|
||||
m_BalanceDlg.Stop();
|
||||
m_DataMgr.StopAll();
|
||||
}
|
||||
void StopAll()
|
||||
{
|
||||
m_MonitorDlg.Stop();
|
||||
m_BalanceDlg.Stop();
|
||||
m_DataMgr.StopAll();
|
||||
}
|
||||
|
||||
private void cbStart_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (cbStart.Checked == true)
|
||||
{
|
||||
if (UlUtil.IsConnected() == false)
|
||||
UlUtil.Reset();
|
||||
private void cbStart_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (cbStart.Checked == true)
|
||||
{
|
||||
if (UlUtil.IsConnected() == false)
|
||||
UlUtil.Reset();
|
||||
|
||||
if (UlUtil.IsConnected() == false)
|
||||
{
|
||||
cbStart.Checked = false;
|
||||
MessageBox.Show("Cybos Plus를 실행해주세요");
|
||||
return;
|
||||
}
|
||||
if (UlUtil.IsConnected() == false)
|
||||
{
|
||||
cbStart.Checked = false;
|
||||
MessageBox.Show("Cybos Plus를 실행해주세요");
|
||||
return;
|
||||
}
|
||||
|
||||
m_DataMgr.Init();
|
||||
StartAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
StopAll();
|
||||
}
|
||||
}
|
||||
m_DataMgr.Init();
|
||||
StartAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
StopAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddTrace(string strCode)
|
||||
private void AddTrace(string strCode)
|
||||
{
|
||||
if (m_TraceList.Contains(strCode) == true)
|
||||
return;
|
||||
@@ -159,38 +159,38 @@ namespace upper_limit_crawler
|
||||
m_TraceList.Add(strCode);
|
||||
}
|
||||
|
||||
private void btApply_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_DataMgr.m_Setting.m_fSearchMin = float.Parse(tbSearchMin.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fSearchMax = float.Parse(tbSearchMax.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fBidMin = float.Parse(tbBidMin.Text.Replace("%", ""))/100;
|
||||
private void btApply_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_DataMgr.m_Setting.m_fSearchMin = float.Parse(tbSearchMin.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fSearchMax = float.Parse(tbSearchMax.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fBidMin = float.Parse(tbBidMin.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fBidMax = float.Parse(tbBidMax.Text.Replace("%", ""))/100;
|
||||
m_DataMgr.m_Setting.m_fBidAmount = float.Parse(tbBidAmount.Text);
|
||||
m_DataMgr.m_Setting.m_fTimeout = float.Parse(tbTimeout.Text);
|
||||
m_DataMgr.m_Setting.m_fTrailing = float.Parse(tbTrailing.Text.Replace("%", ""))/100;
|
||||
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_fLossCut = float.Parse(tbLossCut.Text.Replace("%", ""))/100;
|
||||
|
||||
btCancel_Click(null, null);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
UlUtil.Trace(ex.ToString());
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
UlUtil.Trace(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
tbSearchMin.Text = (m_DataMgr.m_Setting.m_fSearchMin*100).ToString("0.0") + "%";
|
||||
tbSearchMax.Text = (m_DataMgr.m_Setting.m_fSearchMax*100).ToString("0.0") + "%";
|
||||
tbBidMin.Text = (m_DataMgr.m_Setting.m_fBidMin*100).ToString("0.0") + "%";
|
||||
private void btCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
tbSearchMin.Text = (m_DataMgr.m_Setting.m_fSearchMin*100).ToString("0.0") + "%";
|
||||
tbSearchMax.Text = (m_DataMgr.m_Setting.m_fSearchMax*100).ToString("0.0") + "%";
|
||||
tbBidMin.Text = (m_DataMgr.m_Setting.m_fBidMin*100).ToString("0.0") + "%";
|
||||
tbBidMax.Text = (m_DataMgr.m_Setting.m_fBidMax*100).ToString("0.0") + "%";
|
||||
tbBidAmount.Text = m_DataMgr.m_Setting.m_fBidAmount.ToString("###,###,###,###,###");
|
||||
tbTimeout.Text = m_DataMgr.m_Setting.m_fTimeout.ToString("0.###");
|
||||
tbTrailing.Text = (m_DataMgr.m_Setting.m_fTrailing*100).ToString("0.0") + "%";
|
||||
tbLossCut.Text = (m_DataMgr.m_Setting.m_fLossCut*100).ToString("0.0") + "%";
|
||||
}
|
||||
tbTimeout.Text = m_DataMgr.m_Setting.m_fTimeout.ToString("0.###");
|
||||
tbTrailing.Text = (m_DataMgr.m_Setting.m_fTrailing*100).ToString("0.0") + "%";
|
||||
tbLossCut.Text = (m_DataMgr.m_Setting.m_fLossCut*100).ToString("0.0") + "%";
|
||||
}
|
||||
|
||||
private void btCybos5_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -204,91 +204,89 @@ namespace upper_limit_crawler
|
||||
Process.Start(strappname, @"/prj:cp");
|
||||
}
|
||||
|
||||
private void btTimeSync_Click(object sender, EventArgs e)
|
||||
{
|
||||
UlUtil.SyncServerTime();
|
||||
}
|
||||
private void btTimeSync_Click(object sender, EventArgs e)
|
||||
{
|
||||
UlUtil.SyncServerTime();
|
||||
}
|
||||
|
||||
DSCBO1Lib.StockCur cur = new DSCBO1Lib.StockCur();
|
||||
DSCBO1Lib.StockOutCur outCur = new DSCBO1Lib.StockOutCur();
|
||||
string strCheckCode = "A004565";
|
||||
DSCBO1Lib.StockCur cur = new DSCBO1Lib.StockCur();
|
||||
DSCBO1Lib.StockOutCur outCur = new DSCBO1Lib.StockOutCur();
|
||||
string strCheckCode = "A004565";
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
{
|
||||
DSCBO1Lib.StockMst mst = new DSCBO1Lib.StockMst();
|
||||
mst.SetInputValue(0, strCheckCode);
|
||||
mst.BlockRequest();
|
||||
short time = mst.GetHeaderValue(4);
|
||||
Console.WriteLine("StockMst : {0}", time);
|
||||
}
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
{
|
||||
DSCBO1Lib.StockMst mst = new DSCBO1Lib.StockMst();
|
||||
mst.SetInputValue(0, strCheckCode);
|
||||
mst.BlockRequest();
|
||||
short time = mst.GetHeaderValue(4);
|
||||
Console.WriteLine("StockMst : {0}", time);
|
||||
}
|
||||
|
||||
{
|
||||
DSCBO1Lib.StockMst2 mst2 = new DSCBO1Lib.StockMst2();
|
||||
mst2.SetInputValue(0, strCheckCode);
|
||||
mst2.BlockRequest();
|
||||
long time = mst2.GetDataValue(2, 0);
|
||||
Console.WriteLine("StockMst2 : {0}", time);
|
||||
}
|
||||
{
|
||||
DSCBO1Lib.StockMst2 mst2 = new DSCBO1Lib.StockMst2();
|
||||
mst2.SetInputValue(0, strCheckCode);
|
||||
mst2.BlockRequest();
|
||||
long time = mst2.GetDataValue(2, 0);
|
||||
Console.WriteLine("StockMst2 : {0}", time);
|
||||
}
|
||||
|
||||
{
|
||||
cur.SetInputValue(0, strCheckCode);
|
||||
cur.Received += Cur_Received;
|
||||
cur.SubscribeLatest();
|
||||
}
|
||||
{
|
||||
cur.SetInputValue(0, strCheckCode);
|
||||
cur.Received += Cur_Received;
|
||||
cur.SubscribeLatest();
|
||||
}
|
||||
|
||||
{
|
||||
outCur.SetInputValue(0, strCheckCode);
|
||||
outCur.Received += OutCur_Received;
|
||||
outCur.SubscribeLatest();
|
||||
}
|
||||
}
|
||||
{
|
||||
outCur.SetInputValue(0, strCheckCode);
|
||||
outCur.Received += OutCur_Received;
|
||||
outCur.SubscribeLatest();
|
||||
}
|
||||
}
|
||||
|
||||
private void OutCur_Received()
|
||||
{
|
||||
long time = outCur.GetHeaderValue(1);
|
||||
Console.WriteLine("StockOutCur : {0}", time);
|
||||
}
|
||||
private void OutCur_Received()
|
||||
{
|
||||
long time = outCur.GetHeaderValue(1);
|
||||
Console.WriteLine("StockOutCur : {0}", time);
|
||||
}
|
||||
|
||||
private void Cur_Received()
|
||||
{
|
||||
long time = cur.GetHeaderValue(3);
|
||||
long time2 = cur.GetHeaderValue(18);
|
||||
Console.WriteLine("StockCur : {0} / {1}", time, time2);
|
||||
}
|
||||
private void Cur_Received()
|
||||
{
|
||||
long time = cur.GetHeaderValue(3);
|
||||
long time2 = cur.GetHeaderValue(18);
|
||||
Console.WriteLine("StockCur : {0} / {1}", time, time2);
|
||||
}
|
||||
|
||||
private void btMATest_Click(object sender, EventArgs e)
|
||||
{
|
||||
CPSYSDIBLib.StockChart stockChart = new CPSYSDIBLib.StockChart();
|
||||
stockChart.SetInputValue(0, "A043580");
|
||||
stockChart.SetInputValue(1, '1');
|
||||
stockChart.SetInputValue(2, "20160722");
|
||||
stockChart.SetInputValue(3, "20160722");
|
||||
stockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5, 6, 10 });
|
||||
stockChart.SetInputValue(6, 'm');
|
||||
stockChart.BlockRequest2(1);
|
||||
private void btMATest_Click(object sender, EventArgs e)
|
||||
{
|
||||
CPSYSDIBLib.StockChart stockChart = new CPSYSDIBLib.StockChart();
|
||||
stockChart.SetInputValue(0, "A043580");
|
||||
stockChart.SetInputValue(1, '1');
|
||||
stockChart.SetInputValue(2, "20160722");
|
||||
stockChart.SetInputValue(3, "20160722");
|
||||
stockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5, 6, 10 });
|
||||
stockChart.SetInputValue(6, 'm');
|
||||
stockChart.BlockRequest2(1);
|
||||
|
||||
int iCnt = (int)stockChart.GetHeaderValue(3);
|
||||
int iFieldCnt = stockChart.GetHeaderValue(1);
|
||||
string[] astrFieldName = stockChart.GetHeaderValue(2);
|
||||
int iCnt = (int)stockChart.GetHeaderValue(3);
|
||||
int iFieldCnt = stockChart.GetHeaderValue(1);
|
||||
string[] astrFieldName = stockChart.GetHeaderValue(2);
|
||||
|
||||
ULWatchItem item = new ULWatchItem();
|
||||
ULWatchItem item = new ULWatchItem();
|
||||
|
||||
for (int i=iCnt-1; i>=0; i--)
|
||||
{
|
||||
int iTime = (int)stockChart.GetDataValue(1, i);
|
||||
int iPrice = (int)stockChart.GetDataValue(5, i);
|
||||
int iVolume = (int)stockChart.GetDataValue(5, i);
|
||||
for (int i=iCnt-1; i>=0; i--)
|
||||
{
|
||||
int iTime = (int)stockChart.GetDataValue(1, i);
|
||||
int iPrice = (int)stockChart.GetDataValue(5, i);
|
||||
int iVolume = (int)stockChart.GetDataValue(5, i);
|
||||
|
||||
iTime *= 100;
|
||||
iTime *= 100;
|
||||
|
||||
item.m_iCurPrice = iPrice;
|
||||
item.InsertPriceNode(iTime, iPrice);
|
||||
}
|
||||
item.m_iCurPrice = iPrice;
|
||||
item.InsertPriceNode(iTime, iPrice);
|
||||
}
|
||||
|
||||
//item.MakeChart();
|
||||
//item.MakeMAChart();
|
||||
item.PrintChart();
|
||||
}
|
||||
}
|
||||
item.PrintChart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,19 +63,19 @@ namespace upper_limit_crawler
|
||||
m_MainTimer.Tick+=RefreshData;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
m_Td6033 = new CPTRADELib.CpTd6033();
|
||||
public void Start()
|
||||
{
|
||||
m_Td6033 = new CPTRADELib.CpTd6033();
|
||||
|
||||
RefreshBalance();
|
||||
RefreshBalance();
|
||||
|
||||
m_MainTimer.Start();
|
||||
}
|
||||
m_MainTimer.Start();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
m_MainTimer.Stop();
|
||||
}
|
||||
public void Stop()
|
||||
{
|
||||
m_MainTimer.Stop();
|
||||
}
|
||||
|
||||
private void RefreshBalance()
|
||||
{
|
||||
@@ -210,7 +210,7 @@ namespace upper_limit_crawler
|
||||
// 미체결 잔량 취소
|
||||
}
|
||||
// trailing
|
||||
else if (iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
|
||||
else if (iCurPrice <= OwnItem.m_iMaxPrice - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing && WatchItem.Is5MAGoingUp() == false)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[{0}] 트레일링 매도 {1}원 ({2})", OwnItem.m_strCodeName, iCurPrice, (iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f).ToString("0.00%")));
|
||||
m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
|
||||
|
||||
60
ULDataMgr.cs
60
ULDataMgr.cs
@@ -9,25 +9,25 @@ using System.Threading.Tasks;
|
||||
namespace upper_limit_crawler
|
||||
{
|
||||
public struct SETTING
|
||||
{
|
||||
public float m_fSearchMin;
|
||||
public float m_fSearchMax;
|
||||
public float m_fBidMin;
|
||||
{
|
||||
public float m_fSearchMin;
|
||||
public float m_fSearchMax;
|
||||
public float m_fBidMin;
|
||||
public float m_fBidMax;
|
||||
public float m_fBidAmount;
|
||||
public float m_fTimeout;
|
||||
public float m_fTrailing;
|
||||
public float m_fLossCut;
|
||||
}
|
||||
public float m_fTimeout;
|
||||
public float m_fTrailing;
|
||||
public float m_fLossCut;
|
||||
}
|
||||
|
||||
public class ULDataMgr
|
||||
{
|
||||
public SETTING m_Setting = new SETTING();
|
||||
public SETTING m_Setting = new SETTING();
|
||||
|
||||
ULTrader m_Trader = new ULTrader();
|
||||
ULTrader m_Trader = new ULTrader();
|
||||
|
||||
Dictionary<string, ULWatchItem> m_WatchList = new Dictionary<string, ULWatchItem>();
|
||||
List<string> m_BlackList = new List<string>();
|
||||
List<string> m_BlackList = new List<string>();
|
||||
|
||||
public ULDataMgr()
|
||||
{
|
||||
@@ -48,7 +48,7 @@ namespace upper_limit_crawler
|
||||
return m_Trader;
|
||||
}
|
||||
|
||||
public void AddWatch(string strCode, string strCodeName, int iCurPrice, int iPrevClosing)
|
||||
public void AddWatch(string strCode, string strCodeName, int iCurPrice, int iPrevClosing)
|
||||
{
|
||||
if (m_WatchList.ContainsKey(strCode))
|
||||
return;
|
||||
@@ -59,6 +59,8 @@ namespace upper_limit_crawler
|
||||
item.m_iCurPrice = iCurPrice;
|
||||
item.m_iPrevClosing = iPrevClosing;
|
||||
|
||||
item.FillPrice();
|
||||
|
||||
item.m_StockCur = new DSCBO1Lib.StockCur();
|
||||
item.m_StockCur.SetInputValue(0, strCode);
|
||||
item.m_StockCur.Received += item.Received;
|
||||
@@ -76,24 +78,24 @@ namespace upper_limit_crawler
|
||||
m_WatchList.Remove(strCode);
|
||||
}
|
||||
|
||||
public void StartAll()
|
||||
{
|
||||
foreach (KeyValuePair<string, ULWatchItem> item in m_WatchList)
|
||||
{
|
||||
item.Value.m_StockCur = new DSCBO1Lib.StockCur();
|
||||
item.Value.m_StockCur.SetInputValue(0, item.Value.m_strCode);
|
||||
item.Value.m_StockCur.Received += item.Value.Received;
|
||||
item.Value.m_StockCur.SubscribeLatest();
|
||||
}
|
||||
}
|
||||
public void StartAll()
|
||||
{
|
||||
foreach (KeyValuePair<string, ULWatchItem> item in m_WatchList)
|
||||
{
|
||||
item.Value.m_StockCur = new DSCBO1Lib.StockCur();
|
||||
item.Value.m_StockCur.SetInputValue(0, item.Value.m_strCode);
|
||||
item.Value.m_StockCur.Received += item.Value.Received;
|
||||
item.Value.m_StockCur.SubscribeLatest();
|
||||
}
|
||||
}
|
||||
|
||||
public void StopAll()
|
||||
{
|
||||
foreach (KeyValuePair<string, ULWatchItem> item in m_WatchList)
|
||||
{
|
||||
item.Value.m_StockCur.Unsubscribe();
|
||||
}
|
||||
}
|
||||
public void StopAll()
|
||||
{
|
||||
foreach (KeyValuePair<string, ULWatchItem> item in m_WatchList)
|
||||
{
|
||||
item.Value.m_StockCur.Unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddBlackList(string strCode)
|
||||
{
|
||||
|
||||
@@ -36,29 +36,29 @@ namespace upper_limit_crawler
|
||||
m_Timer.Tick += Refresh;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
m_7043 = new CPSYSDIBLib.CpSvrNew7043();
|
||||
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));
|
||||
public void Start()
|
||||
{
|
||||
m_7043 = new CPSYSDIBLib.CpSvrNew7043();
|
||||
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));
|
||||
|
||||
|
||||
RefreshMonitorItem();
|
||||
RefreshMonitorItem();
|
||||
|
||||
m_Timer.Start();
|
||||
}
|
||||
m_Timer.Start();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
m_Timer.Stop();
|
||||
}
|
||||
public void Stop()
|
||||
{
|
||||
m_Timer.Stop();
|
||||
}
|
||||
|
||||
bool RefreshMonitorItem()
|
||||
{
|
||||
@@ -135,31 +135,31 @@ namespace upper_limit_crawler
|
||||
{
|
||||
Dictionary<string, ULWatchItem> WatchList = m_DataMgr.GetWatchList();
|
||||
foreach (ListViewItem lvItem in lvWatch.Items)
|
||||
{
|
||||
string strCode = lvItem.SubItems[chCode.Index].Text;
|
||||
if (WatchList.ContainsKey(strCode) == true)
|
||||
{
|
||||
{
|
||||
string strCode = lvItem.SubItems[chCode.Index].Text;
|
||||
if (WatchList.ContainsKey(strCode) == true)
|
||||
{
|
||||
ULWatchItem 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", ""));
|
||||
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)
|
||||
{
|
||||
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("###,###,###,###");
|
||||
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 &&
|
||||
item.IsUpSlope() == true &&
|
||||
m_DataMgr.IsInBlackList(strCode) == false)
|
||||
item.Is5MAGoingUp() == true &&
|
||||
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.ToString("0.00%")));
|
||||
@@ -167,10 +167,10 @@ namespace upper_limit_crawler
|
||||
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)
|
||||
{
|
||||
|
||||
24
ULTrader.cs
24
ULTrader.cs
@@ -22,10 +22,10 @@ namespace upper_limit_crawler
|
||||
|
||||
public void Init()
|
||||
{
|
||||
m_Util = new CPFORETRADELib.CpForeTdUtil();
|
||||
m_Conclusion = new DSCBO1Lib.CpConclusion();
|
||||
m_Util = new CPFORETRADELib.CpForeTdUtil();
|
||||
m_Conclusion = new DSCBO1Lib.CpConclusion();
|
||||
|
||||
m_Util.TradeInit();
|
||||
m_Util.TradeInit();
|
||||
m_astrAccounts = m_Util.AccountNumber;
|
||||
|
||||
StartConclusion();
|
||||
@@ -129,9 +129,9 @@ namespace upper_limit_crawler
|
||||
{
|
||||
//lock(lockBuy)
|
||||
{
|
||||
while (UlUtil.GetLimitRemainCountRQ() <= 0) ;
|
||||
while (UlUtil.GetLimitRemainCountRQ() <= 0) ;
|
||||
|
||||
int iCnt = iBidAmount / iUnitPrice;
|
||||
int iCnt = iBidAmount / iUnitPrice;
|
||||
|
||||
CPTRADELib.CpTd0311 Td0311Bid = new CPTRADELib.CpTd0311();
|
||||
Td0311Bid.SetInputValue(0, "2");
|
||||
@@ -150,12 +150,12 @@ namespace upper_limit_crawler
|
||||
{
|
||||
//lock (lockSell)
|
||||
{
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
|
||||
while (UlUtil.GetLimitRemainCountRQ() <= 0) ;
|
||||
while (UlUtil.GetLimitRemainCountRQ() <= 0) ;
|
||||
|
||||
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
|
||||
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
|
||||
|
||||
Td0311Ask.SetInputValue(0, "1");
|
||||
Td0311Ask.SetInputValue(1, m_astrAccounts[0]);
|
||||
@@ -173,10 +173,10 @@ namespace upper_limit_crawler
|
||||
{
|
||||
//lock (lockSell)
|
||||
{
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
//long iCnt = (long)Math.Floor(fAskAmount/fCurPrice);
|
||||
//iCnt=1;
|
||||
|
||||
while (UlUtil.GetLimitRemainCountRQ() <= 0);
|
||||
while (UlUtil.GetLimitRemainCountRQ() <= 0);
|
||||
|
||||
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
|
||||
|
||||
|
||||
416
ULWatchItem.cs
416
ULWatchItem.cs
@@ -8,50 +8,50 @@ namespace upper_limit_crawler
|
||||
{
|
||||
public class ULWatchItem
|
||||
{
|
||||
public class PriceNode
|
||||
{
|
||||
public PriceNode(int iTime, int iPrice)
|
||||
{
|
||||
m_iTime = iTime;
|
||||
m_iPrice = iPrice;
|
||||
}
|
||||
public class PriceNode
|
||||
{
|
||||
public PriceNode(int iTime, int iPrice)
|
||||
{
|
||||
m_iTime = iTime;
|
||||
m_iPrice = iPrice;
|
||||
}
|
||||
|
||||
public int m_iTime;
|
||||
public int m_iPrice;
|
||||
}
|
||||
public int m_iTime;
|
||||
public int m_iPrice;
|
||||
}
|
||||
|
||||
public class CandleTick
|
||||
{
|
||||
public CandleTick(int iTime, int iPrice)
|
||||
{
|
||||
m_iTime = iTime;
|
||||
m_iStart = iPrice;
|
||||
m_iEnd = iPrice;
|
||||
m_iLowest = iPrice;
|
||||
m_iHighest = iPrice;
|
||||
}
|
||||
public class CandleTick
|
||||
{
|
||||
public CandleTick(int iTime, int iPrice)
|
||||
{
|
||||
m_iTime = iTime;
|
||||
m_iStart = iPrice;
|
||||
m_iEnd = iPrice;
|
||||
m_iLowest = iPrice;
|
||||
m_iHighest = iPrice;
|
||||
}
|
||||
|
||||
public int m_iTime;
|
||||
public int m_iStart;
|
||||
public int m_iEnd;
|
||||
public int m_iLowest;
|
||||
public int m_iHighest;
|
||||
}
|
||||
public int m_iTime;
|
||||
public int m_iStart;
|
||||
public int m_iEnd;
|
||||
public int m_iLowest;
|
||||
public int m_iHighest;
|
||||
}
|
||||
|
||||
public class MATick
|
||||
{
|
||||
public MATick(int iTime, float fMA)
|
||||
{
|
||||
m_iTime = iTime;
|
||||
m_fMA = fMA;
|
||||
}
|
||||
public class MATick
|
||||
{
|
||||
public MATick(int iTime, float fMA)
|
||||
{
|
||||
m_iTime = iTime;
|
||||
m_fMA = fMA;
|
||||
}
|
||||
|
||||
public int m_iTime;
|
||||
public float m_fMA;
|
||||
}
|
||||
public int m_iTime;
|
||||
public float m_fMA;
|
||||
}
|
||||
|
||||
|
||||
public string m_strCode;
|
||||
public string m_strCode;
|
||||
public string m_strCodeName;
|
||||
public DSCBO1Lib.StockCur m_StockCur = null;
|
||||
public int m_iCurPrice;
|
||||
@@ -64,27 +64,27 @@ namespace upper_limit_crawler
|
||||
public int m_iBidCnt;
|
||||
|
||||
|
||||
List<PriceNode> m_PriceList = new List<PriceNode>();
|
||||
List<PriceNode> m_PriceList = new List<PriceNode>();
|
||||
|
||||
// key : time(hh:mm:ss)
|
||||
SortedList<int, CandleTick> m_1MinChart = new SortedList<int, CandleTick>();
|
||||
SortedList<int, MATick> m_5MAChart = new SortedList<int, MATick>();
|
||||
// key : time(hh:mm:ss)
|
||||
SortedList<int, CandleTick> m_1MinChart = new SortedList<int, CandleTick>();
|
||||
SortedList<int, MATick> m_5MAChart = new SortedList<int, MATick>();
|
||||
|
||||
public void InsertPriceNode(int iTime, int iPrice)
|
||||
{
|
||||
PriceNode node = new PriceNode(iTime, iPrice);
|
||||
m_PriceList.Add(node);
|
||||
|
||||
Insert1MinChart(iTime, iPrice);
|
||||
Insert5MinChart(iTime);
|
||||
}
|
||||
|
||||
public void Received()
|
||||
public void InsertPriceNode(int iTime, int iPrice)
|
||||
{
|
||||
int iTime = (int)m_StockCur.GetHeaderValue(18);
|
||||
int iTime2 = m_StockCur.GetHeaderValue(3);
|
||||
PriceNode node = new PriceNode(iTime, iPrice);
|
||||
m_PriceList.Add(node);
|
||||
|
||||
m_iCurPrice = m_StockCur.GetHeaderValue(13);
|
||||
Insert1MinChart(iTime, iPrice);
|
||||
Insert5MinChart(iTime);
|
||||
}
|
||||
|
||||
public void Received()
|
||||
{
|
||||
int iTime = (int)m_StockCur.GetHeaderValue(18);
|
||||
int iTime2 = m_StockCur.GetHeaderValue(3);
|
||||
|
||||
m_iCurPrice = m_StockCur.GetHeaderValue(13);
|
||||
m_iPrevClosing = m_iCurPrice - m_StockCur.GetHeaderValue(2);
|
||||
m_iStartPrice = m_StockCur.GetHeaderValue(4);
|
||||
m_iHighestPrice = m_StockCur.GetHeaderValue(5);
|
||||
@@ -92,161 +92,213 @@ namespace upper_limit_crawler
|
||||
m_iBidPrice = m_StockCur.GetHeaderValue(8);
|
||||
m_iBidCnt = 0;
|
||||
|
||||
InsertPriceNode(iTime, m_iCurPrice);
|
||||
}
|
||||
InsertPriceNode(iTime, m_iCurPrice);
|
||||
}
|
||||
|
||||
public int GetHour(int iTime)
|
||||
{
|
||||
return iTime / 10000;
|
||||
}
|
||||
public void FillPrice()
|
||||
{
|
||||
CPSYSDIBLib.StockChart stockChart = new CPSYSDIBLib.StockChart();
|
||||
stockChart.SetInputValue(0, m_strCode);
|
||||
stockChart.SetInputValue(1, '1');
|
||||
string strDate = UlUtil.GetCurTime().ToString("yyyyMMdd");
|
||||
stockChart.SetInputValue(2, strDate);
|
||||
stockChart.SetInputValue(3, strDate);
|
||||
stockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5 });
|
||||
stockChart.SetInputValue(6, 'm');
|
||||
stockChart.BlockRequest2(1);
|
||||
|
||||
public int GetMinute(int iTime)
|
||||
{
|
||||
return (iTime / 100) % 100;
|
||||
}
|
||||
int iCnt = (int)stockChart.GetHeaderValue(3);
|
||||
int iFieldCnt = stockChart.GetHeaderValue(1);
|
||||
string[] astrFieldName = stockChart.GetHeaderValue(2);
|
||||
|
||||
public int GetSecond(int iTime)
|
||||
{
|
||||
return iTime % 100;
|
||||
}
|
||||
for (int i = iCnt - 1; i >= 0; i--)
|
||||
{
|
||||
int iTime = (int)stockChart.GetDataValue(1, i);
|
||||
int iPrice = (int)stockChart.GetDataValue(5, i);
|
||||
|
||||
public int GetTimeKey1Min(int iHour, int iMin, int iSecond)
|
||||
{
|
||||
return iHour*10000 + iMin*100 + iSecond;
|
||||
}
|
||||
iTime *= 100;
|
||||
|
||||
void Insert1MinChart(int iTime, int iPrice)
|
||||
{
|
||||
int iHour = GetHour(iTime);
|
||||
int iMin = GetMinute(iTime);
|
||||
int iSec = GetSecond(iTime);
|
||||
InsertPriceNode(iTime, iPrice);
|
||||
}
|
||||
}
|
||||
|
||||
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
|
||||
public int GetHour(int iTime)
|
||||
{
|
||||
return iTime / 10000;
|
||||
}
|
||||
|
||||
if (m_1MinChart.ContainsKey(iKey) == false)
|
||||
{
|
||||
CandleTick tick1 = new CandleTick(iTime, iPrice);
|
||||
m_1MinChart.Add(iKey, tick1);
|
||||
}
|
||||
else
|
||||
{
|
||||
CandleTick tick1 = m_1MinChart[iKey];
|
||||
tick1.m_iTime = iTime;
|
||||
tick1.m_iEnd = iPrice;
|
||||
tick1.m_iLowest = Math.Min(tick1.m_iLowest, iPrice);
|
||||
tick1.m_iHighest = Math.Max(tick1.m_iHighest, iPrice);
|
||||
}
|
||||
}
|
||||
public int GetMinute(int iTime)
|
||||
{
|
||||
return (iTime / 100) % 100;
|
||||
}
|
||||
|
||||
public void MakeChart()
|
||||
{
|
||||
foreach (PriceNode node in m_PriceList)
|
||||
{
|
||||
int iTime = node.m_iTime;
|
||||
int iPrice = node.m_iPrice;
|
||||
public int GetSecond(int iTime)
|
||||
{
|
||||
return iTime % 100;
|
||||
}
|
||||
|
||||
int iHour = GetHour(iTime);
|
||||
int iMin = GetMinute(iTime);
|
||||
int iSec = GetSecond(iTime);
|
||||
public int GetTimeKey1Min(int iHour, int iMin, int iSecond)
|
||||
{
|
||||
return iHour*10000 + iMin*100 + iSecond;
|
||||
}
|
||||
|
||||
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
|
||||
void Insert1MinChart(int iTime, int iPrice)
|
||||
{
|
||||
int iHour = GetHour(iTime);
|
||||
int iMin = GetMinute(iTime);
|
||||
int iSec = GetSecond(iTime);
|
||||
|
||||
if (m_1MinChart.ContainsKey(iKey) == false)
|
||||
{
|
||||
CandleTick tick1 = new CandleTick(iTime, node.m_iPrice);
|
||||
m_1MinChart.Add(iKey, tick1);
|
||||
}
|
||||
else
|
||||
{
|
||||
CandleTick tick1 = m_1MinChart[iKey];
|
||||
tick1.m_iTime = iTime;
|
||||
tick1.m_iEnd = iPrice;
|
||||
tick1.m_iLowest = Math.Min(tick1.m_iLowest, iPrice);
|
||||
tick1.m_iHighest = Math.Max(tick1.m_iHighest, iPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
|
||||
|
||||
bool IsIn5Min(int iBaseKey, int iKeyCheck)
|
||||
{
|
||||
int iBaseIdx = m_1MinChart.IndexOfKey(iBaseKey);
|
||||
int iIdxCheck = m_1MinChart.IndexOfKey(iKeyCheck);
|
||||
if (m_1MinChart.ContainsKey(iKey) == false)
|
||||
{
|
||||
CandleTick tick1 = new CandleTick(iTime, iPrice);
|
||||
m_1MinChart.Add(iKey, tick1);
|
||||
}
|
||||
else
|
||||
{
|
||||
CandleTick tick1 = m_1MinChart[iKey];
|
||||
tick1.m_iTime = iTime;
|
||||
tick1.m_iEnd = iPrice;
|
||||
tick1.m_iLowest = Math.Min(tick1.m_iLowest, iPrice);
|
||||
tick1.m_iHighest = Math.Max(tick1.m_iHighest, iPrice);
|
||||
}
|
||||
}
|
||||
|
||||
return (iIdxCheck > iBaseIdx - 5 && iIdxCheck <= iBaseIdx);
|
||||
}
|
||||
public void MakeChart()
|
||||
{
|
||||
foreach (PriceNode node in m_PriceList)
|
||||
{
|
||||
int iTime = node.m_iTime;
|
||||
int iPrice = node.m_iPrice;
|
||||
|
||||
void Insert5MinChart(int iTime)
|
||||
{
|
||||
int iHour = GetHour(iTime);
|
||||
int iMin = GetMinute(iTime);
|
||||
int iSec = GetSecond(iTime);
|
||||
int iHour = GetHour(iTime);
|
||||
int iMin = GetMinute(iTime);
|
||||
int iSec = GetSecond(iTime);
|
||||
|
||||
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
|
||||
MATick tick = null;
|
||||
if (m_5MAChart.ContainsKey(iKey) == false)
|
||||
tick = new MATick(iTime, 0);
|
||||
else
|
||||
tick = m_5MAChart[iKey];
|
||||
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
|
||||
|
||||
int iIdx = m_1MinChart.IndexOfKey(iKey);
|
||||
IEnumerable<KeyValuePair<int, CandleTick>> Search = m_1MinChart.Where(r => IsIn5Min(iKey, r.Key));
|
||||
float fMA = Search.Count() == 5 ? (float)Search.Average(r => r.Value.m_iEnd) : 0;
|
||||
tick.m_fMA = fMA;
|
||||
if (m_1MinChart.ContainsKey(iKey) == false)
|
||||
{
|
||||
CandleTick tick1 = new CandleTick(iTime, node.m_iPrice);
|
||||
m_1MinChart.Add(iKey, tick1);
|
||||
}
|
||||
else
|
||||
{
|
||||
CandleTick tick1 = m_1MinChart[iKey];
|
||||
tick1.m_iTime = iTime;
|
||||
tick1.m_iEnd = iPrice;
|
||||
tick1.m_iLowest = Math.Min(tick1.m_iLowest, iPrice);
|
||||
tick1.m_iHighest = Math.Max(tick1.m_iHighest, iPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(m_5MAChart.ContainsKey(iKey) == true)
|
||||
m_5MAChart[iKey] = tick;
|
||||
else
|
||||
m_5MAChart.Add(iKey, tick);
|
||||
}
|
||||
bool IsIn5Min(int iBaseKey, int iKeyCheck)
|
||||
{
|
||||
int iBaseIdx = m_1MinChart.IndexOfKey(iBaseKey);
|
||||
int iIdxCheck = m_1MinChart.IndexOfKey(iKeyCheck);
|
||||
|
||||
public void MakeMAChart()
|
||||
{
|
||||
foreach (KeyValuePair<int, CandleTick> node in m_1MinChart)
|
||||
{
|
||||
int iTime = node.Key;
|
||||
return (iIdxCheck > iBaseIdx - 5 && iIdxCheck <= iBaseIdx);
|
||||
}
|
||||
|
||||
int iHour = GetHour(iTime);
|
||||
int iMin = GetMinute(iTime);
|
||||
int iSec = GetSecond(iTime);
|
||||
void Insert5MinChart(int iTime)
|
||||
{
|
||||
int iHour = GetHour(iTime);
|
||||
int iMin = GetMinute(iTime);
|
||||
int iSec = GetSecond(iTime);
|
||||
|
||||
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
|
||||
MATick tick = null;
|
||||
if (m_5MAChart.ContainsKey(iKey) == false)
|
||||
tick = new MATick(iTime, 0);
|
||||
else
|
||||
tick = m_5MAChart[iKey];
|
||||
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
|
||||
MATick tick = null;
|
||||
if (m_5MAChart.ContainsKey(iKey) == false)
|
||||
tick = new MATick(iTime, 0);
|
||||
else
|
||||
tick = m_5MAChart[iKey];
|
||||
|
||||
int iIdx = m_1MinChart.IndexOfKey(iKey);
|
||||
IEnumerable<KeyValuePair<int, CandleTick>> Search = m_1MinChart.Where(r => IsIn5Min(iKey, r.Key));
|
||||
float fMA = Search.Count() == 5 ? (float)Search.Average(r => r.Value.m_iEnd) : 0;
|
||||
tick.m_fMA = fMA;
|
||||
int iIdx = m_1MinChart.IndexOfKey(iKey);
|
||||
IEnumerable<KeyValuePair<int, CandleTick>> Search = m_1MinChart.Where(r => IsIn5Min(iKey, r.Key));
|
||||
float fMA = Search.Count() == 5 ? (float)Search.Average(r => r.Value.m_iEnd) : 0;
|
||||
tick.m_fMA = fMA;
|
||||
|
||||
m_5MAChart.Add(iKey, tick);
|
||||
}
|
||||
}
|
||||
if(m_5MAChart.ContainsKey(iKey) == true)
|
||||
m_5MAChart[iKey] = tick;
|
||||
else
|
||||
m_5MAChart.Add(iKey, tick);
|
||||
}
|
||||
|
||||
public void PrintChart()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("======= 1 MINUTE CHART =======");
|
||||
public void MakeMAChart()
|
||||
{
|
||||
foreach (KeyValuePair<int, CandleTick> node in m_1MinChart)
|
||||
{
|
||||
int iTime = node.Key;
|
||||
|
||||
for(int i=0; i< m_1MinChart.Keys.Count; i++)
|
||||
{
|
||||
int iKey = m_1MinChart.Keys[i];
|
||||
CandleTick node1Min = m_1MinChart.Values[i];
|
||||
MATick node5MA = m_5MAChart.ContainsKey(iKey) ? m_5MAChart[iKey] : null;
|
||||
int iHour = GetHour(iTime);
|
||||
int iMin = GetMinute(iTime);
|
||||
int iSec = GetSecond(iTime);
|
||||
|
||||
sb.AppendFormat("{0:######} : {1:###,###,###} ({2:###,###.###})\n", iKey, node1Min.m_iEnd, node5MA != null ? node5MA.m_fMA : 0);
|
||||
}
|
||||
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
|
||||
MATick tick = null;
|
||||
if (m_5MAChart.ContainsKey(iKey) == false)
|
||||
tick = new MATick(iTime, 0);
|
||||
else
|
||||
tick = m_5MAChart[iKey];
|
||||
|
||||
sb.AppendLine("======= END =======");
|
||||
Console.WriteLine(sb.ToString());
|
||||
}
|
||||
int iIdx = m_1MinChart.IndexOfKey(iKey);
|
||||
IEnumerable<KeyValuePair<int, CandleTick>> Search = m_1MinChart.Where(r => IsIn5Min(iKey, r.Key));
|
||||
float fMA = Search.Count() == 5 ? (float)Search.Average(r => r.Value.m_iEnd) : 0;
|
||||
tick.m_fMA = fMA;
|
||||
|
||||
public bool IsUpSlope()
|
||||
{
|
||||
m_5MAChart.Add(iKey, tick);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public void PrintChart()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("======= 1 MINUTE CHART =======");
|
||||
|
||||
for(int i=0; i< m_1MinChart.Keys.Count; i++)
|
||||
{
|
||||
int iKey = m_1MinChart.Keys[i];
|
||||
CandleTick node1Min = m_1MinChart.Values[i];
|
||||
MATick node5MA = m_5MAChart.ContainsKey(iKey) ? m_5MAChart[iKey] : null;
|
||||
|
||||
sb.AppendFormat("{0:######} : {1:###,###,###} ({2:###,##0.###})\n", iKey, node1Min.m_iEnd, node5MA != null ? node5MA.m_fMA : 0);
|
||||
}
|
||||
|
||||
sb.AppendLine("======= END =======");
|
||||
Console.WriteLine(sb.ToString());
|
||||
}
|
||||
|
||||
public bool Is5MAGoingUp()
|
||||
{
|
||||
if(m_5MAChart.Values.Count >= 2)
|
||||
{
|
||||
MATick lastMA = m_5MAChart.Values[m_5MAChart.Values.Count - 1];
|
||||
MATick prevMA = m_5MAChart.Values[m_5MAChart.Values.Count - 2];
|
||||
|
||||
if (lastMA.m_fMA > prevMA.m_fMA)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[Is5MAGoingUp][{0}] ma up ({1}, {2}", m_strCodeName, lastMA.m_fMA, prevMA.m_fMA));
|
||||
return true;
|
||||
}
|
||||
else if(lastMA.m_fMA == 0)
|
||||
{
|
||||
if(m_1MinChart.Values.Count >= 2)
|
||||
{
|
||||
CandleTick lastTick = m_1MinChart.Values[m_1MinChart.Values.Count - 1];
|
||||
CandleTick prevTick = m_1MinChart.Values[m_1MinChart.Values.Count - 1];
|
||||
|
||||
if (lastTick.m_iEnd > prevTick.m_iEnd)
|
||||
{
|
||||
UlUtil.Trace(string.Format("[Is5MAGoingUp][{0}] cur up ({1}, {2}", m_strCodeName, lastTick.m_iEnd, prevTick.m_iEnd));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
UlUtil.cs
24
UlUtil.cs
@@ -31,11 +31,11 @@ namespace upper_limit_crawler
|
||||
m_strLogFileName += "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".txt";
|
||||
}
|
||||
|
||||
public static void SyncServerTime()
|
||||
{
|
||||
DateTime time = GetFastestNISTDate();
|
||||
m_TimeDiff = time - DateTime.Now;
|
||||
}
|
||||
public static void SyncServerTime()
|
||||
{
|
||||
DateTime time = GetFastestNISTDate();
|
||||
m_TimeDiff = time - DateTime.Now;
|
||||
}
|
||||
|
||||
public static DateTime GetCurTime()
|
||||
{
|
||||
@@ -219,13 +219,13 @@ namespace upper_limit_crawler
|
||||
return (m_CPUtil.IsConnect==1);
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
m_CPUtil = null;
|
||||
System.GC.Collect(0, GCCollectionMode.Forced);
|
||||
System.GC.WaitForFullGCComplete();
|
||||
public static void Reset()
|
||||
{
|
||||
m_CPUtil = null;
|
||||
System.GC.Collect(0, GCCollectionMode.Forced);
|
||||
System.GC.WaitForFullGCComplete();
|
||||
|
||||
m_CPUtil = new CPUTILLib.CpCybos();
|
||||
}
|
||||
m_CPUtil = new CPUTILLib.CpCybos();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user