테스트 폼 구현 중

This commit is contained in:
jwlee
2023-05-15 13:03:33 +09:00
parent b01f9d2a7f
commit 1fb5d2aeb4
5 changed files with 199 additions and 32 deletions

View File

@@ -76,6 +76,7 @@ namespace Million.HunterSubForm
this.simpleButton_resetData = new DevExpress.XtraEditors.SimpleButton();
this.simpleButton_LoadAnalysisResultData = new DevExpress.XtraEditors.SimpleButton();
this.simpleButton_SavaAnalysisData = new DevExpress.XtraEditors.SimpleButton();
this.treeListColumn_PurchasedCount = new DevExpress.XtraTreeList.Columns.TreeListColumn();
((System.ComponentModel.ISupportInitialize)(this.panelControl_IndicatorCondition)).BeginInit();
this.panelControl_IndicatorCondition.SuspendLayout();
this.groupBox_.SuspendLayout();
@@ -388,17 +389,18 @@ namespace Million.HunterSubForm
this.treeListColumn_SellValue,
this.treeListColumn_WinFlag,
this.treeListColumn_EarningRate,
this.treeListColumn_PurchasedCount,
this.treeListColumn_AnalysisDescrption,
this.treeListColumn_OriginalData});
this.treeList_ResultData.Cursor = System.Windows.Forms.Cursors.Default;
this.treeList_ResultData.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeList_ResultData.Location = new System.Drawing.Point(0, 275);
this.treeList_ResultData.Location = new System.Drawing.Point(0, 301);
this.treeList_ResultData.Name = "treeList_ResultData";
this.treeList_ResultData.OptionsFilter.ShowAllValuesInFilterPopup = true;
this.treeList_ResultData.OptionsSelection.MultiSelect = true;
this.treeList_ResultData.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
this.repositoryItemCheckEdit_Inclustion});
this.treeList_ResultData.Size = new System.Drawing.Size(1271, 636);
this.treeList_ResultData.Size = new System.Drawing.Size(1271, 610);
this.treeList_ResultData.TabIndex = 5;
this.treeList_ResultData.KeyUp += new System.Windows.Forms.KeyEventHandler(this.treeList_ResultData_KeyUp);
this.treeList_ResultData.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.treeList_ResultData_MouseDoubleClick);
@@ -600,7 +602,7 @@ namespace Million.HunterSubForm
this.treeListColumn_AnalysisDescrption.FieldName = "Description";
this.treeListColumn_AnalysisDescrption.Name = "treeListColumn_AnalysisDescrption";
this.treeListColumn_AnalysisDescrption.Visible = true;
this.treeListColumn_AnalysisDescrption.VisibleIndex = 11;
this.treeListColumn_AnalysisDescrption.VisibleIndex = 12;
this.treeListColumn_AnalysisDescrption.Width = 375;
//
// treeListColumn_OriginalData
@@ -622,7 +624,7 @@ namespace Million.HunterSubForm
this.panelControl1.Dock = System.Windows.Forms.DockStyle.Top;
this.panelControl1.Location = new System.Drawing.Point(0, 231);
this.panelControl1.Name = "panelControl1";
this.panelControl1.Size = new System.Drawing.Size(1271, 44);
this.panelControl1.Size = new System.Drawing.Size(1271, 70);
this.panelControl1.TabIndex = 4;
//
// simpleButton_TestBoard
@@ -639,7 +641,7 @@ namespace Million.HunterSubForm
// labelControl_WinRateProfitRate
//
this.labelControl_WinRateProfitRate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelControl_WinRateProfitRate.Location = new System.Drawing.Point(369, 15);
this.labelControl_WinRateProfitRate.Location = new System.Drawing.Point(652, 50);
this.labelControl_WinRateProfitRate.Name = "labelControl_WinRateProfitRate";
this.labelControl_WinRateProfitRate.Size = new System.Drawing.Size(19, 14);
this.labelControl_WinRateProfitRate.TabIndex = 2;
@@ -705,6 +707,14 @@ namespace Million.HunterSubForm
this.simpleButton_SavaAnalysisData.Text = "결과 저장";
this.simpleButton_SavaAnalysisData.Click += new System.EventHandler(this.simpleButton_SavaAnalysisData_Click);
//
// treeListColumn_PurchasedCount
//
this.treeListColumn_PurchasedCount.Caption = "구종목 보유 수";
this.treeListColumn_PurchasedCount.FieldName = "PurchasedCount";
this.treeListColumn_PurchasedCount.Name = "treeListColumn_PurchasedCount";
this.treeListColumn_PurchasedCount.Visible = true;
this.treeListColumn_PurchasedCount.VisibleIndex = 11;
//
// ResultViewerForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
@@ -796,5 +806,6 @@ namespace Million.HunterSubForm
private DevExpress.XtraEditors.SimpleButton simpleButton_WinRateProfitRate;
public DevExpress.XtraEditors.SimpleButton simpleButton_TestBoard;
public DevExpress.XtraTreeList.TreeList treeList_ResultData;
private DevExpress.XtraTreeList.Columns.TreeListColumn treeListColumn_PurchasedCount;
}
}

View File

@@ -92,10 +92,27 @@ namespace Million.HunterSubForm
_analysisDatas.Add(analysisData);
}
var evaeragePurchasedCount = 0;
// 보유한 종목 수 계산
foreach (var item in _analysisDatas)
{
// Ts <= Os <= Te
// Ts <= Oe <= Te
var count = _analysisDatas.Count(target => (target.StartDate <= item.StartDate && target.EndDate >= item.StartDate) ||
(target.StartDate <= item.EndDate && target.EndDate >= item.EndDate)
);
item.PurchasedCount = count;
evaeragePurchasedCount += count;
}
evaeragePurchasedCount /= _analysisDatas.Count();
winRate = winRate * 100 / _analysisDatas.Count();
labelControl_WinRateProfitRate.Text = string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2}",
double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), _analysisDatas.Count());
labelControl_WinRateProfitRate.Text = string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2} 평균 보유 수 : {3}" ,
double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), _analysisDatas.Count(), evaeragePurchasedCount);
treeList_ResultData.DataSource = _analysisDatas;
treeList_ResultData.RefreshDataSource();
@@ -228,6 +245,8 @@ namespace Million.HunterSubForm
double winRate = 0;
// 평균 수익률 계산하기
double profitRate = 0;
// 종목 보유 수
var evaeragePurchasedCount = 0;
// 값이 있으면 저장
if (nodeList != null && nodeList.Count() > 0)
@@ -242,14 +261,27 @@ namespace Million.HunterSubForm
// 수익률 계산하기
profitRate += data.EarningRate;
// 종목 보유 수 계산하기
// Ts <= Os <= Te
// Ts <= Oe <= Te
var count = nodeList.Count(target => (Convert.ToDateTime(target["StartDate"]) <= data.StartDate && Convert.ToDateTime(target["EndDate"]) >= data.StartDate) ||
(Convert.ToDateTime(target["StartDate"]) <= data.EndDate && Convert.ToDateTime(target["EndDate"]) >= data.EndDate)
);
evaeragePurchasedCount += count;
data.PurchasedCount = count;
}
winRate = winRate * 100 / nodeList.Count();
evaeragePurchasedCount /= nodeList.Count();
}
labelControl_WinRateProfitRate.Text = string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2}",
double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), nodeList.Count());
labelControl_WinRateProfitRate.Text = string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2} 평균 보유 수 : {3}",
double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), nodeList.Count(), evaeragePurchasedCount);
}
private void treeList_ResultData_KeyUp(object sender, KeyEventArgs e)
{
switch (e.KeyCode)

View File

@@ -32,21 +32,25 @@ namespace Million_Hunter.HunterSubForm
this.simpleButton_FullInsertCandle = new DevExpress.XtraEditors.SimpleButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_구름떼상한선하락시판매 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_구매이전봉볼린저40_1이하 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_이전봉40_2볼린저이하 = new DevExpress.XtraEditors.CheckEdit();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.simpleButton_Reset = new DevExpress.XtraEditors.SimpleButton();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.simpleButton_찬 = new DevExpress.XtraEditors.SimpleButton();
this.checkEdit_구름떼상한선하락시판매 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.CheckEdit();
this.textEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.TextEdit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).BeginInit();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_종목보유수별수익률계산.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).BeginInit();
this.SuspendLayout();
//
// simpleButton_FullInsertCandle
@@ -72,6 +76,8 @@ namespace Million_Hunter.HunterSubForm
//
// groupBox2
//
this.groupBox2.Controls.Add(this.textEdit_종목보유수별수익률계산);
this.groupBox2.Controls.Add(this.checkEdit_종목보유수별수익률계산);
this.groupBox2.Controls.Add(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매);
this.groupBox2.Controls.Add(this.checkEdit_구름떼상한선하락시판매);
this.groupBox2.Controls.Add(this.checkEdit_구매이전봉볼린저40_1이하);
@@ -83,6 +89,24 @@ namespace Million_Hunter.HunterSubForm
this.groupBox2.TabStop = false;
this.groupBox2.Text = "지표";
//
// checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매
//
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Location = new System.Drawing.Point(19, 47);
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Name = "checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매";
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties.Caption = "구매 전봉 기준 가중이동평균 5봉이 40봉 크로스 이후 구매";
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Size = new System.Drawing.Size(310, 19);
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.TabIndex = 3;
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_구름떼상한선하락시판매
//
this.checkEdit_구름떼상한선하락시판매.Location = new System.Drawing.Point(379, 22);
this.checkEdit_구름떼상한선하락시판매.Name = "checkEdit_구름떼상한선하락시판매";
this.checkEdit_구름떼상한선하락시판매.Properties.Caption = "구름떼 상한선 하락시 판매 (1%)";
this.checkEdit_구름떼상한선하락시판매.Size = new System.Drawing.Size(179, 19);
this.checkEdit_구름떼상한선하락시판매.TabIndex = 2;
this.checkEdit_구름떼상한선하락시판매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_구매이전봉볼린저40_1이하
//
this.checkEdit_구매이전봉볼린저40_1이하.Location = new System.Drawing.Point(204, 22);
@@ -118,6 +142,7 @@ namespace Million_Hunter.HunterSubForm
this.simpleButton_Reset.Size = new System.Drawing.Size(109, 32);
this.simpleButton_Reset.TabIndex = 0;
this.simpleButton_Reset.Text = "Reset";
this.simpleButton_Reset.Click += new System.EventHandler(this.simpleButton_Reset_Click);
//
// progressBar1
//
@@ -136,23 +161,22 @@ namespace Million_Hunter.HunterSubForm
this.simpleButton_찬.Text = "찬테스트";
this.simpleButton_찬.Click += new System.EventHandler(this.simpleButton_찬_Click);
//
// checkEdit_구름떼상한선하락시판매
// checkEdit_종목보유수별수익률계산
//
this.checkEdit_구름떼상한선하락시판매.Location = new System.Drawing.Point(379, 22);
this.checkEdit_구름떼상한선하락시판매.Name = "checkEdit_구름떼상한선하락시판매";
this.checkEdit_구름떼상한선하락시판매.Properties.Caption = "구름떼 상한선 하락시 판매 (1%)";
this.checkEdit_구름떼상한선하락시판매.Size = new System.Drawing.Size(179, 19);
this.checkEdit_구름떼상한선하락시판매.TabIndex = 2;
this.checkEdit_구름떼상한선하락시판매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
this.checkEdit_종목보유수별수익률계산.Location = new System.Drawing.Point(19, 72);
this.checkEdit_종목보유수별수익률계산.Name = "checkEdit_종목보유수별수익률계산";
this.checkEdit_종목보유수별수익률계산.Properties.Caption = "종목 보유수 별 수익률 계산";
this.checkEdit_종목보유수별수익률계산.Size = new System.Drawing.Size(310, 19);
this.checkEdit_종목보유수별수익률계산.TabIndex = 3;
this.checkEdit_종목보유수별수익률계산.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매
// textEdit_종목보유수별수익률계산
//
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Location = new System.Drawing.Point(19, 47);
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Name = "checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매";
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties.Caption = "구매 전봉 기준 가중이동평균 5봉이 40봉 크로스 이후 구매";
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Size = new System.Drawing.Size(310, 19);
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.TabIndex = 3;
this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
this.textEdit_종목보유수별수익률계산.EditValue = "1";
this.textEdit_종목보유수별수익률계산.Location = new System.Drawing.Point(175, 72);
this.textEdit_종목보유수별수익률계산.Name = "textEdit_종목보유수별수익률계산";
this.textEdit_종목보유수별수익률계산.Size = new System.Drawing.Size(42, 20);
this.textEdit_종목보유수별수익률계산.TabIndex = 4;
//
// TestBoardForm
//
@@ -168,11 +192,13 @@ namespace Million_Hunter.HunterSubForm
this.Text = "TestBoard";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매이전봉볼린저40_1이하.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).EndInit();
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼상한선하락시판매.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_종목보유수별수익률계산.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).EndInit();
this.ResumeLayout(false);
}
@@ -191,5 +217,7 @@ namespace Million_Hunter.HunterSubForm
private DevExpress.XtraEditors.CheckEdit checkEdit_구매이전봉볼린저40_1이하;
private DevExpress.XtraEditors.CheckEdit checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매;
private DevExpress.XtraEditors.CheckEdit checkEdit_구름떼상한선하락시판매;
private DevExpress.XtraEditors.TextEdit textEdit_종목보유수별수익률계산;
private DevExpress.XtraEditors.CheckEdit checkEdit_종목보유수별수익률계산;
}
}

View File

@@ -358,10 +358,102 @@ namespace Million_Hunter.HunterSubForm
MessageBox.Show(string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2}",
double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), allCount.ToString()) );
}
parentForm.treeList_ResultData.RefreshDataSource();
parentForm.CalcurateProfitAndWinRate();
if (checkEdit_구매전봉기준가중이동평균5봉이40봉크로스이후구매.Checked)
{
var Interval_5 = 5;
var Interval_40 = 40;
// 분모 구하기
var 분모5일 = 0;
var 분모40일 = 0;
for (int i = 1; i <= Interval_5; i++) 분모5일 += i;
for (int i=1; i<=Interval_40; i++) 분모40일 += i;
var ttt = parentForm._totalIndicator.First().MCandleTimeType;
foreach (var analysisData in parentForm._analysisDatas)
{
// 현재 시간 데이터 포함
var 구매이전봉_5일전거래시간 = changeDatetimeFormat(analysisData.StartDate, -Interval_5);
var 구매이전봉_40일전거래시간 = changeDatetimeFormat(analysisData.StartDate, -Interval_40);
var 구매이전봉_거래시간 = changeDatetimeFormat(analysisData.StartDate, -1);
var 가중이동평균5일 = 0.0;
var 가중이동평균40일 = 0.0;
int count_40 = Interval_40;
int count_5 = Interval_5;
var curDateTime = 구매이전봉_거래시간;
while (curDateTime >= 구매이전봉_40일전거래시간)
{
var candleData = analysisData.CandleDatas[MCandleTimeType].Find(item => item.DateTime == curDateTime);
var 거래량 = 0.0;
// 데이터가 없으면 거래량 0으로 사용
if (candleData == null) 거래량 = 0;
else 거래량 = Convert.ToDouble(candleData.MoneyVolume);
// 5일치 누적 및 계산이 끝났으면 그만 계산
if (curDateTime >= 구매이전봉_5일전거래시간)
{
가중이동평균5일 += count_5 * 거래량;
}
// 5일 계산
if (curDateTime == 구매이전봉_5일전거래시간)
{
가중이동평균5일 /= 분모5일;
// 5일 계산
거래량 = 0.0;
}
// 40일 누적
가중이동평균40일 += count_40 * 거래량;
// 40일 계산
if (curDateTime == 구매이전봉_40일전거래시간)
{
가중이동평균40일 /= 분모40일;
}
curDateTime = changeDatetimeFormat(curDateTime, -1);
count_40--;
count_5--;
}
// 제외된 조건인 아닌 경우 (만족 조건 중에서만 검색)
if (analysisData.Inclusion)
{
var result = false;
if (가중이동평균5일 > 가중이동평균40일)
{
result = true;
analysisData.Inclusion = true;
}
else
{
result = false;
analysisData.Inclusion = false;
}
analysisData.Description = string.Format("[{0},5일:{1:0.0},40일:{2:0.0}]",result, 가중이동평균5일, 가중이동평균40일);
}
}
if (checkEdit_종목보유수별수익률계산.Checked)
{
var coinCount = Convert.ToInt32(textEdit_종목보유수별수익률계산.Text);
//inCount =
}
parentForm.CalcurateProfitAndWinRate();
parentForm.treeList_ResultData.RefreshDataSource();
}
}

View File

@@ -46,6 +46,10 @@ namespace Million.Data
// 기타 기입 내용
public string Description { get; set; }
// 현재 시간으로 구매된 종목 개수
[field: NonSerialized]
public int PurchasedCount { get; set; }
[field: NonSerialized]
public Dictionary<CommonProperty.MCandleTimeType,List<CandleData>> CandleDatas { get; set; }