36 Commits

Author SHA1 Message Date
5bb7f2363a 현재가, 매수 후 최고가 디버그 2016-08-11 01:02:54 +09:00
eb48b58b7e 임시저장 2016-08-10 16:07:55 +09:00
5714cb3388 개발중 2016-08-09 14:42:50 +09:00
d41130fcdd - BinaryRage DB 로그 추가 2016-08-02 02:03:22 +09:00
a5783ad90f Merge branch 'develop' of git.mjjo53.us.to:mjjo/upper-limit-crawler into develop 2016-08-01 23:29:03 +09:00
c8028fffe4 5MA slope 구할 때 index 안 맞는 문제 처리 2016-08-01 23:28:31 +09:00
mjjo
c94598d20c - 매수, 매도 정보 leveldb로 저장 2016-08-01 18:58:02 +09:00
mjjo
f450f20d79 - 5MA가 없는 상태에서도 매수하도록 2016-08-01 09:31:12 +09:00
367c57cb49 - 현금잔고, 평가손익 표시 추가 2016-08-01 03:09:17 +09:00
62315062bf - 5MA 계산 버그 수정
- 매수, 매도 조건 수정 : 5MA slope 조건 추가
- 기본 파라미터 수정
2016-08-01 01:29:48 +09:00
b831b56934 - 시간 계산식 수정
- 보합 처리 추가
2016-07-29 02:59:07 +09:00
76e94dd4fc 체결되면 balance 갱신 2016-07-28 21:56:31 +09:00
7690bcb4cc blacklist 5분 검사 함수 수정 2016-07-28 21:47:22 +09:00
dd7c35c73f trace 정리 2016-07-28 21:30:56 +09:00
ccef98ad77 - 5MA 상승 시점에 매수, 5MA 하락 시점에 매도
- 검증
2016-07-27 01:37:40 +09:00
35165922c4 검증 개발 중 2016-07-26 09:30:43 +09:00
mjjo
ab2181747f 1 min CandleTick이 완료됐을 때 5 MA tick을 생성하도록 수정 2016-07-25 11:11:45 +09:00
3fb2c4adbe - BlackList에 5분 적용 2016-07-25 04:05:45 +09:00
f5af5eaef3 - ULWatchItem.Is5MAGoingUp() 함수 추가
- ULWatchItem.FillPrice() 함수 추가
2016-07-25 03:52:01 +09:00
604795159e 1분 candle chart, 5MA 추가 2016-07-25 03:11:55 +09:00
7c63795f12 로그 수정
기본 파라미터 변경
watch 삭제
2016-07-22 16:31:43 +09:00
53af49336b 현재가를 객체별 함수로 나눔 2016-07-21 23:30:43 +09:00
bf4dd6a94d 인터넷 시간 추가 2016-07-21 00:25:01 +09:00
7aec7e8361 - monitor, balance subscribe로 수정
- UI 개선
2016-07-20 23:46:28 +09:00
069557e102 실시간으로 수정 2016-07-14 00:52:17 +09:00
mjjo
06a27f7b0e Merge branch 'develop' of git.mjjo53.us.to:mjjo/upper-limit-crawler into develop 2016-07-11 16:28:54 +09:00
mjjo
5216d627b2 서버 로그 추가 2016-07-11 16:28:27 +09:00
f92ddb7945 트레일링, 손절 추가 2016-07-08 01:58:13 +09:00
2b179e6df6 잔고 리스트에서 현재가 갱신 2016-07-08 00:56:43 +09:00
mjjo
8f5a36f2ee 플로우 약간 수정 2016-07-07 19:08:39 +09:00
c0a93e082a 잔고 평가 dlg 추가 2016-07-07 01:58:22 +09:00
mjjo
8006843ff0 sell 함수 추가 2016-07-06 18:43:22 +09:00
313e0fb163 검색, 구매, 구매 확인 구현 2016-07-06 16:51:23 +09:00
e15eedc63f 기본적인 프레임워크 구현 2016-02-20 18:37:49 +09:00
2f52865d14 지정된 시간동안에만 실행되도록 수정 2015-07-14 01:17:58 +09:00
70164fced8 항상 받도록 테스트 2015-07-14 01:02:56 +09:00
27 changed files with 3718 additions and 167 deletions

1
.gitignore vendored
View File

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

61
Form1.Designer.cs generated
View File

@@ -1,61 +0,0 @@
namespace upper_limit_crawler
{
partial class Form1
{
/// <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.btSearch = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btSearch
//
this.btSearch.Location = new System.Drawing.Point(40, 106);
this.btSearch.Name = "btSearch";
this.btSearch.Size = new System.Drawing.Size(139, 88);
this.btSearch.TabIndex = 0;
this.btSearch.Text = "Search";
this.btSearch.UseVisualStyleBackColor = true;
this.btSearch.Click += new System.EventHandler(this.btSearch_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(454, 381);
this.Controls.Add(this.btSearch);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button btSearch;
}
}

View File

@@ -1,75 +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;
namespace upper_limit_crawler
{
public partial class Form1 : Form
{
CPSYSDIBLib.CpSvrNew7043 m_7043 = new CPSYSDIBLib.CpSvrNew7043();
public Form1()
{
InitializeComponent();
}
private void btSearch_Click(object sender, EventArgs e)
{
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);
int iResult = m_7043.BlockRequest2(1);
if(iResult != 0)
{
MessageBox.Show("요청 에러");
return;
}
Console.WriteLine(string.Format("종목/현재가/대비플래그/대비/대비율/거래량/시가/시가대비/시가대비율/연속일"));
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);
Console.WriteLine(string.Format("[{0}:{1}]/{2}/{3}/{4}/{5}/{6}/{7}/{8}/{9}/{10}",
Name, Code,
CurPrice, flag, Comp, CompRate,
DealAmount, StartPrice, StartPriceComp, StartPriceCompRate,
SerialDay));
}
bContinue = (m_7043.Continue == 1);
if (bContinue == true)
iResult = m_7043.BlockRequest2(1);
}
}
}
}

534
MainForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,534 @@
namespace upper_limit_crawler
{
partial class MainForm
{
/// <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.tbLog = new System.Windows.Forms.TextBox();
this.tbSearchMax = new System.Windows.Forms.TextBox();
this.tbBidMin = new System.Windows.Forms.TextBox();
this.tbBidAmount = new System.Windows.Forms.TextBox();
this.tbTimeout = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.tbTrailing = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.tbLossCut = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.tbSearchMin = new System.Windows.Forms.TextBox();
this.btApply = new System.Windows.Forms.Button();
this.btCancel = new System.Windows.Forms.Button();
this.tbBidMax = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.button1 = new System.Windows.Forms.Button();
this.btLogDump = new System.Windows.Forms.Button();
this.btMATest = new System.Windows.Forms.Button();
this.btTimeSync = new System.Windows.Forms.Button();
this.cbStart = new System.Windows.Forms.CheckBox();
this.btCybosPlus = new System.Windows.Forms.Button();
this.btCybos5 = new System.Windows.Forms.Button();
this.lbSBCnt = new System.Windows.Forms.Label();
this.lbRQCnt = new System.Windows.Forms.Label();
this.lbEvalProfit = new System.Windows.Forms.Label();
this.lbCacheBalance = new System.Windows.Forms.Label();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
this.splitContainer3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
this.SuspendLayout();
//
// tbLog
//
this.tbLog.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.tbLog.BackColor = System.Drawing.SystemColors.Control;
this.tbLog.HideSelection = false;
this.tbLog.Location = new System.Drawing.Point(12, 3);
this.tbLog.Multiline = true;
this.tbLog.Name = "tbLog";
this.tbLog.ReadOnly = true;
this.tbLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.tbLog.Size = new System.Drawing.Size(862, 84);
this.tbLog.TabIndex = 2;
//
// tbSearchMax
//
this.tbSearchMax.Location = new System.Drawing.Point(160, 23);
this.tbSearchMax.Name = "tbSearchMax";
this.tbSearchMax.Size = new System.Drawing.Size(37, 21);
this.tbSearchMax.TabIndex = 6;
this.tbSearchMax.Text = "10.5%";
this.tbSearchMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// tbBidMin
//
this.tbBidMin.Location = new System.Drawing.Point(97, 50);
this.tbBidMin.Name = "tbBidMin";
this.tbBidMin.Size = new System.Drawing.Size(37, 21);
this.tbBidMin.TabIndex = 8;
this.tbBidMin.Text = "9.0%";
this.tbBidMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// tbBidAmount
//
this.tbBidAmount.Location = new System.Drawing.Point(97, 77);
this.tbBidAmount.Name = "tbBidAmount";
this.tbBidAmount.Size = new System.Drawing.Size(100, 21);
this.tbBidAmount.TabIndex = 9;
this.tbBidAmount.Text = "100,000";
this.tbBidAmount.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// tbTimeout
//
this.tbTimeout.Location = new System.Drawing.Point(97, 104);
this.tbTimeout.Name = "tbTimeout";
this.tbTimeout.Size = new System.Drawing.Size(100, 21);
this.tbTimeout.TabIndex = 10;
this.tbTimeout.Text = "120";
this.tbTimeout.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(38, 26);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 11;
this.label1.Text = "검색범위";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(38, 53);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 12;
this.label2.Text = "매수범위";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(38, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(41, 12);
this.label3.TabIndex = 13;
this.label3.Text = "매수금";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(38, 107);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(53, 12);
this.label4.TabIndex = 13;
this.label4.Text = "타임아웃";
//
// tbTrailing
//
this.tbTrailing.Location = new System.Drawing.Point(97, 131);
this.tbTrailing.Name = "tbTrailing";
this.tbTrailing.Size = new System.Drawing.Size(100, 21);
this.tbTrailing.TabIndex = 10;
this.tbTrailing.Text = "3.0%";
this.tbTrailing.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(38, 134);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(53, 12);
this.label5.TabIndex = 13;
this.label5.Text = "트레일링";
//
// tbLossCut
//
this.tbLossCut.Location = new System.Drawing.Point(97, 158);
this.tbLossCut.Name = "tbLossCut";
this.tbLossCut.Size = new System.Drawing.Size(100, 21);
this.tbLossCut.TabIndex = 10;
this.tbLossCut.Text = "3.0%";
this.tbLossCut.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(38, 161);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(29, 12);
this.label6.TabIndex = 13;
this.label6.Text = "손절";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(140, 26);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(14, 12);
this.label7.TabIndex = 11;
this.label7.Text = "~";
//
// tbSearchMin
//
this.tbSearchMin.Location = new System.Drawing.Point(97, 23);
this.tbSearchMin.Name = "tbSearchMin";
this.tbSearchMin.Size = new System.Drawing.Size(37, 21);
this.tbSearchMin.TabIndex = 14;
this.tbSearchMin.Text = "7.0%";
this.tbSearchMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// btApply
//
this.btApply.Location = new System.Drawing.Point(97, 185);
this.btApply.Name = "btApply";
this.btApply.Size = new System.Drawing.Size(44, 23);
this.btApply.TabIndex = 15;
this.btApply.Text = "적용";
this.btApply.UseVisualStyleBackColor = true;
this.btApply.Click += new System.EventHandler(this.btApply_Click);
//
// btCancel
//
this.btCancel.Location = new System.Drawing.Point(153, 185);
this.btCancel.Name = "btCancel";
this.btCancel.Size = new System.Drawing.Size(44, 23);
this.btCancel.TabIndex = 16;
this.btCancel.Text = "취소";
this.btCancel.UseVisualStyleBackColor = true;
this.btCancel.Click += new System.EventHandler(this.btCancel_Click);
//
// tbBidMax
//
this.tbBidMax.Location = new System.Drawing.Point(160, 50);
this.tbBidMax.Name = "tbBidMax";
this.tbBidMax.Size = new System.Drawing.Size(37, 21);
this.tbBidMax.TabIndex = 8;
this.tbBidMax.Text = "10.0%";
this.tbBidMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(140, 53);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(14, 12);
this.label8.TabIndex = 11;
this.label8.Text = "~";
//
// splitContainer1
//
this.splitContainer1.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.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.tbLog);
this.splitContainer1.Size = new System.Drawing.Size(886, 714);
this.splitContainer1.SplitterDistance = 611;
this.splitContainer1.TabIndex = 20;
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.splitContainer3);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.button1);
this.splitContainer2.Panel2.Controls.Add(this.btLogDump);
this.splitContainer2.Panel2.Controls.Add(this.btMATest);
this.splitContainer2.Panel2.Controls.Add(this.btTimeSync);
this.splitContainer2.Panel2.Controls.Add(this.cbStart);
this.splitContainer2.Panel2.Controls.Add(this.btCybosPlus);
this.splitContainer2.Panel2.Controls.Add(this.btCybos5);
this.splitContainer2.Panel2.Controls.Add(this.lbSBCnt);
this.splitContainer2.Panel2.Controls.Add(this.lbRQCnt);
this.splitContainer2.Panel2.Controls.Add(this.label1);
this.splitContainer2.Panel2.Controls.Add(this.label5);
this.splitContainer2.Panel2.Controls.Add(this.tbTimeout);
this.splitContainer2.Panel2.Controls.Add(this.tbSearchMax);
this.splitContainer2.Panel2.Controls.Add(this.label7);
this.splitContainer2.Panel2.Controls.Add(this.btCancel);
this.splitContainer2.Panel2.Controls.Add(this.lbEvalProfit);
this.splitContainer2.Panel2.Controls.Add(this.lbCacheBalance);
this.splitContainer2.Panel2.Controls.Add(this.label6);
this.splitContainer2.Panel2.Controls.Add(this.label2);
this.splitContainer2.Panel2.Controls.Add(this.label4);
this.splitContainer2.Panel2.Controls.Add(this.tbBidMin);
this.splitContainer2.Panel2.Controls.Add(this.tbBidAmount);
this.splitContainer2.Panel2.Controls.Add(this.tbLossCut);
this.splitContainer2.Panel2.Controls.Add(this.label8);
this.splitContainer2.Panel2.Controls.Add(this.btApply);
this.splitContainer2.Panel2.Controls.Add(this.tbSearchMin);
this.splitContainer2.Panel2.Controls.Add(this.tbTrailing);
this.splitContainer2.Panel2.Controls.Add(this.label3);
this.splitContainer2.Panel2.Controls.Add(this.tbBidMax);
this.splitContainer2.Size = new System.Drawing.Size(886, 611);
this.splitContainer2.SplitterDistance = 645;
this.splitContainer2.TabIndex = 0;
//
// splitContainer3
//
this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer3.Location = new System.Drawing.Point(0, 0);
this.splitContainer3.Name = "splitContainer3";
this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
this.splitContainer3.Size = new System.Drawing.Size(645, 611);
this.splitContainer3.SplitterDistance = 256;
this.splitContainer3.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(118, 555);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 35);
this.button1.TabIndex = 25;
this.button1.Text = "Dump Simulation";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// btLogDump
//
this.btLogDump.Location = new System.Drawing.Point(21, 555);
this.btLogDump.Name = "btLogDump";
this.btLogDump.Size = new System.Drawing.Size(75, 35);
this.btLogDump.TabIndex = 25;
this.btLogDump.Text = "Dump Log";
this.btLogDump.UseVisualStyleBackColor = true;
this.btLogDump.Click += new System.EventHandler(this.btLogDump_Click);
//
// btMATest
//
this.btMATest.Location = new System.Drawing.Point(113, 404);
this.btMATest.Name = "btMATest";
this.btMATest.Size = new System.Drawing.Size(84, 57);
this.btMATest.TabIndex = 24;
this.btMATest.Text = "Simulation";
this.btMATest.UseVisualStyleBackColor = true;
this.btMATest.Click += new System.EventHandler(this.btMATest_Click);
//
// btTimeSync
//
this.btTimeSync.Location = new System.Drawing.Point(16, 341);
this.btTimeSync.Name = "btTimeSync";
this.btTimeSync.Size = new System.Drawing.Size(84, 57);
this.btTimeSync.TabIndex = 22;
this.btTimeSync.Text = "Time Sync";
this.btTimeSync.UseVisualStyleBackColor = true;
this.btTimeSync.Click += new System.EventHandler(this.btTimeSync_Click);
//
// cbStart
//
this.cbStart.Appearance = System.Windows.Forms.Appearance.Button;
this.cbStart.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.cbStart.Location = new System.Drawing.Point(16, 404);
this.cbStart.Name = "cbStart";
this.cbStart.Size = new System.Drawing.Size(84, 57);
this.cbStart.TabIndex = 21;
this.cbStart.Text = "Start";
this.cbStart.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.cbStart.UseVisualStyleBackColor = true;
this.cbStart.CheckedChanged += new System.EventHandler(this.cbStart_CheckedChanged);
//
// btCybosPlus
//
this.btCybosPlus.Location = new System.Drawing.Point(113, 467);
this.btCybosPlus.Name = "btCybosPlus";
this.btCybosPlus.Size = new System.Drawing.Size(84, 67);
this.btCybosPlus.TabIndex = 20;
this.btCybosPlus.Text = "Cybos Plus";
this.btCybosPlus.UseVisualStyleBackColor = true;
this.btCybosPlus.Click += new System.EventHandler(this.btCybosPlus_Click);
//
// btCybos5
//
this.btCybos5.Location = new System.Drawing.Point(16, 467);
this.btCybos5.Name = "btCybos5";
this.btCybos5.Size = new System.Drawing.Size(84, 67);
this.btCybos5.TabIndex = 20;
this.btCybos5.Text = "Cybos 5";
this.btCybos5.UseVisualStyleBackColor = true;
this.btCybos5.Click += new System.EventHandler(this.btCybos5_Click);
//
// lbSBCnt
//
this.lbSBCnt.AutoSize = true;
this.lbSBCnt.Location = new System.Drawing.Point(20, 297);
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(20, 273);
this.lbRQCnt.Name = "lbRQCnt";
this.lbRQCnt.Size = new System.Drawing.Size(71, 12);
this.lbRQCnt.TabIndex = 18;
this.lbRQCnt.Text = "RQ Count : ";
//
// lbEvalProfit
//
this.lbEvalProfit.AutoSize = true;
this.lbEvalProfit.Location = new System.Drawing.Point(38, 244);
this.lbEvalProfit.Name = "lbEvalProfit";
this.lbEvalProfit.Size = new System.Drawing.Size(53, 12);
this.lbEvalProfit.TabIndex = 13;
this.lbEvalProfit.Text = "평가손익";
//
// lbCacheBalance
//
this.lbCacheBalance.AutoSize = true;
this.lbCacheBalance.Location = new System.Drawing.Point(38, 222);
this.lbCacheBalance.Name = "lbCacheBalance";
this.lbCacheBalance.Size = new System.Drawing.Size(29, 12);
this.lbCacheBalance.TabIndex = 13;
this.lbCacheBalance.Text = "잔고";
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 720);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1,
this.statusBarPanel2});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(886, 22);
this.statusBar1.TabIndex = 21;
this.statusBar1.Text = "statusBar1";
//
// statusBarPanel1
//
this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
this.statusBarPanel1.Name = "statusBarPanel1";
this.statusBarPanel1.Width = 749;
//
// statusBarPanel2
//
this.statusBarPanel2.MinWidth = 120;
this.statusBarPanel2.Name = "statusBarPanel2";
this.statusBarPanel2.Width = 120;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(886, 742);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.splitContainer1);
this.Name = "MainForm";
this.Text = "Upper Limit";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
this.splitContainer2.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TextBox tbLog;
private System.Windows.Forms.TextBox tbSearchMax;
private System.Windows.Forms.TextBox tbBidMin;
private System.Windows.Forms.TextBox tbBidAmount;
private System.Windows.Forms.TextBox tbTimeout;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox tbTrailing;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox tbLossCut;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox tbSearchMin;
private System.Windows.Forms.Button btApply;
private System.Windows.Forms.Button btCancel;
private System.Windows.Forms.TextBox tbBidMax;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.SplitContainer splitContainer3;
private System.Windows.Forms.Label lbRQCnt;
private System.Windows.Forms.Label lbSBCnt;
private System.Windows.Forms.Button btCybosPlus;
private System.Windows.Forms.Button btCybos5;
private System.Windows.Forms.CheckBox cbStart;
private System.Windows.Forms.Button btTimeSync;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;
private System.Windows.Forms.Button btMATest;
private System.Windows.Forms.Label lbCacheBalance;
private System.Windows.Forms.Label lbEvalProfit;
private System.Windows.Forms.Button btLogDump;
private System.Windows.Forms.Button button1;
}
}

525
MainForm.cs Normal file
View File

@@ -0,0 +1,525 @@
using System;
using System.Windows.Forms;
using System.Collections;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Threading;
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
{
ArrayList m_TraceList = new ArrayList();
System.Windows.Forms.Timer m_MainTimer = new System.Windows.Forms.Timer();
int m_iLastTime = 0;
static ULDataMgr m_DataMgr = new ULDataMgr();
ULOwn m_Own = new ULOwn(m_DataMgr);
ULMonitorDlg m_MonitorDlg = null;
ULBalanceDlg m_BalanceDlg = null;
public MainForm()
{
InitializeComponent();
SetDoubleBuffered(tbLog);
ULUtil.Init(tbLog);
btApply_Click(null, null);
m_MonitorDlg = new ULMonitorDlg(m_DataMgr);
splitContainer3.Panel1.Controls.Add(m_MonitorDlg);
m_MonitorDlg.Dock = DockStyle.Fill;
m_MonitorDlg.Show();
m_BalanceDlg = new ULBalanceDlg(m_DataMgr);
splitContainer3.Panel2.Controls.Add(m_BalanceDlg);
m_BalanceDlg.Dock = DockStyle.Fill;
m_BalanceDlg.Show();
m_MainTimer.Interval = 10;
m_MainTimer.Tick += Refresh;
m_MainTimer.Start();
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 });
}
private bool IsOnTime()
{
DateTime CurTime = ULUtil.GetCurTime();
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 Refresh(object sender, EventArgs e)
{
//if(IsOnTime() == false)
// return;
int iCurTime = Environment.TickCount;
if(m_iLastTime == 0)
{
m_iLastTime=iCurTime;
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();
lbCacheBalance.Text = "잔고 : " + m_DataMgr.GetCacheBalance().ToString("###,###,###,###,##0원");
lbEvalProfit.Text = "평가손익 : " + m_DataMgr.GetEvalProfit().ToString("###,###,###,###,##0원");
statusBar1.Panels[1].Text = ULUtil.GetCurTimeString() + " ";
m_iLastTime = iCurTime;
}
void StartAll()
{
m_MonitorDlg.Start();
m_BalanceDlg.Start();
m_DataMgr.StartAll();
}
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();
if (ULUtil.IsConnected() == false)
{
cbStart.Checked = false;
MessageBox.Show("Cybos Plus를 실행해주세요");
return;
}
m_DataMgr.Init();
StartAll();
}
else
{
StopAll();
}
}
private void AddTrace(string strCode)
{
if (m_TraceList.Contains(strCode) == true)
return;
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;
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_fLossCut = float.Parse(tbLossCut.Text.Replace("%", ""))/100;
btCancel_Click(null, null);
}
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") + "%";
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") + "%";
}
private void btCybos5_Click(object sender, EventArgs e)
{
string strappname = @"C:\DAISHIN\STARTER\ncStarter.exe";
Process.Start(strappname);
}
private void btCybosPlus_Click(object sender, EventArgs e)
{
string strappname = @"C:\DAISHIN\STARTER\ncStarter.exe";
Process.Start(strappname, @"/prj:cp");
}
private void btTimeSync_Click(object sender, EventArgs e)
{
ULUtil.SyncServerTime();
}
struct chart_data
{
public chart_data(int iTime, int iPrice)
{
this.iTime = iTime;
this.iPrice = iPrice;
}
public int iTime;
public int iPrice;
override public string ToString() { return string.Format("[{0]] {{1}}", iTime, iPrice); }
}
private void btMATest_Click(object sender, EventArgs e)
{
Console.WriteLine("시뮬레이션 시작");
List<string> aCodeList = new List<string> {
"A064240",
"A090410",
"A208860",
"A044180",
"A127160",
"A123570",
"A039420",
"A015020",
"A090850",
"A007660",
"A017180",
"A036810",
"A049950",
"A044480",
"A047310",
"A115610",
"A086060",
"A118000",
"A037400",
"A027580",
"A100090",
"A103130",
"A032790",
"A226350",
"A024800",
"A002630",
"A109740",
"A077970",
"A040350",
"A092870",
"A001140",
"A065130",
"A043340",
"A038010",
"A099410",
"A115440",
"A115960",
"A098120",
"A004380",
"A007120",
"A025820",
"A005980",
"A011810",
"A131100",
"A059090",
"A083470",
"A051170",
"A096350",
"A131400",
"A122800",
"A043910",
"A089590",
"A067990",
"A091970",
"A058450",
"A104040",
"A003070",
};
string strPrevDate = "20160801";
string strDate = "20160802";
int iTotalProfit = 0;
foreach (string code in aCodeList)
{
string strCode = code[0] == 'A' ? code : "A"+code;
string strCodeName = ULUtil.GetCodeName(strCode);
Console.WriteLine("{0}({1})", strCodeName, strCode);
List<chart_data> DataList = new List<chart_data>();
CPSYSDIBLib.StockChart stockChart = new CPSYSDIBLib.StockChart();
stockChart.SetInputValue(0, strCode);
stockChart.SetInputValue(1, '1');
stockChart.SetInputValue(2, strPrevDate);
stockChart.SetInputValue(3, strPrevDate);
stockChart.SetInputValue(4, 1);
stockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5, 6, 10, 37 });
stockChart.SetInputValue(6, 'T');
ULUtil.BlockRequest(stockChart);
int iTimeTest = (int)stockChart.GetDataValue(1, 0);
int iPrevClosing = stockChart.GetDataValue(5, 0);
stockChart.SetInputValue(0, strCode);
stockChart.SetInputValue(1, '1');
stockChart.SetInputValue(2, strDate);
stockChart.SetInputValue(3, strDate);
stockChart.SetInputValue(4, 0);
stockChart.SetInputValue(5, new int[] { 0, 1, 2, 3, 4, 5, 6, 10, 37 });
stockChart.SetInputValue(6, 'T');
ULUtil.BlockRequest(stockChart);
int iFieldCnt = stockChart.GetHeaderValue(1);
string[] astrFieldName = stockChart.GetHeaderValue(2);
while (true)
{
int iCnt = (int)stockChart.GetHeaderValue(3);
for (int i = 0; i < iCnt; i++)
{
int iTime = (int)stockChart.GetDataValue(1, i);
iTime *= 100;
int iCurPrice = (int)stockChart.GetDataValue(5, i);
int iVolume = (int)stockChart.GetDataValue(5, i);
DataList.Add(new chart_data(iTime, iCurPrice));
}
if(stockChart.Continue == 1)
ULUtil.BlockRequest(stockChart);
else
break;
}
int iTotalBidPrice = 0;
int iTotalAskPrice = 0;
ULWatchItem WatchItem = new ULWatchItem();
WatchItem.m_strCode = strCode;
WatchItem.m_strCodeName = strCodeName;
WatchItem.m_iCurPrice = 0;
WatchItem.m_iPrevClosing = 0;
ULBalanceDlg.OWN_ITEM OwnItem = new ULBalanceDlg.OWN_ITEM();
DataList.Reverse();
foreach (chart_data data in DataList)
{
int iTime = data.iTime;
int iCurPrice = data.iPrice;
if (WatchItem.m_iPrevClosing == 0)
WatchItem.m_iPrevClosing = iPrevClosing;
WatchItem.m_iCurPrice = iCurPrice;
WatchItem.InsertPriceNode(iTime, iCurPrice);
if (OwnItem.m_iUnitBEP != 0)
OwnItem.m_iMaxPriceAfterBid = Math.Max(iCurPrice, OwnItem.m_iMaxPriceAfterBid);
float fCompRate = WatchItem.m_iCurPrice / (float)WatchItem.m_iPrevClosing - 1.0f;
if (fCompRate >= m_DataMgr.m_Setting.m_fBidMin && fCompRate <= m_DataMgr.m_Setting.m_fBidMax)
{
m_DataMgr.AddAvailableItem(strCode);
if (m_DataMgr.IsInPostponeList(iTime, strCode) == true)
{
//Console.WriteLine("[{0}] 조건 매수 실패. black list {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"));
continue;
}
else if(m_DataMgr.IsInBlackList(strCode) == true)
{
continue;
}
float f5MASlope = WatchItem.GetPrev5MASlope(iTime);
if(f5MASlope < 0.002f)
{
//Console.WriteLine("[{0}] 조건 매수 실패. 5ma 상승하지 않음 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"));
continue;
}
// bid and add to black list
Console.WriteLine("[{0}] [{1}] 조건 매수 {2}원 ({3}) (5MA slop:{4})", iTime, WatchItem.m_strCodeName, WatchItem.m_iCurPrice, fCompRate.ToString("0.00%"), f5MASlope.ToString("0.00%"));
ULUtil.TraceCSV(iTime, "[시뮬레이션] 조건 매수", WatchItem.m_strCodeName, WatchItem.m_iCurPrice, fCompRate.ToString("0.00%"), f5MASlope.ToString("0.00%"));
m_DataMgr.AddBidLog(strCode, WatchItem.m_strCodeName, iTime, WatchItem.m_iCurPrice, f5MASlope, false);
int iBidCnt = (int)m_DataMgr.m_Setting.m_fBidAmount / iCurPrice;
iTotalBidPrice += iCurPrice* iBidCnt;
OwnItem.m_iUnitBEP = (OwnItem.m_iUnitBEP * OwnItem.m_iConclusionBalanceCnt + iCurPrice * iBidCnt) / (OwnItem.m_iConclusionBalanceCnt + iBidCnt);
OwnItem.m_iConclusionBalanceCnt += iBidCnt;
OwnItem.m_strCodeName = WatchItem.m_strCodeName;
//m_DataMgr.GetTrader().Buy(strCode, item.m_iCurPrice, (int)m_DataMgr.m_Setting.m_fBidAmount);
m_DataMgr.AddPostphoneItem(iTime, strCode);
}
if (OwnItem.m_iUnitBEP > 0)
{
// loss cut
if (iCurPrice <= OwnItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut))
{
m_DataMgr.AddLosscutItem(strCode);
int iProfit = iCurPrice - (int)OwnItem.m_iUnitBEP;
float fProfitRate = (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f);
Console.WriteLine("[{0}] [{1}] 손절 {2}원 ({3}:{4})", iTime, OwnItem.m_strCodeName, iCurPrice, iProfit, fProfitRate.ToString("0.00%"));
ULUtil.TraceCSV(iTime, "[시뮬레이션] 손절", OwnItem.m_strCodeName, iCurPrice, fProfitRate.ToString("0.00%"));
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, float.NaN, true, iProfit, fProfitRate, false);
iTotalAskPrice += iCurPrice * OwnItem.m_iConclusionBalanceCnt;
OwnItem.m_iUnitBEP = 0;
OwnItem.m_iConclusionBalanceCnt = 0;
//m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
//m_OwnList.Remove(OwnItem);
//m_DataMgr.RemoveWatch(strCode);
// own에서 삭제하고 미체결 리스트에 넣고, watch에서도 뺀다
// 미체결 잔량 취소
}
// trailing
else if (iCurPrice <= OwnItem.m_iMaxPriceAfterBid - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
{
float f5MASlope = WatchItem.GetPrev5MASlope(iTime);
if (float.IsNaN(f5MASlope) || f5MASlope > -0.0100f)
{
//Console.WriteLine("[{0}] [{1}] 트레일링 매도 대기. 5ma 상승 중 {2}원 ({3})", iTime, OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"));
continue;
}
int iProfit = iCurPrice - (int)OwnItem.m_iUnitBEP;
float fProfitRate = (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f);
Console.WriteLine("[{0}] [{1}] 트레일링 매도 {2}원 ({3}:{4}) (5MA slop:{5})", iTime, OwnItem.m_strCodeName, iCurPrice, iProfit, fProfitRate.ToString("0.00%"), f5MASlope.ToString("0.00%"));
ULUtil.TraceCSV(iTime, "[시뮬레이션] 트레일링 매도", OwnItem.m_strCodeName, iCurPrice, iProfit, fProfitRate.ToString("0.00%"), f5MASlope.ToString("0.00%"));
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, f5MASlope, false, iProfit, fProfitRate, false);
iTotalAskPrice += iCurPrice * OwnItem.m_iConclusionBalanceCnt;
OwnItem.m_iUnitBEP = 0;
OwnItem.m_iConclusionBalanceCnt = 0;
//m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
//m_OwnList.Remove(OwnItem);
//m_DataMgr.RemoveWatch(strCode);
}
//// steadiness
//else if (WatchItem.GetAvgDiff(iTime) < WatchItem.m_iPrevClosing*0.01)
//{
// //m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
// //m_OwnList.Remove(OwnItem);
// //m_DataMgr.RemoveWatch(strCode);
// Console.WriteLine("[{0}] [{1}] 보합 처리 {2}원 ({3}:{4}) {5}",
// iTime,
// OwnItem.m_strCodeName,
// WatchItem.m_iCurPrice,
// WatchItem.m_iCurPrice - OwnItem.m_iUnitBEP,
// (WatchItem.m_iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"),
// WatchItem.m_iHighestPrice);
// ULUtil.TraceCSV("[시뮬레이션]", "보합 처리", OwnItem.m_strCodeName, WatchItem.m_iCurPrice, WatchItem.m_iCurPrice - OwnItem.m_iUnitBEP, (WatchItem.m_iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), WatchItem.m_iHighestPrice);
// OwnItem.m_iUnitBEP = 0;
//}
}
}
if (OwnItem.m_iConclusionBalanceCnt > 0)
{
iTotalAskPrice += WatchItem.FinalPrice() * OwnItem.m_iConclusionBalanceCnt;
OwnItem.m_iUnitBEP = 0;
OwnItem.m_iConclusionBalanceCnt = 0;
}
Console.WriteLine("Profit : {0}/{1} ({2}:{3:0.00%})", iTotalBidPrice, iTotalAskPrice, iTotalAskPrice - iTotalBidPrice, iTotalAskPrice / (float)iTotalBidPrice - 1.0f);
Console.WriteLine("\n");
iTotalProfit += (iTotalAskPrice - iTotalBidPrice);
//WatchItem.PrintChart();
}
Console.WriteLine("total : {0}", iTotalProfit);
Console.WriteLine("시뮬레이션 끝");
}
private void btLogDump_Click(object sender, EventArgs e)
{
m_DataMgr.DumpLog(true);
}
private void button1_Click(object sender, EventArgs e)
{
m_DataMgr.DumpLog(false);
}
}
}

View File

@@ -14,9 +14,17 @@ namespace upper_limit_crawler
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Application.EnableVisualStyles(); try
Application.SetCompatibleTextRenderingDefault(false); {
Application.Run(new Form1()); Application.EnableVisualStyles();
} Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
} }
} }

190
ULBalanceDlg.Designer.cs generated Normal file
View File

@@ -0,0 +1,190 @@
namespace upper_limit_crawler
{
partial class ULBalanceDlg
{
/// <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.lvBalance = new System.Windows.Forms.ListView();
this.chCode = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chName = ((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.chCurPrice = ((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.chEvaluationPrice = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chHighPriceAfterBid = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chProfitRate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.btRefresh = new System.Windows.Forms.Button();
this.btSellAll = new System.Windows.Forms.Button();
this.btSell = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lvBalance
//
this.lvBalance.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.lvBalance.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chCode,
this.chName,
this.chUnitBuyPrice,
this.chUnitBEP,
this.chCurPrice,
this.chEvaluationProfit,
this.chBalance,
this.chEvaluationPrice,
this.chHighPriceAfterBid,
this.chProfitRate});
this.lvBalance.FullRowSelect = true;
this.lvBalance.GridLines = true;
this.lvBalance.Location = new System.Drawing.Point(12, 12);
this.lvBalance.MultiSelect = false;
this.lvBalance.Name = "lvBalance";
this.lvBalance.Size = new System.Drawing.Size(637, 362);
this.lvBalance.TabIndex = 0;
this.lvBalance.UseCompatibleStateImageBehavior = false;
this.lvBalance.View = System.Windows.Forms.View.Details;
this.lvBalance.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvBalance_ItemSelectionChanged);
//
// chCode
//
this.chCode.Text = "종목코드";
//
// chName
//
this.chName.Text = "종목명";
this.chName.Width = 100;
//
// chUnitBuyPrice
//
this.chUnitBuyPrice.Text = "장부가";
this.chUnitBuyPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chUnitBEP
//
this.chUnitBEP.Text = "손익단가";
this.chUnitBEP.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chCurPrice
//
this.chCurPrice.Text = "현재가";
this.chCurPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chEvaluationProfit
//
this.chEvaluationProfit.Text = "평가손익";
this.chEvaluationProfit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chBalance
//
this.chBalance.Text = "잔고수량";
this.chBalance.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chEvaluationPrice
//
this.chEvaluationPrice.Text = "평가금액";
this.chEvaluationPrice.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chHighPriceAfterBid
//
this.chHighPriceAfterBid.Text = "매수후 최고가";
//
// chProfitRate
//
this.chProfitRate.Text = "수익률";
this.chProfitRate.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.chProfitRate.Width = 80;
//
// btRefresh
//
this.btRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btRefresh.Location = new System.Drawing.Point(12, 380);
this.btRefresh.Name = "btRefresh";
this.btRefresh.Size = new System.Drawing.Size(75, 23);
this.btRefresh.TabIndex = 1;
this.btRefresh.Text = "갱신";
this.btRefresh.UseVisualStyleBackColor = true;
this.btRefresh.Click += new System.EventHandler(this.btRefresh_Click);
//
// btSellAll
//
this.btSellAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btSellAll.Location = new System.Drawing.Point(574, 380);
this.btSellAll.Name = "btSellAll";
this.btSellAll.Size = new System.Drawing.Size(75, 23);
this.btSellAll.TabIndex = 2;
this.btSellAll.Text = "모두 청산";
this.btSellAll.UseVisualStyleBackColor = true;
this.btSellAll.Click += new System.EventHandler(this.btSellAll_Click);
//
// btSell
//
this.btSell.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btSell.Location = new System.Drawing.Point(493, 380);
this.btSell.Name = "btSell";
this.btSell.Size = new System.Drawing.Size(75, 23);
this.btSell.TabIndex = 3;
this.btSell.Text = "매도";
this.btSell.UseVisualStyleBackColor = true;
this.btSell.Click += new System.EventHandler(this.btSell_Click);
//
// ULBalanceDlg
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(661, 415);
this.Controls.Add(this.btSell);
this.Controls.Add(this.btSellAll);
this.Controls.Add(this.btRefresh);
this.Controls.Add(this.lvBalance);
this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "ULBalanceDlg";
this.Text = "잔고 평가";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListView lvBalance;
private System.Windows.Forms.ColumnHeader chName;
private System.Windows.Forms.ColumnHeader chCurPrice;
private System.Windows.Forms.ColumnHeader chBalance;
private System.Windows.Forms.ColumnHeader chUnitBEP;
private System.Windows.Forms.ColumnHeader chEvaluationProfit;
private System.Windows.Forms.ColumnHeader chProfitRate;
private System.Windows.Forms.Button btRefresh;
private System.Windows.Forms.ColumnHeader chCode;
private System.Windows.Forms.ColumnHeader chUnitBuyPrice;
private System.Windows.Forms.ColumnHeader chEvaluationPrice;
private System.Windows.Forms.Button btSellAll;
private System.Windows.Forms.Button btSell;
private System.Windows.Forms.ColumnHeader chHighPriceAfterBid;
}
}

413
ULBalanceDlg.cs Normal file
View File

@@ -0,0 +1,413 @@
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 ULBalanceDlg : Form
{
const int BALANCE_DELAY = 10000;
public class OWN_ITEM
{
public string m_strCodeName;
public int m_iPayBalance;
public int m_iPayUnitPrice;
public int m_iConclusionBalanceCnt;
public long m_iEvaluationPrice;
public long m_iEvaluationProfit;
public double m_dProfitRate;
public string m_strCode;
public int m_iAskableCnt;
public double m_dConclusionUnitPrice;
public long m_iUnitBEP;
public int m_iBidTime;
public int m_iCurPrice;
public int m_iMaxPriceAfterBid;
public bool m_bCheck;
};
List<OWN_ITEM> m_OwnList = new List<OWN_ITEM>();
System.Windows.Forms.Timer m_MainTimer = new System.Windows.Forms.Timer();
int m_iLastTime = 0;
int m_iBalanceDelay = BALANCE_DELAY;
ULDataMgr m_DataMgr = null;
CPTRADELib.CpTd6033 m_Td6033 = null;
public ULBalanceDlg(ULDataMgr DataMgr)
{
InitializeComponent();
MainForm.SetDoubleBuffered(lvBalance);
this.TopLevel = false;
m_DataMgr = DataMgr;
MainForm.SetDoubleBuffered(lvBalance);
btSell.Enabled = false;
m_MainTimer.Interval=15;
m_MainTimer.Tick+=RefreshData;
}
public void Start()
{
m_Td6033 = new CPTRADELib.CpTd6033();
RefreshBalance();
m_MainTimer.Start();
}
public void Stop()
{
m_MainTimer.Stop();
}
private void RefreshBalance()
{
m_Td6033.SetInputValue(0, m_DataMgr.GetAccount());
m_Td6033.SetInputValue(2, 50);
ULUtil.BlockRequest(m_Td6033);
//object[] datalist = new object[]
//{
// m_Td6033.GetHeaderValue(0),
// m_Td6033.GetHeaderValue(1),
// m_Td6033.GetHeaderValue(2),
// m_Td6033.GetHeaderValue(3),
// m_Td6033.GetHeaderValue(4),
// m_Td6033.GetHeaderValue(5),
// m_Td6033.GetHeaderValue(6),
// m_Td6033.GetHeaderValue(7),
// m_Td6033.GetHeaderValue(8),
// m_Td6033.GetHeaderValue(9),
// m_Td6033.GetHeaderValue(10),
// m_Td6033.GetHeaderValue(11),
// m_Td6033.GetHeaderValue(12)
//};
m_DataMgr.SetCacheBalance(m_Td6033.GetHeaderValue(9));
m_DataMgr.SetEvalProfit(m_Td6033.GetHeaderValue(4));
lvBalance.Items.Clear();
//m_OwnList.Clear();
m_OwnList.All(c => { c.m_bCheck = false; return true; });
int iCnt = m_Td6033.GetHeaderValue(7);
for(int i = 0; i<iCnt; i++)
{
string strCode = m_Td6033.GetDataValue(12, i);
string strCodeName = m_Td6033.GetDataValue(0, i);
int iPayBalance = m_Td6033.GetDataValue(3, i); // 결제 잔고수량
int iPayUnitPrice = m_Td6033.GetDataValue(4, i); // 결제 장부단가
int iConclusionBalanceCnt = m_Td6033.GetDataValue(7, i);// 체결 잔고수량
long iEvaluationPrice = m_Td6033.GetDataValue(9, i); // 평가금액 : 보유수량x현재가
long iEvaluationProfit = m_Td6033.GetDataValue(10, i); // 평가손익
double dReturn = m_Td6033.GetDataValue(11, i); // 수익률
int iAskableCnt = m_Td6033.GetDataValue(15, i); // 매도 가능 수량
double dConclusionUnitPrice = m_Td6033.GetDataValue(17, i); // 체결 장부단가
long iUnitBEP = m_Td6033.GetDataValue(18, i); // 손익단가 : 수수료 포함 순익 분기점 Break-Even Point
int iCurPrice = 0;
OWN_ITEM OwnItem = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode);
if (OwnItem == null)
{
OwnItem = new OWN_ITEM();
m_OwnList.Add(OwnItem);
}
m_DataMgr.AddWatch(strCode, strCodeName);
OwnItem.m_strCodeName = strCodeName;
OwnItem.m_iPayBalance = iPayBalance;
OwnItem.m_iPayUnitPrice = iPayUnitPrice;
OwnItem.m_iConclusionBalanceCnt = iConclusionBalanceCnt;
OwnItem.m_iEvaluationPrice = iEvaluationPrice;
OwnItem.m_iEvaluationProfit = iEvaluationProfit;
OwnItem.m_dProfitRate = dReturn;
OwnItem.m_strCode = strCode;
OwnItem.m_iAskableCnt = iAskableCnt;
OwnItem.m_dConclusionUnitPrice = dConclusionUnitPrice;
OwnItem.m_iUnitBEP = iUnitBEP;
OwnItem.m_iCurPrice = iCurPrice;
OwnItem.m_iMaxPriceAfterBid = Math.Max(iCurPrice, OwnItem.m_iMaxPriceAfterBid);
OwnItem.m_iBidTime=m_DataMgr.GetBidTime(strCode);
OwnItem.m_bCheck = true;
ListViewItem listViewItem = new ListViewItem(new string[] { strCode, strCodeName, dConclusionUnitPrice.ToString("###,###,##0"),
iUnitBEP.ToString("###,###,##0"), iCurPrice.ToString("###,###,##0"),
iEvaluationProfit.ToString("###,###,##0"), iConclusionBalanceCnt.ToString("###,###,##0"),
iEvaluationPrice.ToString("###,###,##0"), iCurPrice.ToString("###,###,##0"), dReturn.ToString("#,##0.00")+"%" });
listViewItem.UseItemStyleForSubItems = false;
if(iEvaluationProfit > 0)
listViewItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Red;
else
listViewItem.SubItems[chEvaluationProfit.Index].ForeColor = Color.Blue;
if (dReturn > 0)
listViewItem.SubItems[chProfitRate.Index].ForeColor = Color.Red;
else if (dReturn < 0)
listViewItem.SubItems[chProfitRate.Index].ForeColor = Color.Blue;
lvBalance.Items.Add(listViewItem);
}
m_OwnList.RemoveAll(c => c.m_bCheck = false);
foreach (ColumnHeader col in lvBalance.Columns)
col.Width=-2;
}
private void RefreshCurPrice()
{
Dictionary<string, ULWatchItem> WatchList = m_DataMgr.GetWatchList();
foreach(KeyValuePair<string, ULWatchItem> WatchPair in WatchList)
{
string strCode = WatchPair.Key;
ULWatchItem WatchItem = WatchPair.Value;
OWN_ITEM OwnItem = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode);
if(OwnItem == null)
continue;
int iTime = WatchItem.m_iCurTime;
int iCurPrice = WatchItem.m_iCurPrice;
int iComp = iCurPrice - (int)OwnItem.m_iUnitBEP; // or OwnItem.m_dConclusionUnitPrice
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;
OwnItem.m_iMaxPriceAfterBid=WatchItem.GetHighestPriceAfter(OwnItem.m_iBidTime);
ListViewItem lvItem = lvBalance.FindItemWithText(strCode);
if(lvItem != null)
{
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%");
lvItem.SubItems[chHighPriceAfterBid.Index].Text = OwnItem.m_iMaxPriceAfterBid.ToString("###,###,##0");
if(OwnItem.m_dProfitRate > 0)
lvItem.SubItems[chProfitRate.Index].ForeColor = Color.Red;
else
lvItem.SubItems[chProfitRate.Index].ForeColor = Color.Blue;
}
if(ULUtil.IsTradingTime() == true && iCurPrice > 0)
{
// loss cut
if(iCurPrice <= OwnItem.m_iUnitBEP * (1.0f - m_DataMgr.m_Setting.m_fLossCut))
{
m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
m_OwnList.Remove(OwnItem);
m_DataMgr.RemoveWatch(strCode);
m_DataMgr.AddLosscutItem(strCode);
int iProfit = iCurPrice-(int)OwnItem.m_iUnitBEP;
float fProfitRate = iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f;
ULUtil.Trace("[{0}] 손절 {1}원 ({2}) {3}", OwnItem.m_strCodeName, iCurPrice, fProfitRate.ToString("0.00%"), WatchItem.m_iHighestPrice);
ULUtil.TraceCSV("손절", OwnItem.m_strCodeName, iCurPrice, fProfitRate.ToString("0.00%"), WatchItem.m_iHighestPrice);
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, float.NaN, true, iProfit, fProfitRate, true);
// own에서 삭제하고 미체결 리스트에 넣고, watch에서도 뺀다
// 미체결 잔량 취소
}
// trailing
else if(iCurPrice <= OwnItem.m_iMaxPriceAfterBid - OwnItem.m_iUnitBEP * m_DataMgr.m_Setting.m_fTrailing)
{
float f5MASlope = WatchItem.GetPrev5MASlope(iTime);
if(float.IsNaN(f5MASlope) || f5MASlope > -0.0100f)
{
ULUtil.Trace(string.Format("[{0}] [{1}] 트레일링 매도 대기. 5ma 상승 중 {2}원 ({3})", iTime, OwnItem.m_strCodeName, iCurPrice, (iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%")));
continue;
}
m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
m_OwnList.Remove(OwnItem);
m_DataMgr.RemoveWatch(strCode);
int iProfit = iCurPrice-(int)OwnItem.m_iUnitBEP;
float fProfitRate = iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f;
ULUtil.Trace("[{0}] 트레일링 매도 {1}원 ({2}:{3}) (5MA slop:{4}) {5}",
OwnItem.m_strCodeName,
iCurPrice,
iCurPrice - OwnItem.m_iUnitBEP,
(iCurPrice/(float)OwnItem.m_iUnitBEP-1.0f).ToString("0.00%"),
f5MASlope.ToString("0.00%"),
WatchItem.m_iHighestPrice);
ULUtil.TraceCSV("트레일링 매도", OwnItem.m_strCodeName, iCurPrice, iCurPrice - OwnItem.m_iUnitBEP, fProfitRate.ToString("0.00%"), f5MASlope.ToString("0.00%"), WatchItem.m_iHighestPrice);
m_DataMgr.AddAskLog(strCode, WatchItem.m_strCodeName, iTime, iCurPrice, f5MASlope, false, iProfit, fProfitRate, true);
}
// steadiness
else if(ULUtil.GetTimeDiff(OwnItem.m_iBidTime, iTime) > 3000)
{
m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
m_OwnList.Remove(OwnItem);
m_DataMgr.RemoveWatch(strCode);
ULUtil.Trace("[{0}] 보합 처리 {1}원 ({2}:{3}) {4}",
OwnItem.m_strCodeName,
WatchItem.m_iCurPrice,
WatchItem.m_iCurPrice - OwnItem.m_iUnitBEP,
(WatchItem.m_iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"),
WatchItem.m_iHighestPrice);
ULUtil.TraceCSV("보합 처리", OwnItem.m_strCodeName, WatchItem.m_iCurPrice, WatchItem.m_iCurPrice - OwnItem.m_iUnitBEP, (WatchItem.m_iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), WatchItem.m_iHighestPrice);
}
}
}
//foreach (ListViewItem lvItem in lvBalance.Items)
//{
// string strCode = lvItem.SubItems[chCode.Index].Text;
// int iTime = ULUtil.GetCurTimeInt();
// if (WatchList.ContainsKey(strCode) == true)
// {
// ULWatchItem WatchItem = WatchList[strCode];
// OWN_ITEM OwnItem = m_OwnList.Find(itemFind => itemFind.m_strCode == strCode);
// if (OwnItem == null)
// continue;
// int iDisplayCurPrice = 0;
// if (lvItem.SubItems[chCurPrice.Index].Text.Length > 0)
// iDisplayCurPrice = int.Parse(Regex.Replace(lvItem.SubItems[chCurPrice.Index].Text, @"\D", ""));
// if (WatchItem.m_iCurPrice != iDisplayCurPrice)
// {
// int iCurPrice = WatchItem.m_iCurPrice;
// int iComp = iCurPrice - (int)OwnItem.m_iUnitBEP; // or OwnItem.m_dConclusionUnitPrice
// 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%");
// lvItem.SubItems[chHighestPrice.Index].Text = WatchItem.m_iHighestPrice.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);
// }
// steadiness
//if (WatchItem.GetAvgDiff(iTime) < WatchItem.m_iPrevClosing*0.01)
//{
// m_DataMgr.GetTrader().SellCurPrice(OwnItem.m_strCode, OwnItem.m_iPayBalance);
// m_OwnList.Remove(OwnItem);
// m_DataMgr.RemoveWatch(strCode);
// ULUtil.Trace("[{0}] 보합 처리 {1}원 ({2}:{3}) {4}",
// OwnItem.m_strCodeName,
// WatchItem.m_iCurPrice,
// WatchItem.m_iCurPrice - OwnItem.m_iUnitBEP,
// (WatchItem.m_iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"),
// WatchItem.m_iHighestPrice);
// ULUtil.TraceCSV("보합 처리", OwnItem.m_strCodeName, WatchItem.m_iCurPrice, WatchItem.m_iCurPrice - OwnItem.m_iUnitBEP, (WatchItem.m_iCurPrice / (float)OwnItem.m_iUnitBEP - 1.0f).ToString("0.00%"), WatchItem.m_iHighestPrice);
//}
// }
//}
}
private void RefreshData(object sender, EventArgs e)
{
int iCurTime = Environment.TickCount;
if(m_iLastTime==0)
{
m_iLastTime=iCurTime;
return;
}
int iDeltaT = iCurTime-m_iLastTime;
m_iBalanceDelay-=iDeltaT;
if(m_DataMgr.GetTrader().HasConclusion() == true || m_iBalanceDelay<=0)
{
RefreshBalance();
m_iBalanceDelay=BALANCE_DELAY;
m_DataMgr.GetTrader().ResetConclusion();
}
RefreshCurPrice();
m_iLastTime=iCurTime;
}
private void btRefresh_Click(object sender, EventArgs e)
{
RefreshBalance();
}
private void btSell_Click(object sender, EventArgs e)
{
foreach(ListViewItem item in lvBalance.SelectedItems)
{
ULUtil.Trace("[{0}] 수동 매도", item.SubItems[chName.Index].Text);
ULUtil.TraceCSV(ULUtil.GetCurTimeInt(), "수동 매도", item.SubItems[chName.Index], item.SubItems[chCurPrice.Index], item.SubItems[chProfitRate.Index]);
string strCode = item.SubItems[chCode.Index].Text;
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);
m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt);
}
}
private void btSellAll_Click(object sender, EventArgs e)
{
foreach (ListViewItem item in lvBalance.Items)
{
ULUtil.Trace("[{0}] 모두 청산", item.SubItems[chName.Index].Text);
ULUtil.TraceCSV(ULUtil.GetCurTimeInt(), "모두 청산", item.SubItems[chName.Index], item.SubItems[chCurPrice.Index], item.SubItems[chProfitRate.Index]);
string strCode = item.SubItems[chCode.Index].Text;
int iCnt = int.Parse(item.SubItems[chBalance.Index].Text);
m_DataMgr.GetTrader().SellCurPrice(strCode, iCnt);
}
}
private void lvBalance_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
btSell.Enabled = (lvBalance.SelectedItems.Count > 0);
}
}
}

120
ULBalanceDlg.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>

34
ULDB.cs Normal file
View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace upper_limit_crawler
{
public class ULDB
{
const string DBNAME = "DB";
public ULDB()
{
}
public void Insert<T>(string strKey, T Value)
{
BinaryRage.DB.Insert(strKey, Value, DBNAME);
}
public T Get<T>(string strKey)
{
object data = BinaryRage.DB.Get<T>(strKey, DBNAME);
return (T)data;
}
public bool IsExist(string strKey)
{
return BinaryRage.DB.Exists(strKey, DBNAME);
}
}
}

337
ULDataMgr.cs Normal file
View File

@@ -0,0 +1,337 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
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_fBidMax;
public float m_fBidAmount;
public float m_fTimeout;
public float m_fTrailing;
public float m_fLossCut;
}
public struct POSTPONE_ITEM
{
public POSTPONE_ITEM(string strCode, int iTime)
{
m_strCode = strCode;
m_iTime = iTime;
}
public string m_strCode;
public int m_iTime;
}
[Serializable]
struct BID_LOG
{
public string m_strCode { get; set; }
public string m_strCodeName { get; set; }
public int m_iTime { get; set; }
public int m_iBidPrice { get; set; }
public float m_f5MAslope { get; set; }
}
[Serializable]
struct ASK_LOG
{
public string m_strCode { get; set; }
public string m_strCodeName { get; set; }
public int m_iTime { get; set; }
public int m_iAskPrice { get; set; }
public float m_f5MAslope { get; set; }
public bool m_bLosscut { get; set; }
public int m_iProfit { get; set; }
public float m_fProfitRate { get; set; }
}
public class ULDataMgr
{
public SETTING m_Setting = new SETTING();
public ULDB m_DB = new ULDB();
ULTrader m_Trader = new ULTrader();
Dictionary<string, ULWatchItem> m_WatchList = new Dictionary<string, ULWatchItem>();
List<POSTPONE_ITEM> m_PostponeList = new List<POSTPONE_ITEM>();
Dictionary<string, int> m_LossCutList = new Dictionary<string, int>();
List<string> m_BlackList = new List<string>();
string m_AvailableListKey;
List<string> m_AvailableList = new List<string>();
List<BID_LOG> m_BidLogs = new List<BID_LOG>();
List<ASK_LOG> m_AskLogs = new List<ASK_LOG>();
List<BID_LOG> m_BidLogsSimul = new List<BID_LOG>();
List<ASK_LOG> m_AskLogsSimul = new List<ASK_LOG>();
long m_iCacheBalance = 0;
long m_iEvalProfit = 0;
string m_strToday = ULUtil.GetCurTime().ToString("yyyy-MM-dd");
public ULDataMgr()
{
m_AvailableListKey= "available-"+m_strToday;
if(m_DB.IsExist(m_AvailableListKey) == true)
m_AvailableList = m_DB.Get<List<string>>(m_AvailableListKey);
else
m_AvailableList = new List<string>();
m_BidLogs = GetBidLog(m_strToday, true);
m_AskLogs = GetAskLog(m_strToday, true);
m_BidLogsSimul = GetBidLog(m_strToday, false);
m_AskLogsSimul = GetAskLog(m_strToday, false);
}
public void Init()
{
m_Trader.Init();
}
public string GetAccount()
{
return m_Trader.GetAccount();
}
public ULTrader GetTrader()
{
return m_Trader;
}
public void AddWatch(string strCode, string strCodeName)
{
if (m_WatchList.ContainsKey(strCode))
return;
ULWatchItem item = new ULWatchItem();
item.m_strCode = strCode;
item.m_strCodeName = strCodeName;
item.FillPrice();
item.m_StockCur = new DSCBO1Lib.StockCur();
item.m_StockCur.SetInputValue(0, strCode);
item.m_StockCur.Received += item.Received;
item.m_StockCur.SubscribeLatest();
m_WatchList.Add(strCode, item);
}
public void RemoveWatch(string strCode)
{
if (m_WatchList.ContainsKey(strCode))
return;
m_WatchList[strCode].m_StockCur.Unsubscribe();
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 StopAll()
{
foreach (KeyValuePair<string, ULWatchItem> item in m_WatchList)
{
item.Value.m_StockCur.Unsubscribe();
}
}
public void AddPostphoneItem(int iTime, string strCode)
{
POSTPONE_ITEM postpone = new POSTPONE_ITEM(strCode, iTime);
m_PostponeList.Add(postpone);
}
public bool IsInPostponeList(int iTime, string strCode)
{
return m_PostponeList.Any(r => r.m_strCode == strCode && ULUtil.IsInTime(r.m_iTime, iTime, 4));
}
public void AddLosscutItem(string strCode)
{
if(m_LossCutList.ContainsKey(strCode) == false)
{
m_LossCutList.Add(strCode, 1);
}
else
{
m_LossCutList[strCode] += 1;
if(m_LossCutList[strCode] >= 2)
m_BlackList.Add(strCode);
}
}
public bool IsInBlackList(string strCode)
{
return m_BlackList.Any(r => r == strCode);
}
public Dictionary<string, ULWatchItem> GetWatchList()
{
return m_WatchList;
}
public void SetCacheBalance(long iBalance)
{
m_iCacheBalance = iBalance;
}
public long GetCacheBalance()
{
return m_iCacheBalance;
}
public void SetEvalProfit(long iProfit)
{
m_iEvalProfit = iProfit;
}
public long GetEvalProfit()
{
return m_iEvalProfit;
}
public ULDB GetDB()
{
return m_DB;
}
public void AddAvailableItem(string strCode)
{
if(m_AvailableList.Any(r => r==strCode)==false)
{
m_AvailableList.Add(strCode);
m_DB.Insert(m_AvailableListKey, m_AvailableList);
}
}
public void AddBidLog(string strCode, string strCodeName, int iTime, int iBidPrice, float f5MAslope, bool bReal)
{
string strKey = bReal ? "bid-"+m_strToday : "bid-simul-"+m_strToday;
BID_LOG log = new BID_LOG();
log.m_strCode = strCode;
log.m_strCodeName = strCodeName;
log.m_iTime = iTime;
log.m_iBidPrice = iBidPrice;
log.m_f5MAslope = f5MAslope;
if(bReal == true)
{
m_BidLogs.Add(log);
m_DB.Insert(strKey, m_BidLogs);
}
else
{
m_BidLogsSimul.Add(log);
m_DB.Insert(strKey, m_BidLogsSimul);
}
}
List<BID_LOG> GetBidLog(string strDate, bool bReal)
{
string strKey = bReal ? "bid-"+m_strToday : "bid-simul-"+m_strToday;
if(m_DB.IsExist(strKey) == true)
return m_DB.Get<List<BID_LOG>>(strKey);
else
return new List<BID_LOG>();
}
public void AddAskLog(string strCode, string strCodeName, int iTime, int iAskPrice, float f5MAslope, bool bLosscut, int iProfit, float fProfitRate, bool bReal)
{
string strKey = bReal ? "ask-"+m_strToday : "ask-simul-"+m_strToday;
ASK_LOG log = new ASK_LOG();
log.m_strCode = strCode;
log.m_strCodeName = strCodeName;
log.m_iTime = iTime;
log.m_iAskPrice = iAskPrice;
log.m_f5MAslope = f5MAslope;
log.m_bLosscut = bLosscut;
log.m_iProfit = iProfit;
log.m_fProfitRate = fProfitRate;
if(bReal == true)
{
m_AskLogs.Add(log);
m_DB.Insert(strKey, m_AskLogs);
}
else
{
m_AskLogsSimul.Add(log);
m_DB.Insert(strKey, m_AskLogsSimul);
}
}
List<ASK_LOG> GetAskLog(string strDate, bool bReal)
{
string strKey = bReal ? "ask-"+m_strToday : "ask-simul-"+m_strToday;
if(m_DB.IsExist(strKey) == true)
return m_DB.Get<List<ASK_LOG>>(strKey);
else
return new List<ASK_LOG>();
}
public int GetBidTime(string strCode)
{
int iTime = 0;
List<BID_LOG> BidLog = m_BidLogs.Where(r => r.m_strCode==strCode).ToList();
BidLog.Reverse();
foreach(BID_LOG bid in BidLog)
{
if(m_AskLogs.Any(r => r.m_strCode==strCode && r.m_iTime>bid.m_iTime)==false)
iTime=bid.m_iTime;
else
break;
}
return iTime;
}
public void DumpLog(bool bReal)
{
StringBuilder sb = new StringBuilder();
foreach(string strCode in m_AvailableList)
sb.AppendLine("\"" +strCode+ "\",");
if(bReal == true)
{
foreach(BID_LOG log in m_BidLogs)
sb.AppendFormat("매수, {0}, {1}, {2}, {3}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iBidPrice, log.m_f5MAslope.ToString("0.00%"));
foreach(ASK_LOG log in m_AskLogs)
sb.AppendFormat("매도, {0}, {1}, {2}, {3}, {4}, {5}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iAskPrice, log.m_f5MAslope.ToString("0.00%"), log.m_iProfit, log.m_fProfitRate.ToString("0.00%"));
System.IO.File.WriteAllText(ULUtil.GetLogDir()+"dblog-"+m_strToday+".csv", sb.ToString(), Encoding.UTF8);
}
else
{
foreach(BID_LOG log in m_BidLogsSimul)
sb.AppendFormat("매수, {0}, {1}, {2}, {3}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iBidPrice, log.m_f5MAslope.ToString("0.00%"));
foreach(ASK_LOG log in m_AskLogsSimul)
sb.AppendFormat("매도, {0}, {1}, {2}, {3}, {4}, {5}"+Environment.NewLine, log.m_iTime, log.m_strCodeName, log.m_iAskPrice, log.m_f5MAslope.ToString("0.00%"), log.m_iProfit, log.m_fProfitRate.ToString("0.00%"));
System.IO.File.WriteAllText(ULUtil.GetLogDir()+"dblog-simul-"+m_strToday+".csv", sb.ToString(), Encoding.UTF8);
}
}
}
}

143
ULMonitorDlg.Designer.cs generated Normal file
View File

@@ -0,0 +1,143 @@
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.chPrevClosing = ((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.chPrevClosing});
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;
//
// chPrevClosing
//
this.chPrevClosing.Text = "전일종가";
//
// 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;
private System.Windows.Forms.ColumnHeader chPrevClosing;
}
}

222
ULMonitorDlg.cs Normal file
View File

@@ -0,0 +1,222 @@
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 = 15000;
ULDataMgr m_DataMgr;
CPSYSDIBLib.CpSvrNew7043 m_7043 = null;
System.Windows.Forms.Timer m_Timer = new System.Windows.Forms.Timer();
int m_iMonitorDelay = 0;
int m_iLastTime = 0;
bool m_bRequesting = false;
public ULMonitorDlg(ULDataMgr DataMgr)
{
InitializeComponent();
MainForm.SetDoubleBuffered(lvWatch);
this.TopLevel = false;
m_DataMgr = DataMgr;
m_Timer.Interval = 100;
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));
RefreshMonitorItem();
m_Timer.Start();
}
public void Stop()
{
m_Timer.Stop();
}
bool RefreshMonitorItem()
{
if (m_bRequesting == true)
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 = ULUtil.BlockRequest(m_7043);
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("###,###,###,###");
searchItem.SubItems[chPrevClosing.Index].Text = (iCurPrice - iComp).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(), (iCurPrice - iComp).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);
}
}
bContinue = (m_7043.Continue == 1);
if (bContinue == true)
iResult = ULUtil.BlockRequest(m_7043);
}
//foreach (ColumnHeader col in lvWatch.Columns)
// col.Width = -2;
m_bRequesting = false;
return true;
}
void RefreshData()
{
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)
{
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", ""));
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.AddAvailableItem(strCode);
int iTime = ULUtil.GetCurTimeInt();
if (m_DataMgr.IsInPostponeList(iTime, strCode) == true)
{
//ULUtil.Trace("[{0}] 조건 매수 실패. black list {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"));
continue;
}
else if(m_DataMgr.IsInBlackList(strCode) == true)
{
continue;
}
float f5MASlope = item.GetPrev5MASlope(item.m_iCurTime);
if(f5MASlope < 0.002f)
{
//ULUtil.Trace("[{0}] 조건 매수 실패. 5ma 상승하지 않음 {1}원 ({2})", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"));
continue;
}
// bid and add to black list
m_DataMgr.GetTrader().Buy(strCode, item.m_iCurPrice, (int)m_DataMgr.m_Setting.m_fBidAmount);
m_DataMgr.AddBidLog(strCode, item.m_strCodeName, iTime, item.m_iCurPrice, f5MASlope, true);
m_DataMgr.AddPostphoneItem(iTime, strCode);
ULUtil.Trace("[{0}] 조건 매수 {1}원 ({2}) (5MA slop:{3})",
item.m_strCodeName,
item.m_iCurPrice,
fCompRate.ToString("0.00%"),
f5MASlope.ToString("0.00%"));
ULUtil.TraceCSV("조건 매수", item.m_strCodeName, item.m_iCurPrice, fCompRate.ToString("0.00%"), f5MASlope.ToString("0.00%"));
}
}
}
}
}
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 = RefreshMonitorItem();
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>

24
ULObj.cs Normal file
View 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
View 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);
}
}
}

192
ULTrader.cs Normal file
View File

@@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace upper_limit_crawler
{
public class ULTrader
{
CPFORETRADELib.CpForeTdUtil m_Util = null;
DSCBO1Lib.CpConclusion m_Conclusion = null;
string[] m_astrAccounts = null;
object lockBuy = new object();
object lockSell = new object();
bool m_bHasConclusion = false;
public ULTrader()
{
}
public void Init()
{
m_Util = new CPFORETRADELib.CpForeTdUtil();
m_Conclusion = new DSCBO1Lib.CpConclusion();
m_Util.TradeInit();
m_astrAccounts = m_Util.AccountNumber;
StartConclusion();
}
public string GetAccount()
{
return m_astrAccounts[0];
}
void StartConclusion()
{
m_Conclusion.Received += Conclusion_Received;
m_Conclusion.Subscribe();
}
private void Conclusion_Received()
{
string strAccount = m_Conclusion.GetHeaderValue(1);
string strCodeName = m_Conclusion.GetHeaderValue(2);
long iCount = m_Conclusion.GetHeaderValue(3);
long iPrice = m_Conclusion.GetHeaderValue(4);
long iTradeNo = m_Conclusion.GetHeaderValue(5);
long iTradeNoOrg = m_Conclusion.GetHeaderValue(6);
string strCode = m_Conclusion.GetHeaderValue(9);
bool bBuy = (m_Conclusion.GetHeaderValue(12) == "2");
string strResult = m_Conclusion.GetHeaderValue(14);
string strTradeType = m_Conclusion.GetHeaderValue(16);
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") // 체결
{ strLog += "체결"; }
else if (strResult == "2") // 확인
{ strLog += "확인"; }
else if (strResult == "3") // 거부
{ strLog += "거부"; }
else if (strResult == "4") // 접수
{ strLog += "접수"; }
ULUtil.Trace(strLog);
if (strResult == "1")
m_bHasConclusion = true;
}
public bool HasConclusion()
{
return m_bHasConclusion;
}
public void ResetConclusion()
{
m_bHasConclusion = false;
}
//0 - (string)주문종류코드 주문구분
// 1 매도
// 2 매수
//1 - (string)계좌번호
//2 - (string)상품관리구분코드 계좌구분
//3 - (string)종목코드
//4 - (long)주문수량
//5 - (long)주문단가
//6 - (string)매매구분
//7 - (string)주문조건구분코드 매매조건
//0 없음
//1 IOC
//2 FOK
//8 - (string)주문호가구분코드
// 1 보통[default]
// 2 임의
// 3 시장가
// 5 조건부지정가
// 6 희망대량
// 9 자사주
// 12 최유리지정가
// 13 최우선지정가
// 10 스톡옵션자사주
// 23 임의시장가
// 25 임의조건부지정가
// 51 장중대량
// 52 장중바스켓
// 61 개시전종가
// 62 개시전종가대량
// 63 개시전시간외바스켓
// 67 개시전금전신탁자사주
// 69 개시전대량자기
// 71 신고대량(전장시가)
// 72 시간외대량
// 73 신고대량(종가)
// 77 금전신탁종가대량
// 11 금전신탁자사주
// 80 시간외바스켓
// 79 시간외대량자기
public void Buy(string strCode, int iUnitPrice, int iBidAmount)
{
int iCnt = iBidAmount / iUnitPrice;
CPTRADELib.CpTd0311 Td0311Bid = new CPTRADELib.CpTd0311();
Td0311Bid.SetInputValue(0, "2");
Td0311Bid.SetInputValue(1, m_astrAccounts[0]);
Td0311Bid.SetInputValue(3, strCode);
Td0311Bid.SetInputValue(4, iCnt); // 수량
Td0311Bid.SetInputValue(5, 0); // 단가
Td0311Bid.SetInputValue(7, "0");
Td0311Bid.SetInputValue(8, "03");
ULUtil.BlockRequest(Td0311Bid);
}
public void Sell(string strCode, int iUnitPrice, int iCnt)
{
while (ULUtil.GetLimitRemainCountRQ() <= 0) ;
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
Td0311Ask.SetInputValue(0, "1");
Td0311Ask.SetInputValue(1, m_astrAccounts[0]);
Td0311Ask.SetInputValue(3, strCode);
Td0311Ask.SetInputValue(4, iCnt); // 수량
Td0311Ask.SetInputValue(5, iUnitPrice); // 단가
Td0311Ask.SetInputValue(7, "0");
Td0311Ask.SetInputValue(8, "03");
ULUtil.BlockRequest(Td0311Ask);
}
public void SellCurPrice(string strCode, int iCnt)
{
CPTRADELib.CpTd0311 Td0311Ask = new CPTRADELib.CpTd0311();
Td0311Ask.SetInputValue(0, "1");
Td0311Ask.SetInputValue(1, m_astrAccounts[0]);
Td0311Ask.SetInputValue(3, strCode);
Td0311Ask.SetInputValue(4, iCnt); // 수량
Td0311Ask.SetInputValue(5, 0); // 단가
Td0311Ask.SetInputValue(7, "0");
Td0311Ask.SetInputValue(8, "03");
ULUtil.BlockRequest(Td0311Ask);
}
}
}

377
ULWatchItem.cs Normal file
View File

@@ -0,0 +1,377 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace upper_limit_crawler
{
public class ULWatchItem
{
public class PriceNode
{
public PriceNode(int iTime, int iPrice)
{
m_iTime = iTime;
m_iPrice = 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 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 int m_iTime;
public float m_fMA;
override public string ToString() { return string.Format("Time : {0}, m_fMA : {1}", m_iTime, m_fMA); }
}
public string m_strCode;
public string m_strCodeName;
public DSCBO1Lib.StockCur m_StockCur = null;
public int m_iCurTime;
public int m_iCurPrice;
public int m_iPrevClosing;
public int m_iStartPrice;
public int m_iHighestPrice;
public int m_iVolume;
public int m_iBidPrice;
public int m_iBidCnt;
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>();
public void InsertPriceNode(int iTime, int iPrice)
{
PriceNode node = new PriceNode(iTime, iPrice);
m_PriceList.Add(node);
bool bMakeNew = Insert1MinChart(iTime, iPrice);
if(bMakeNew == true)
{
int i5MAIdx = m_1MinChart.IndexOfKey(iTime) - 1;
if (i5MAIdx >= 0)
{
int i5MATime = m_1MinChart.Keys[i5MAIdx];
Insert5MAChart(i5MATime);
}
}
}
public void Received()
{
int iTime = (int)m_StockCur.GetHeaderValue(18);
int iTime2 = m_StockCur.GetHeaderValue(3);
m_iCurTime = iTime;
m_iCurPrice = m_StockCur.GetHeaderValue(13);
m_iPrevClosing = m_iCurPrice - m_StockCur.GetHeaderValue(2);
m_iStartPrice = m_StockCur.GetHeaderValue(4);
m_iHighestPrice = Math.Max(m_iHighestPrice, m_iCurPrice);
m_iVolume = m_StockCur.GetHeaderValue(9);
m_iBidPrice = m_StockCur.GetHeaderValue(8);
m_iBidCnt = 0;
InsertPriceNode(iTime, m_iCurPrice);
}
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, 6, 37 });
stockChart.SetInputValue(6, 'm');
stockChart.BlockRequest2(1);
int iCnt = (int)stockChart.GetHeaderValue(3);
int iFieldCnt = stockChart.GetHeaderValue(1);
string[] astrFieldName = stockChart.GetHeaderValue(2);
m_iPrevClosing = (int)stockChart.GetHeaderValue(6);
m_iCurPrice = m_iPrevClosing;
for (int i = iCnt - 1; i >= 0; i--)
{
int iPrice = (int)stockChart.GetDataValue(5, i);
int iTime = (int)stockChart.GetDataValue(1, i);
iTime *= 100;
m_iCurPrice = iPrice;
m_iCurTime = iTime;
InsertPriceNode(iTime, iPrice);
}
}
int GetHour(int iTime)
{
return iTime / 10000;
}
int GetMinute(int iTime)
{
return (iTime / 100) % 100;
}
int GetSecond(int iTime)
{
return iTime % 100;
}
int GetTimeKey1Min(int iHour, int iMin, int iSecond)
{
return iHour*10000 + iMin*100;
}
bool Insert1MinChart(int iTime, int iPrice)
{
int iHour = GetHour(iTime);
int iMin = GetMinute(iTime);
int iSec = GetSecond(iTime);
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
bool bMadeNew = false;
if (m_1MinChart.ContainsKey(iKey) == false)
{
CandleTick tick1 = new CandleTick(iTime, iPrice);
m_1MinChart.Add(iKey, tick1);
bMadeNew = true;
}
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);
bMadeNew = false;
}
return bMadeNew;
}
public void MakeChart()
{
foreach (PriceNode node in m_PriceList)
{
int iTime = node.m_iTime;
int iPrice = node.m_iPrice;
int iHour = GetHour(iTime);
int iMin = GetMinute(iTime);
int iSec = GetSecond(iTime);
int iKey = GetTimeKey1Min(iHour, iMin, iSec);
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);
}
}
}
public int FinalPrice()
{
return m_PriceList.Last().m_iPrice;
}
bool IsInTimeIdx(int iTime1, int iTime2, int iCnt)
{
int iIdx1 = m_1MinChart.IndexOfKey(iTime1);
int iIdx2 = m_1MinChart.IndexOfKey(iTime2);
return (iIdx1 < iIdx2 && iIdx1 > iIdx2 - iCnt);
}
void Insert5MAChart(int iTime)
{
int iHour = GetHour(iTime);
int iMin = GetMinute(iTime);
int iSec = GetSecond(iTime);
int iInsertKey = GetTimeKey1Min(iHour, iMin, iSec);
MATick tick = null;
if (m_5MAChart.ContainsKey(iInsertKey) == false)
tick = new MATick(iTime, 0);
else
tick = m_5MAChart[iInsertKey];
float fMA = 0;
int iIdx = m_1MinChart.IndexOfKey(iInsertKey);
if (iIdx >= 4)
{
int iCnt = 0;
for (int i = 0; i < 5 && iIdx >= 0; i++)
{
fMA += (float)m_1MinChart.Values[iIdx-i].m_iEnd;
iCnt++;
}
fMA /= iCnt;
}
else
{
fMA = float.NaN;
}
tick.m_fMA = fMA;
if(m_5MAChart.ContainsKey(iInsertKey) == true)
m_5MAChart[iInsertKey] = tick;
else
m_5MAChart.Add(iInsertKey, tick);
}
public void MakeMAChart()
{
foreach (KeyValuePair<int, CandleTick> node in m_1MinChart)
{
int iTime = node.Key;
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 iIdx = m_1MinChart.IndexOfKey(iKey);
IEnumerable<KeyValuePair<int, CandleTick>> Search = m_1MinChart.Where(r => ULUtil.IsInTime(iKey, r.Key, 5));
float fMA = Search.Count() == 5 ? (float)Search.Average(r => r.Value.m_iEnd) : 0;
tick.m_fMA = fMA;
m_5MAChart.Add(iKey, tick);
}
}
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:######} : Price : {1:###,###,###} (5MA : {2:###,##0.###})\n", iKey, node1Min.m_iEnd, node5MA != null ? node5MA.m_fMA : 0);
}
sb.AppendLine("======= END =======");
Console.WriteLine(sb.ToString());
}
public float GetPrev5MASlope(int iTime)
{
int iTimeKey = GetTimeKey1Min(GetHour(iTime), GetMinute(iTime), 0);
int iLastIdx = m_1MinChart.IndexOfKey(iTimeKey)-1;
if(iLastIdx <= 1 || iLastIdx >= m_5MAChart.Count)
return float.NaN;
MATick LastMA = m_5MAChart.Values[iLastIdx];
MATick PrevMA = m_5MAChart.Values[iLastIdx-1];
return (LastMA.m_fMA - PrevMA.m_fMA) / m_iPrevClosing;
}
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("[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("[Is5MAGoingUp][{0}] cur up ({1}, {2}", m_strCodeName, lastTick.m_iEnd, prevTick.m_iEnd);
return true;
}
}
}
}
return false;
}
public float GetAvgDiff(int iTime)
{
IEnumerable<KeyValuePair<int, CandleTick>> itor = m_1MinChart.Where(r => ULUtil.IsInTime(r.Key, iTime, 30));
if (itor.Count() < 30)
return 100000;
float fSum = itor.Sum(r => r.Value.m_iHighest-r.Value.m_iLowest);
return fSum / (itor.Count());
}
public int GetHighestPriceAfter(int iTime)
{
List<PriceNode> AfterList = m_PriceList.Where(r => r.m_iTime > iTime).ToList();
if(AfterList.Count() > 0)
return AfterList.Max(r => r.m_iPrice);
else
return 0;
}
}
}

321
UlUtil.cs Normal file
View File

@@ -0,0 +1,321 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace upper_limit_crawler
{
public static class ULUtil
{
//static string m_strLogServer = "http://mjjo53.us.to:8000";
static CPUTILLib.CpCybos m_CPUtil = null;
static CPUTILLib.CpCodeMgr m_CPCodeMgr = null;
static TextBox m_tbLog = null;
static string m_strLogDir;
static string m_strLogFileName;
static string m_strCSVFileName;
static TimeSpan m_TimeDiff = TimeSpan.Zero;
static int m_iTradingStartTime;
static int m_iTradingEndTime;
public static void Init(TextBox tbLog)
{
m_CPUtil = new CPUTILLib.CpCybos();
m_CPCodeMgr = new CPUTILLib.CpCodeMgr();
m_tbLog = tbLog;
if (Debugger.IsAttached == true)
m_strLogDir = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\";
m_strLogDir += "log\\";
if (Directory.Exists(m_strLogDir) == false)
Directory.CreateDirectory(m_strLogDir);
m_strLogFileName = m_strLogDir + "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".txt";
m_strCSVFileName = m_strLogDir + "log-" + GetCurTime().ToString("yyyy-MM-dd") + ".csv";
m_iTradingStartTime = (int)m_CPCodeMgr.GetMarketStartTime();
m_iTradingStartTime *= 100;
m_iTradingEndTime = (int)m_CPCodeMgr.GetMarketEndTime();
m_iTradingEndTime *= 100;
}
public static void SyncServerTime()
{
DateTime time = GetFastestNISTDate();
m_TimeDiff = time - DateTime.Now;
}
public static DateTime GetCurTime()
{
return DateTime.Now + m_TimeDiff;
}
public static void GetServerTime()
{
try
{
string strURL = string.Format("http://www.timeapi.org/utc/now?format={0}", (@"\Y-\m-\d \H:\M:\S"));
Uri uri = new Uri(strURL);
WebRequest wReq = (HttpWebRequest)WebRequest.Create(uri); // WebRequest 객체 형성 및 HttpWebRequest 로 형변환
wReq.Method = "GET"; // 전송 방법 "GET" or "POST"
using (HttpWebResponse wRes = (HttpWebResponse)wReq.GetResponse())
{
Stream respPostStream = wRes.GetResponseStream();
StreamReader readerPost = new StreamReader(respPostStream, Encoding.GetEncoding("EUC-KR"), true);
string resResult = readerPost.ReadToEnd();
}
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
{
var resp = (HttpWebResponse)ex.Response;
Trace("인터넷 시간 동기화 실패 ({0})", resp.StatusCode);
}
}
}
public static DateTime GetFastestNISTDate()
{
var result = DateTime.MinValue;
// Initialize the list of NIST time servers
// http://tf.nist.gov/tf-cgi/servers.cgi
string[] servers = new string[] {
"time-c.nist.gov",
"nist1-macon.macon.ga.us",
"time.nist.gov",
"time-nw.nist.gov",
"nist-time-server.eoni.com"
};
// Try 5 servers in random order to spread the load
Random rnd = new Random();
foreach (string server in servers.OrderBy(s => rnd.NextDouble()).Take(5))
{
try
{
ULUtil.Trace("TimeSync trying [server:{0}]", server);
// Connect to the server (at port 13) and get the response
string serverResponse = string.Empty;
using (var reader = new StreamReader(new System.Net.Sockets.TcpClient(server, 13).GetStream()))
{
serverResponse = reader.ReadToEnd();
}
// If a response was received
if (!string.IsNullOrEmpty(serverResponse))
{
// Split the response string ("55596 11-02-14 13:54:11 00 0 0 478.1 UTC(NIST) *")
string[] tokens = serverResponse.Split(' ');
// Check the number of tokens
if (tokens.Length >= 6)
{
// Check the health status
string health = tokens[5];
if (health == "0")
{
// Get date and time parts from the server response
string[] dateParts = tokens[1].Split('-');
string[] timeParts = tokens[2].Split(':');
// Create a DateTime instance
DateTime utcDateTime = new DateTime(
Convert.ToInt32(dateParts[0]) + 2000,
Convert.ToInt32(dateParts[1]), Convert.ToInt32(dateParts[2]),
Convert.ToInt32(timeParts[0]), Convert.ToInt32(timeParts[1]),
Convert.ToInt32(timeParts[2]));
// Convert received (UTC) DateTime value to the local timezone
result = utcDateTime.ToLocalTime();
return result;
// Response successfully received; exit the loop
}
}
}
}
catch
{
// Ignore exception and try the next server
}
}
return result;
}
public static string GetCurTimeString()
{
return GetCurTime().ToString("yyyy-MM-dd HH:mm:ss");
}
public static int GetCurTimeInt()
{
return int.Parse(GetCurTime().ToString("HHmmss"));
}
public static int GetTimeDiff(int iTime1, int iTime2)
{
TimeSpan Diff = DateTime.Parse(iTime2.ToString()) - DateTime.Parse(iTime1.ToString());
return int.Parse(Diff.ToString("HHmmss"));
}
public static void WebLog(string strURL, string strMsg)
{
try
{
// 요청 String -> 요청 Byte 변환
byte[] byteDataParams = UTF8Encoding.UTF8.GetBytes(strMsg);
// HttpWebRequest 객체 생성, 설정
Uri reqURI = new Uri(strURL);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(reqURI);
request.Method = "POST"; // 기본값 "GET"
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteDataParams.Length;
// 요청 Byte -> 요청 Stream 변환
Stream stDataParams = request.GetRequestStream();
stDataParams.Write(byteDataParams, 0, byteDataParams.Length);
stDataParams.Close();
// 요청, 응답 받기
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// 응답 Stream 읽기
Stream stReadData = response.GetResponseStream();
StreamReader srReadData = new StreamReader(stReadData, Encoding.Default);
// 응답 Stream -> 응답 String 변환
string strResult = srReadData.ReadToEnd();
Console.WriteLine(strResult);
}
catch(Exception ex)
{
ex.ToString();
}
}
public static string GetLogDir()
{
return m_strLogDir;
}
public static void Trace(string strMsg)
{
string strLog = "["+GetCurTimeString()+"] "+strMsg;
System.IO.File.AppendAllText(m_strLogFileName, strLog + Environment.NewLine);
Console.WriteLine(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);
}
public static void Trace(string strFormat, params object[] args)
{
Trace(string.Format(strFormat, args));
}
public static void TraceCSV(params object[] args)
{
string strLog = GetCurTimeString();
foreach (object arg in args)
strLog += ", " + arg;
System.IO.File.AppendAllText(m_strCSVFileName, strLog + Environment.NewLine, Encoding.UTF8);
}
public static int GetLimitRemainCountTrace()
{
return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_TRADE_REQUEST);
}
public static int GetLimitRemainCountRQ()
{
return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_NONTRADE_REQUEST);
}
public static int GetLimitRemainCountSB()
{
return m_CPUtil.GetLimitRemainCount(CPUTILLib.LIMIT_TYPE.LT_SUBSCRIBE);
}
public static bool IsConnected()
{
return (m_CPUtil.IsConnect==1);
}
public static string GetCodeName(string strCode)
{
return m_CPCodeMgr.CodeToName(strCode);
}
public static void Reset()
{
m_CPUtil = null;
System.GC.Collect(0, GCCollectionMode.Forced);
System.GC.WaitForFullGCComplete();
m_CPUtil = new CPUTILLib.CpCybos();
}
public static bool IsInTime(int iTime1, int iTime2, int iMinDiff)
{
int iHour1 = iTime1 / 10000;
int iMin1 = (iTime1 / 100) % 100;
int iSec1 = iTime1 % 100;
int iHour2 = iTime2 / 10000;
int iMin2 = (iTime2 / 100) % 100;
int iSec2 = iTime2 % 100;
int iTotalSec1 = iHour1 * 60 * 60 + iMin1 * 60 + iSec1;
int iTotalSec2 = iHour2 * 60 * 60 + iMin2 * 60 + iSec2;
return (iTotalSec2 >= iTotalSec1 && iTotalSec2 - iTotalSec1 <= iMinDiff * 60);
}
public static short BlockRequest(CPTRADELib.ICpTdDib obj)
{
while(GetLimitRemainCountRQ() < 1)
Thread.Sleep(500);
return obj.BlockRequest2(1);
}
public static short BlockRequest(CPSYSDIBLib.ISysDib obj)
{
while(GetLimitRemainCountRQ() < 1)
Thread.Sleep(500);
return obj.BlockRequest2(1);
}
public static bool IsTradingTime()
{
int iCurTime = GetCurTimeInt();
return (iCurTime >= m_iTradingStartTime && iCurTime <= m_iTradingEndTime);
}
}
}

5
packages.config Normal file
View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BinaryRage" version="1.4.0.0" targetFramework="net45" />
<package id="LevelDB.Net" version="1.2.1" targetFramework="net45" />
</packages>

Binary file not shown.

Binary file not shown.

Binary file not shown.

19
sql/create.sql Normal file
View File

@@ -0,0 +1,19 @@
DROP TABLE trace;
CREATE TABLE trace
(
seq INT AUTO_INCREMENT,
CODE VARCHAR(12),
NAME VARCHAR(40),
TIME DATETIME,
startprice INT,
curprice INT,
rateperstart FLOAT,
askprice INT,
askcount INT,
bidprice INT,
bidcount INT,
tradingvolume INT,
PRIMARY KEY(seq)
)

View File

@@ -12,25 +12,6 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SignManifests>false</SignManifests> <SignManifests>false</SignManifests>
</PropertyGroup> </PropertyGroup>
@@ -43,7 +24,31 @@
<PropertyGroup> <PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest> <ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="BinaryRage, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\BinaryRage.1.4.0.0\lib\net40\BinaryRage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@@ -56,16 +61,38 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Form1.cs"> <Compile Include="ULDB.cs" />
<Compile Include="ULWatchItem.cs" />
<Compile Include="ULBalanceDlg.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Form1.Designer.cs"> <Compile Include="ULBalanceDlg.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>ULBalanceDlg.cs</DependentUpon>
</Compile>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<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="ULDataMgr.cs" />
<DependentUpon>Form1.cs</DependentUpon> <Compile Include="ULMonitorDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ULMonitorDlg.Designer.cs">
<DependentUpon>ULMonitorDlg.cs</DependentUpon>
</Compile>
<Compile Include="ULObj.cs" />
<Compile Include="ULOwn.cs" />
<Compile Include="ULTrader.cs" />
<Compile Include="ULUtil.cs" />
<EmbeddedResource Include="ULBalanceDlg.resx">
<DependentUpon>ULBalanceDlg.cs</DependentUpon>
</EmbeddedResource>
<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>
@@ -76,6 +103,10 @@
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<EmbeddedResource Include="ULMonitorDlg.resx">
<DependentUpon>ULMonitorDlg.cs</DependentUpon>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\app.manifest"> <None Include="Properties\app.manifest">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</None> </None>
@@ -95,6 +126,33 @@
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<COMReference Include="CPFOREDIBLIB">
<Guid>{ABA39D6F-5AF4-4D10-8389-031055C13A75}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="CPFORETRADELib">
<Guid>{1E3BC2CB-4AC7-46BB-AF63-11DEA8628E3C}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="CpIndexesLib">
<Guid>{3DC4496B-C823-4440-ABD4-A248A716F7C6}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="CPSYSDIBLib"> <COMReference Include="CPSYSDIBLib">
<Guid>{9C31B76A-7189-49A3-9781-3C6DD6ED5AD3}</Guid> <Guid>{9C31B76A-7189-49A3-9781-3C6DD6ED5AD3}</Guid>
<VersionMajor>1</VersionMajor> <VersionMajor>1</VersionMajor>
@@ -104,6 +162,15 @@
<Isolated>False</Isolated> <Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes> <EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference> </COMReference>
<COMReference Include="CPTRADELib">
<Guid>{1F7D5E5A-05AB-4236-B6F3-3D383B09203A}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="CPUTILLib"> <COMReference Include="CPUTILLib">
<Guid>{2DA9C35C-FE59-4A32-A942-325EE8A6F659}</Guid> <Guid>{2DA9C35C-FE59-4A32-A942-325EE8A6F659}</Guid>
<VersionMajor>1</VersionMajor> <VersionMajor>1</VersionMajor>
@@ -113,6 +180,15 @@
<Isolated>False</Isolated> <Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes> <EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference> </COMReference>
<COMReference Include="DSCBO1Lib">
<Guid>{859343F1-08FD-11D4-8231-00105A7C4F8C}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013 # Visual Studio 14
VisualStudioVersion = 12.0.30723.0 VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "upper-limit-crawler", "upper-limit-crawler.csproj", "{591FA710-356A-498A-8133-7E9E60AB4E40}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "upper-limit-crawler", "upper-limit-crawler.csproj", "{591FA710-356A-498A-8133-7E9E60AB4E40}"
EndProject EndProject