Merge branch 'feature/V1.1' of http://222.96.13.116/Million into feature/V1.1

This commit is contained in:
DESKTOP-1A3P75F\lee
2023-07-07 13:06:29 +09:00
26 changed files with 1673 additions and 712 deletions

View File

@@ -28,7 +28,9 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.cb_StarValueLowOverlapUp = new System.Windows.Forms.CheckBox();
this.cb_DownBeforeValueFlag = new System.Windows.Forms.CheckBox();
this.cb_UpperMainIndi = new System.Windows.Forms.CheckBox();
this.cb_IncludeClearIndicator = new System.Windows.Forms.CheckBox();
@@ -69,10 +71,6 @@
this.lb_log = new System.Windows.Forms.ListBox();
this.bt_alive = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.label5 = new System.Windows.Forms.Label();
this.dt_End = new DevExpress.XtraEditors.DateEdit();
this.dt_Start = new DevExpress.XtraEditors.DateEdit();
this.rd_BuyerTickerMode = new System.Windows.Forms.RadioButton();
this.cb_AccountList = new System.Windows.Forms.ComboBox();
this.cb_UserList = new System.Windows.Forms.ComboBox();
this.label12 = new System.Windows.Forms.Label();
@@ -89,20 +87,15 @@
this.bt_BuyStop = new System.Windows.Forms.Button();
this.bt_BuyStart = new System.Windows.Forms.Button();
this.lb_BuyFlag = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.splitContainerControl1 = new DevExpress.XtraEditors.SplitContainerControl();
this.splitContainerControl2 = new DevExpress.XtraEditors.SplitContainerControl();
this.bt_AllSell = new System.Windows.Forms.Button();
this.cb_StarValueLowOverlapUp = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tl_BuyList)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tl_Result)).BeginInit();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dt_End.Properties.CalendarTimeProperties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dt_End.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dt_Start.Properties.CalendarTimeProperties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dt_Start.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tl_RealtimeOrder)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).BeginInit();
this.splitContainerControl1.SuspendLayout();
@@ -125,13 +118,23 @@
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Location = new System.Drawing.Point(12, 172);
this.groupBox1.Location = new System.Drawing.Point(12, 149);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(362, 230);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "데이터 Setting";
//
// cb_StarValueLowOverlapUp
//
this.cb_StarValueLowOverlapUp.AutoSize = true;
this.cb_StarValueLowOverlapUp.Location = new System.Drawing.Point(9, 199);
this.cb_StarValueLowOverlapUp.Name = "cb_StarValueLowOverlapUp";
this.cb_StarValueLowOverlapUp.Size = new System.Drawing.Size(164, 16);
this.cb_StarValueLowOverlapUp.TabIndex = 15;
this.cb_StarValueLowOverlapUp.Text = "사는시점 전 고가<현 시가";
this.cb_StarValueLowOverlapUp.UseVisualStyleBackColor = true;
//
// cb_DownBeforeValueFlag
//
this.cb_DownBeforeValueFlag.AutoSize = true;
@@ -250,7 +253,7 @@
this.groupBox2.Controls.Add(this.label10);
this.groupBox2.Controls.Add(this.lb_BuyMarketCount);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Location = new System.Drawing.Point(12, 408);
this.groupBox2.Location = new System.Drawing.Point(12, 388);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(362, 72);
this.groupBox2.TabIndex = 6;
@@ -496,10 +499,10 @@
this.lb_log.FormattingEnabled = true;
this.lb_log.HorizontalScrollbar = true;
this.lb_log.ItemHeight = 12;
this.lb_log.Location = new System.Drawing.Point(12, 486);
this.lb_log.Location = new System.Drawing.Point(12, 474);
this.lb_log.Name = "lb_log";
this.lb_log.ScrollAlwaysVisible = true;
this.lb_log.Size = new System.Drawing.Size(362, 256);
this.lb_log.Size = new System.Drawing.Size(362, 268);
this.lb_log.TabIndex = 16;
//
// bt_alive
@@ -515,10 +518,6 @@
//
// groupBox3
//
this.groupBox3.Controls.Add(this.label5);
this.groupBox3.Controls.Add(this.dt_End);
this.groupBox3.Controls.Add(this.dt_Start);
this.groupBox3.Controls.Add(this.rd_BuyerTickerMode);
this.groupBox3.Controls.Add(this.cb_AccountList);
this.groupBox3.Controls.Add(this.cb_UserList);
this.groupBox3.Controls.Add(this.label12);
@@ -527,57 +526,11 @@
this.groupBox3.Controls.Add(this.rd_Realtime);
this.groupBox3.Location = new System.Drawing.Point(12, 9);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(362, 157);
this.groupBox3.Size = new System.Drawing.Size(362, 134);
this.groupBox3.TabIndex = 10;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "계정 및 모드 선택";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(243, 123);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(14, 12);
this.label5.TabIndex = 18;
this.label5.Text = "~";
//
// dt_End
//
this.dt_End.EditValue = null;
this.dt_End.Enabled = false;
this.dt_End.Location = new System.Drawing.Point(262, 120);
this.dt_End.Name = "dt_End";
this.dt_End.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.dt_End.Properties.CalendarTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.dt_End.Size = new System.Drawing.Size(94, 20);
this.dt_End.TabIndex = 17;
//
// dt_Start
//
this.dt_Start.EditValue = null;
this.dt_Start.Enabled = false;
this.dt_Start.Location = new System.Drawing.Point(148, 120);
this.dt_Start.Name = "dt_Start";
this.dt_Start.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.dt_Start.Properties.CalendarTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.dt_Start.Size = new System.Drawing.Size(89, 20);
this.dt_Start.TabIndex = 16;
//
// rd_BuyerTickerMode
//
this.rd_BuyerTickerMode.AutoSize = true;
this.rd_BuyerTickerMode.Location = new System.Drawing.Point(10, 123);
this.rd_BuyerTickerMode.Name = "rd_BuyerTickerMode";
this.rd_BuyerTickerMode.Size = new System.Drawing.Size(131, 16);
this.rd_BuyerTickerMode.TabIndex = 15;
this.rd_BuyerTickerMode.Text = "Buyer Ticker Mode";
this.rd_BuyerTickerMode.UseVisualStyleBackColor = true;
this.rd_BuyerTickerMode.CheckedChanged += new System.EventHandler(this.rd_BuyerTickerMode_CheckedChanged);
//
// cb_AccountList
//
this.cb_AccountList.FormattingEnabled = true;
@@ -773,16 +726,6 @@
this.bt_AllSell.UseVisualStyleBackColor = true;
this.bt_AllSell.Click += new System.EventHandler(this.bt_AllSell_Click);
//
// cb_StarValueLowOverlapUp
//
this.cb_StarValueLowOverlapUp.AutoSize = true;
this.cb_StarValueLowOverlapUp.Location = new System.Drawing.Point(9, 199);
this.cb_StarValueLowOverlapUp.Name = "cb_StarValueLowOverlapUp";
this.cb_StarValueLowOverlapUp.Size = new System.Drawing.Size(164, 16);
this.cb_StarValueLowOverlapUp.TabIndex = 15;
this.cb_StarValueLowOverlapUp.Text = "사는시점 전 고가<현 시가";
this.cb_StarValueLowOverlapUp.UseVisualStyleBackColor = true;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -811,10 +754,6 @@
((System.ComponentModel.ISupportInitialize)(this.tl_Result)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dt_End.Properties.CalendarTimeProperties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dt_End.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dt_Start.Properties.CalendarTimeProperties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dt_Start.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tl_RealtimeOrder)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainerControl1)).EndInit();
this.splitContainerControl1.ResumeLayout(false);
@@ -887,10 +826,6 @@
private DevExpress.XtraEditors.SplitContainerControl splitContainerControl1;
private DevExpress.XtraEditors.SplitContainerControl splitContainerControl2;
private System.Windows.Forms.CheckBox cb_DownBeforeValueFlag;
private System.Windows.Forms.RadioButton rd_BuyerTickerMode;
private System.Windows.Forms.Label label5;
private DevExpress.XtraEditors.DateEdit dt_End;
private DevExpress.XtraEditors.DateEdit dt_Start;
private System.Windows.Forms.Button bt_AllSell;
private System.Windows.Forms.CheckBox cb_StarValueLowOverlapUp;
}

View File

@@ -88,9 +88,7 @@ namespace Million_Buyer
private void rd_Realtime_CheckedChanged(object sender, EventArgs e)
{
programMode = BuyerMode.BuyerRealtime;
SetReadOnly(true);
dt_Start.Enabled = false;
dt_End.Enabled = false;
SetReadOnly(true);
}
/// <summary>
@@ -101,18 +99,7 @@ namespace Million_Buyer
private void rd_buyer_CheckedChanged(object sender, EventArgs e)
{
programMode = BuyerMode.Buyer;
SetReadOnly(false);
dt_Start.Enabled = false;
dt_End.Enabled = false;
}
private void rd_BuyerTickerMode_CheckedChanged(object sender, EventArgs e)
{
programMode = BuyerMode.BuyerTicker;
SetReadOnly(true);
dt_Start.Enabled = true;
dt_End.Enabled = true;
SetReadOnly(false);
}
/// <summary>
@@ -196,9 +183,6 @@ namespace Million_Buyer
cb_UpperMainIndi.Enabled = false;
rd_buyer.Enabled = false;
rd_Realtime.Enabled = false;
dt_Start.Enabled = false;
dt_End.Enabled = false;
rd_BuyerTickerMode.Enabled = false;
cb_StarValueLowOverlapUp.Enabled = false;
}
}
@@ -218,7 +202,6 @@ namespace Million_Buyer
bt_Start.Enabled = true;
rd_buyer.Enabled = true;
rd_Realtime.Enabled = true;
rd_BuyerTickerMode.Enabled = true;
if (rd_buyer.Checked)
SetReadOnly(false);
@@ -229,18 +212,8 @@ namespace Million_Buyer
cb_UpperMainIndi.Enabled = true;
cb_StarValueLowOverlapUp.Enabled = true;
if (programMode == BuyerMode.BuyerTicker)
{
dt_Start.Enabled = true;
dt_End.Enabled = true;
}
/*
* 종료 된 후 데이터 처리 소스는 여기서 처리
* 1. Grid에 Stop 후 데이터 처리
* 2. 종료 후 데이터 저장 처리
*/
}
/// <summary>
@@ -365,9 +338,7 @@ namespace Million_Buyer
if (programMode == BuyerMode.BuyerRealtime)
InsertLog("실시간 검증 구동 중..");
else if (programMode == BuyerMode.Buyer)
InsertLog("Buyer 구동 중..");
else if (programMode == BuyerMode.BuyerTicker)
InsertLog("Buyer Ticker 구동 중..");
InsertLog("Buyer 구동 중..");
var cnt = 0;
sw.Start();
@@ -391,13 +362,7 @@ namespace Million_Buyer
realTimeMsg = new RealtimeDataSettingManager(null, programMode, this.payment);
var startDateTime = DateTime.Now;
var endDateTime = startDateTime;
if (programMode == BuyerMode.BuyerTicker)
{
startDateTime = dt_Start.DateTime;
endDateTime = dt_End.DateTime;
}
var endDateTime = startDateTime;
dataList = realTimeMsg.GetRealTimeCandleData(candleTypeList, startDateTime, endDateTime, 200);
@@ -406,7 +371,7 @@ namespace Million_Buyer
InsertLog("Buyer Ticker List 종료");
break;
}
#region TODO 이미 구매되어 있는 종목에 대한 기본 데이터 Setting 필요
if (programMode == BuyerMode.Buyer)
{
buyList = InitManager.GetBuyListofAccounts(this.accounts, dataList);
@@ -427,16 +392,12 @@ namespace Million_Buyer
}
lb_BuyMarketCount.Text = buyList.Count.ToString();
}));
#region TODO 이미 구매되어 있는 종목에 대한 기본 데이터 Setting 필요
}));
#endregion
firstFlag = false;
sw.Stop();
InsertLog("Deafult Data Setting 완료..\\r\n" + "Default 계산 시간 : " + sw.Elapsed.ToString());
LogManager.WriteLog("Default 계산 시간 : " + sw.Elapsed.ToString());
@@ -527,25 +488,25 @@ namespace Million_Buyer
continue;
}
if (StarValueLowOverlapUp)
if (StarValueLowBuyValueUp)
{
if (recentlyData.StartValue < beforeData.HighValue)
//if (recentlyData.StartValue < beforeData.HighValue)
//{
// foreach (var indi in totalIndicatorList)
// subIndicatorStateManagement[indi.IndexString][item] = false;
// overlapBuyManagementList[item] = false;
// continue;
//}
if (recentlyData.BuyValue < beforeData.HighValue)
{
foreach (var indi in totalIndicatorList)
subIndicatorStateManagement[indi.IndexString][item] = false;
overlapBuyManagementList[item] = false;
overlapBuyManagementList[item] = true;
continue;
}
//if (recentlyData.BuyValue < beforeData.HighValue)
//{
// foreach (var indi in totalIndicator)
// subIndicatorStateManagement[indi.IndexString][item] = false;
// overlapBuyManagementList[item] = true;
// continue;
//}
}
@@ -614,19 +575,23 @@ namespace Million_Buyer
}
}
else
{
//default sell
var flag = sellScript.DicExcuteScript(recentlyData.CalculateFlag);
{
var flag = false;
var scriptStr = sellScript.regularExpressionString;
if (sellExceptionScript.regularExpressionString != null &&
sellExceptionScript.regularExpressionString.Length > 0)
{
//예외처리 로직 추가
flag = sellExceptionScript.DicExcuteScript(recentlyData.CalculateFlag);
if (flag) scriptStr = sellExceptionScript.regularExpressionString;
}
if (!flag)
{
if (sellExceptionScript.regularExpressionString != null &&
sellExceptionScript.regularExpressionString.Length > 0)
{
//예외처리 로직 추가
flag = sellExceptionScript.DicExcuteScript(recentlyData.CalculateFlag);
if (flag) scriptStr = sellExceptionScript.regularExpressionString;
}
//default sell
flag = sellScript.DicExcuteScript(recentlyData.CalculateFlag);
scriptStr = sellScript.regularExpressionString;
}
if (allSell) flag = true;
@@ -743,6 +708,8 @@ namespace Million_Buyer
}
}
realTimeMsg.Flag = false;
SaveData();
InsertLog("Thread Out");
}

View File

@@ -273,7 +273,7 @@ namespace Million
// 조건 검색을 반영하여 데이터 계산
private void simpleButton_CalcurateData_Click(object sender, EventArgs e)
{
CommonProperty.StarValueLowOverlapUp = cb_StarValueLowOverlapUp.Checked;
CommonProperty.StarValueLowBuyValueUp = cb_StarValueLowOverlapUp.Checked;
// 계산 결과 데이터 관련 클래스에 값 채우기
DeafultDataSet();
@@ -352,7 +352,7 @@ namespace Million
var dic = new Dictionary<string, List<SearchResult>>();
Parallel.For(0, tableList.Count, i =>
{
//for (var i = 0; i < tableList.Count; i++)
// for (var i = 0; i < tableList.Count; i++)
//{
var market = tableList[i];
var distinctIndicator = IndicatorSetupManager.Distinct(totalIndicator);
@@ -374,7 +374,7 @@ namespace Million
foreach (var item in dic.Keys)
{
if(dic.ContainsKey(item))
if (dic.ContainsKey(item))
totalResultList.AddRange(dic[item]);
}
@@ -451,7 +451,16 @@ namespace Million
private List<SearchResult> CalculateHunterRealtime(List<IndicatorCoditionSetup> totalIndicator, DateTime startDate, DateTime endDate, MarketData market,
List<IndicatorCoditionSetup> distinctIndicator, Dictionary<string, bool> overlapBuyManagementList,
InteratorScripter buyScript, InteratorScripter sellScript, InteratorScripter sellExceptionScript)
{
{
var totalCandleTypeList = totalIndicator.Select(t => t.MCandleTimeType).ToList();
var maxCandleType = totalCandleTypeList.Max();
var list = totalCandleTypeList.Where(t => t < MCandleTimeType.H1).ToList();
var minMaxCandleType = MCandleTimeType.M1;
if (!(list == null || list.Count == 0))
minMaxCandleType = list.Max();
var buyList = new List<CandleDataList>();
var subBuyList = new List<CandleDataList>();
var item = market.CoinFullName;
@@ -460,24 +469,44 @@ namespace Million
var resultData = new List<SearchResult>();
var startMiniuteDate = startDate.AddMinutes(-100);
var startHourDate = startDate.AddHours(-100);
var startMiniuteDate = startDate.AddMinutes((int)minMaxCandleType * -80);
var mCandleTypeList = new List<CommonProperty.MCandleTimeType>();
mCandleTypeList.Add(CommonProperty.MCandleTimeType.M1);
var hCandleTypeList = new List<CommonProperty.MCandleTimeType>();
hCandleTypeList.Add(CommonProperty.MCandleTimeType.H1);
var standardData = DataManager.GetStandardData(totalIndicator, startMiniuteDate, startDate, market, distinctIndicator, true, mCandleTypeList);
var hStandardData = DataManager.GetStandardData(totalIndicator, startHourDate, startDate, market, distinctIndicator, true, hCandleTypeList);
totalCandleTypeList.AddRange(mCandleTypeList);
if (maxCandleType >= MCandleTimeType.H1)
{
var startHourDate = startDate.AddHours((int)maxCandleType / 60 * -80);
var hCandleTypeList = new List<CommonProperty.MCandleTimeType>();
hCandleTypeList.Add(CommonProperty.MCandleTimeType.H1);
var hStandardData = DataManager.GetStandardData(totalIndicator, startHourDate, startDate, market, distinctIndicator, true, hCandleTypeList);
standardData.Add(CommonProperty.MCandleTimeType.H1, hStandardData[CommonProperty.MCandleTimeType.H1]);
totalCandleTypeList.AddRange(hCandleTypeList);
}
totalCandleTypeList = totalCandleTypeList.Distinct().ToList();
foreach(var candleTimeType in totalCandleTypeList)
{
if (standardData.ContainsKey(candleTimeType)) continue;
var candleDataList = standardData[MCandleTimeType.M1];
if (candleTimeType >= MCandleTimeType.H1)
candleDataList = standardData[MCandleTimeType.H1];
if (candleTimeType == MCandleTimeType.M1 || candleTimeType == MCandleTimeType.H1) continue;
standardData[candleTimeType] = DataManager.GetConvertCandleDataList(candleDataList, candleTimeType);
}
standardData.Add(CommonProperty.MCandleTimeType.H1, hStandardData[CommonProperty.MCandleTimeType.H1]);
//속도 및 메모리 부하를 줄이기 위한 로직 추가
//db 전체 데이터 불러오는 로직 -> 1분봉 데이터 하나도 안빠져있다는 가정
#region 개선 후
var standardStartDate = startDate;
var standardEndDate = startDate.AddDays(7);
@@ -524,43 +553,22 @@ namespace Million
}
//remove
if (standardData[CommonProperty.MCandleTimeType.M1].Count > 150)
standardData[CommonProperty.MCandleTimeType.M1].RemoveAt(0);
if (standardData[CommonProperty.MCandleTimeType.H1].Count > 150)
standardData[CommonProperty.MCandleTimeType.H1].RemoveAt(0);
foreach (var key in standardData.Keys) {
if (standardData[key].Count > 150)
standardData[key].RemoveAt(0);
}
//1분씩 증가하면서 1h 처리
//1분씩 증가하면서 나머지 처리
minData.RecentlyDataFlag = true;
standardData[CommonProperty.MCandleTimeType.M1].Add(minData);
var compareHour = standardData[CommonProperty.MCandleTimeType.H1].LastOrDefault();
if (compareHour.DateTime.Hour != minData.DateTime.Hour)
foreach (var key in standardData.Keys)
{
var candle = new CandleData();
candle.CandleTimeType = (int)MCandleTimeType.H1;
candle.StartValue = minData.StartValue;
candle.HighValue = minData.HighValue;
candle.LowValue = minData.LowValue;
candle.RecentlyDataFlag = true;
candle.EndValue = minData.EndValue;
candle.MoneyVolume = minData.MoneyVolume;
var date = compareHour.DateTime.AddHours(1);
date = date.AddMinutes(-1 * date.Minute);
date = date.AddSeconds(-1 * date.Second);
candle.DateTime = date;
standardData[CommonProperty.MCandleTimeType.H1].Add(candle);
}
else
{
compareHour.HighValue = compareHour.HighValue < minData.HighValue ? minData.HighValue : compareHour.HighValue;
compareHour.LowValue = compareHour.LowValue < minData.LowValue ? compareHour.LowValue : minData.LowValue;
compareHour.EndValue = minData.EndValue;
compareHour.RecentlyDataFlag = true;
compareHour.MoneyVolume += minData.MoneyVolume;
var compareData = standardData[key].LastOrDefault();
var newFlag = false;
var candleData = DataManager.GetRecentlyCandleData(minData, compareData, key, ref newFlag);
if (newFlag)
standardData[key].Add(candleData);
}
standardData = DataManager.GetExecuteData(standardData, totalIndicator);
@@ -584,11 +592,9 @@ namespace Million
mDataList.CandleDataLists_Im.RemoveAt(0);
continue;
}
var recentlyDate = recentlyData.DateTime;
recentlyDate = recentlyDate.AddMinutes(recentlyDate.Minute * -1);
recentlyDate = recentlyDate.AddHours( -1);
//before 데이터 가져오는 함수
var beforeData = standardData[MCandleTimeType.H1].FirstOrDefault(t => t.DateTime == recentlyDate);
//before 데이터 가져오는 함수 -> 사는 케이스만
var beforeData = standardData[maxCandleType].LastOrDefault();
if (!buyList.Any(t => t.ConGoodsData.CoinFullName == item))
{
@@ -613,18 +619,9 @@ namespace Million
recentlyData.BuyValue = OrderbookManager.GetAskPrice(CalculateManager.GetConditionValue(buyScript.regularExpressionString, valDic, recentlyData.CalculateFlag));
// 이전 전봉(H1)의 고가가 사려는 가격보다 높을경우 pass
if (StarValueLowOverlapUp)
if (StarValueLowBuyValueUp)
{
if (recentlyData.StartValue < beforeData.HighValue)
{
foreach (var indi in totalIndicator)
subIndicatorStateManagement[indi.IndexString][item] = false;
overlapBuyManagementList[item] = false;
continue;
}
//if (recentlyData.BuyValue < beforeData.HighValue)
//if (recentlyData.StartValue < beforeData.HighValue)
//{
// foreach (var indi in totalIndicator)
// subIndicatorStateManagement[indi.IndexString][item] = false;
@@ -632,6 +629,15 @@ namespace Million
// overlapBuyManagementList[item] = true;
// continue;
//}
if (recentlyData.BuyValue < beforeData.HighValue)
{
foreach (var indi in totalIndicator)
subIndicatorStateManagement[indi.IndexString][item] = false;
overlapBuyManagementList[item] = true;
continue;
}
}
recentlyData.BuyTime = recentlyData.DateTime;
@@ -1027,8 +1033,7 @@ namespace Million
/// <param name="sender"></param>
/// <param name="e"></param>
private void bt_CalculateList_Click(object sender, EventArgs e)
{
CommonProperty.StarValueLowOverlapUp = cb_StarValueLowOverlapUp.Checked;
{
if (multiSavedResultDatas.Count > 0)
{
LogManager.WriteLog("헌터 리스트 계산 시작", "Hunter List 계산");
@@ -1036,6 +1041,8 @@ namespace Million
foreach (var item in multiSavedResultDatas)
{
CommonProperty.StarValueLowBuyValueUp = item.StarValueLowOverlapUp;
CalculateDatas(item.SavedResultData, item.UpperMainIndicatorFlag, item.IncludeClearIndicator, item.DownBeforeValueFlag, item.HunterMode);
LogManager.WriteLog("헌터 리스트 계산 완료. Name : " + item.SavedResultData.Name, "Hunter List 계산");
@@ -1082,6 +1089,7 @@ namespace Million
data.HunterMode = rd_Hunter.Checked;
data.IncludeClearIndicator = cb_IncludeClearIndicator.Checked;
data.UpperMainIndicatorFlag = cb_UpperMainIndi.Checked;
data.StarValueLowOverlapUp = cb_StarValueLowOverlapUp.Checked;
multiSavedResultDatas.Add(data);
MessageBox.Show("추가 완료");

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,17 +32,73 @@ 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_4시간_8시간구름떼위_양봉 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_4시간_8시간구름떼위 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_시가가볼린저401보다작음 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_시가구름떼위에서시작 = new DevExpress.XtraEditors.CheckEdit();
this.textEdit_종가시간판매 = new DevExpress.XtraEditors.TextEdit();
this.checkEdit_종가시간판매 = new DevExpress.XtraEditors.CheckEdit();
this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
this.textEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.TextEdit();
this.checkEdit1 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_종목보유수별수익률계산 = new DevExpress.XtraEditors.CheckEdit();
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.groupBox4 = new System.Windows.Forms.GroupBox();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.checkEdit_1H = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_4H = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_8H = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_12H = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_1D = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_15M = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_10M = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_5M = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_1M = new DevExpress.XtraEditors.CheckEdit();
this.comboBoxEdit_defaultTime = new DevExpress.XtraEditors.ComboBoxEdit();
this.checkEdit_구름떼돌파몇봉이내 = new DevExpress.XtraEditors.CheckEdit();
this.textEdit_구름떼돌파몇봉이내 = new DevExpress.XtraEditors.TextEdit();
this.checkEdit_시가볼린저40_1아래 = new DevExpress.XtraEditors.CheckEdit();
this.checkEdit_시가구름떼위 = new DevExpress.XtraEditors.CheckEdit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_4시간_8시간구름떼위_양봉.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_4시간_8시간구름떼위.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가가볼린저401보다작음.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위에서시작.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit_종가시간판매.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_종가시간판매.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit1.Properties)).BeginInit();
((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.checkEdit_구매이전봉볼린저40_1이하.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).BeginInit();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_1H.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_4H.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_8H.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_12H.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_1D.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_15M.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_10M.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_5M.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_1M.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_defaultTime.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼돌파몇봉이내.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit_구름떼돌파몇봉이내.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가볼린저40_1아래.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위.Properties)).BeginInit();
this.SuspendLayout();
//
// simpleButton_FullInsertCandle
@@ -53,30 +109,161 @@ namespace Million_Hunter.HunterSubForm
this.simpleButton_FullInsertCandle.Name = "simpleButton_FullInsertCandle";
this.simpleButton_FullInsertCandle.Size = new System.Drawing.Size(121, 32);
this.simpleButton_FullInsertCandle.TabIndex = 1;
this.simpleButton_FullInsertCandle.Text = "1시간봉 다 채우기";
this.simpleButton_FullInsertCandle.Text = "시간봉 다 채우기";
this.simpleButton_FullInsertCandle.Click += new System.EventHandler(this.simpleButton_FullInsertCandle_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.comboBoxEdit_defaultTime);
this.groupBox1.Controls.Add(this.checkEdit_15M);
this.groupBox1.Controls.Add(this.checkEdit_10M);
this.groupBox1.Controls.Add(this.checkEdit_5M);
this.groupBox1.Controls.Add(this.checkEdit_1M);
this.groupBox1.Controls.Add(this.simpleButton_FullInsertCandle);
this.groupBox1.Controls.Add(this.checkEdit_1D);
this.groupBox1.Controls.Add(this.checkEdit_12H);
this.groupBox1.Controls.Add(this.checkEdit_8H);
this.groupBox1.Controls.Add(this.checkEdit_4H);
this.groupBox1.Controls.Add(this.checkEdit_1H);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(154, 63);
this.groupBox1.Size = new System.Drawing.Size(255, 126);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "데이터 채우기";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.checkEdit_시가구름떼위);
this.groupBox2.Controls.Add(this.checkEdit_시가볼린저40_1아래);
this.groupBox2.Controls.Add(this.textEdit_구름떼돌파몇봉이내);
this.groupBox2.Controls.Add(this.checkEdit_구름떼돌파몇봉이내);
this.groupBox2.Controls.Add(this.groupBox5);
this.groupBox2.Controls.Add(this.groupBox4);
this.groupBox2.Controls.Add(this.checkEdit_시가가볼린저401보다작음);
this.groupBox2.Controls.Add(this.checkEdit_시가구름떼위에서시작);
this.groupBox2.Controls.Add(this.textEdit1);
this.groupBox2.Controls.Add(this.textEdit_종목보유수별수익률계산);
this.groupBox2.Controls.Add(this.checkEdit1);
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이하);
this.groupBox2.Controls.Add(this.checkEdit_이전봉40_2볼린저이하);
this.groupBox2.Location = new System.Drawing.Point(12, 90);
this.groupBox2.Location = new System.Drawing.Point(12, 162);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(829, 123);
this.groupBox2.Size = new System.Drawing.Size(1006, 230);
this.groupBox2.TabIndex = 3;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "지표";
//
// checkEdit_4시간_8시간구름떼위_양봉
//
this.checkEdit_4시간_8시간구름떼위_양봉.Location = new System.Drawing.Point(6, 46);
this.checkEdit_4시간_8시간구름떼위_양봉.Name = "checkEdit_4시간_8시간구름떼위_양봉";
this.checkEdit_4시간_8시간구름떼위_양봉.Properties.Caption = "4시간, 8시간 구름떼위 양봉 (1시간 기준)";
this.checkEdit_4시간_8시간구름떼위_양봉.Size = new System.Drawing.Size(221, 19);
this.checkEdit_4시간_8시간구름떼위_양봉.TabIndex = 9;
this.checkEdit_4시간_8시간구름떼위_양봉.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_4시간_8시간구름떼위
//
this.checkEdit_4시간_8시간구름떼위.Location = new System.Drawing.Point(6, 21);
this.checkEdit_4시간_8시간구름떼위.Name = "checkEdit_4시간_8시간구름떼위";
this.checkEdit_4시간_8시간구름떼위.Properties.Caption = "4시간, 8시간구름떼위 (1시간 기준)";
this.checkEdit_4시간_8시간구름떼위.Size = new System.Drawing.Size(195, 19);
this.checkEdit_4시간_8시간구름떼위.TabIndex = 9;
this.checkEdit_4시간_8시간구름떼위.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_시가가볼린저401보다작음
//
this.checkEdit_시가가볼린저401보다작음.Location = new System.Drawing.Point(164, 97);
this.checkEdit_시가가볼린저401보다작음.Name = "checkEdit_시가가볼린저401보다작음";
this.checkEdit_시가가볼린저401보다작음.Properties.Caption = "시가가 볼린저 40 1 보다 작음";
this.checkEdit_시가가볼린저401보다작음.Size = new System.Drawing.Size(165, 19);
this.checkEdit_시가가볼린저401보다작음.TabIndex = 8;
this.checkEdit_시가가볼린저401보다작음.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_시가구름떼위에서시작
//
this.checkEdit_시가구름떼위에서시작.Location = new System.Drawing.Point(19, 97);
this.checkEdit_시가구름떼위에서시작.Name = "checkEdit_시가구름떼위에서시작";
this.checkEdit_시가구름떼위에서시작.Properties.Caption = "시가 구름떼 위에서 시작";
this.checkEdit_시가구름떼위에서시작.Size = new System.Drawing.Size(150, 19);
this.checkEdit_시가구름떼위에서시작.TabIndex = 7;
this.checkEdit_시가구름떼위에서시작.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// textEdit_종가시간판매
//
this.textEdit_종가시간판매.EditValue = "0";
this.textEdit_종가시간판매.Location = new System.Drawing.Point(108, 21);
this.textEdit_종가시간판매.Name = "textEdit_종가시간판매";
this.textEdit_종가시간판매.Properties.Mask.EditMask = "d";
this.textEdit_종가시간판매.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
this.textEdit_종가시간판매.Size = new System.Drawing.Size(42, 20);
this.textEdit_종가시간판매.TabIndex = 6;
//
// checkEdit_종가시간판매
//
this.checkEdit_종가시간판매.Location = new System.Drawing.Point(6, 21);
this.checkEdit_종가시간판매.Name = "checkEdit_종가시간판매";
this.checkEdit_종가시간판매.Properties.Caption = "종가(시간)판매";
this.checkEdit_종가시간판매.Size = new System.Drawing.Size(102, 19);
this.checkEdit_종가시간판매.TabIndex = 5;
this.checkEdit_종가시간판매.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// textEdit1
//
this.textEdit1.EditValue = "1";
this.textEdit1.Location = new System.Drawing.Point(298, 72);
this.textEdit1.Name = "textEdit1";
this.textEdit1.Size = new System.Drawing.Size(42, 20);
this.textEdit1.TabIndex = 4;
//
// textEdit_종목보유수별수익률계산
//
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;
//
// checkEdit1
//
this.checkEdit1.Location = new System.Drawing.Point(233, 73);
this.checkEdit1.Name = "checkEdit1";
this.checkEdit1.Properties.Caption = "거래대금";
this.checkEdit1.Size = new System.Drawing.Size(150, 19);
this.checkEdit1.TabIndex = 3;
this.checkEdit1.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_종목보유수별수익률계산
//
this.checkEdit_종목보유수별수익률계산.Location = new System.Drawing.Point(19, 72);
this.checkEdit_종목보유수별수익률계산.Name = "checkEdit_종목보유수별수익률계산";
this.checkEdit_종목보유수별수익률계산.Properties.Caption = "종목 보유수 별 수익률 계산";
this.checkEdit_종목보유수별수익률계산.Size = new System.Drawing.Size(150, 19);
this.checkEdit_종목보유수별수익률계산.TabIndex = 3;
this.checkEdit_종목보유수별수익률계산.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// 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);
@@ -98,53 +285,230 @@ namespace Million_Hunter.HunterSubForm
// groupBox3
//
this.groupBox3.Controls.Add(this.simpleButton_Reset);
this.groupBox3.Location = new System.Drawing.Point(187, 12);
this.groupBox3.Location = new System.Drawing.Point(373, 12);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(154, 63);
this.groupBox3.TabIndex = 4;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "데이터 채우기";
this.groupBox3.Text = "관리";
//
// simpleButton_Reset
//
this.simpleButton_Reset.Location = new System.Drawing.Point(0, 0);
this.simpleButton_Reset.Location = new System.Drawing.Point(6, 21);
this.simpleButton_Reset.Name = "simpleButton_Reset";
this.simpleButton_Reset.Size = new System.Drawing.Size(75, 23);
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
//
this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.progressBar1.Location = new System.Drawing.Point(0, 275);
this.progressBar1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.progressBar1.Location = new System.Drawing.Point(0, 395);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(852, 23);
this.progressBar1.Size = new System.Drawing.Size(1030, 23);
this.progressBar1.TabIndex = 5;
//
// simpleButton_찬
//
this.simpleButton_찬.Location = new System.Drawing.Point(737, 33);
this.simpleButton_찬.Location = new System.Drawing.Point(914, 23);
this.simpleButton_찬.Name = "simpleButton_찬";
this.simpleButton_찬.Size = new System.Drawing.Size(104, 32);
this.simpleButton_찬.TabIndex = 4;
this.simpleButton_찬.Text = "찬테스트";
this.simpleButton_찬.Click += new System.EventHandler(this.simpleButton_찬_Click);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.checkEdit_4시간_8시간구름떼위);
this.groupBox4.Controls.Add(this.checkEdit_4시간_8시간구름떼위_양봉);
this.groupBox4.Location = new System.Drawing.Point(379, 49);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(444, 83);
this.groupBox4.TabIndex = 10;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "상위 시간 구름떼 / 볼린저 (시가 기준)";
//
// groupBox5
//
this.groupBox5.Controls.Add(this.checkEdit_종가시간판매);
this.groupBox5.Controls.Add(this.textEdit_종가시간판매);
this.groupBox5.Location = new System.Drawing.Point(19, 123);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(335, 100);
this.groupBox5.TabIndex = 11;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "데이터 변경 (봉 채우기 재필요)";
//
// checkEdit_1H
//
this.checkEdit_1H.Location = new System.Drawing.Point(6, 76);
this.checkEdit_1H.Name = "checkEdit_1H";
this.checkEdit_1H.Properties.Caption = "1H";
this.checkEdit_1H.Size = new System.Drawing.Size(43, 19);
this.checkEdit_1H.TabIndex = 9;
this.checkEdit_1H.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_4H
//
this.checkEdit_4H.Location = new System.Drawing.Point(55, 76);
this.checkEdit_4H.Name = "checkEdit_4H";
this.checkEdit_4H.Properties.Caption = "4H";
this.checkEdit_4H.Size = new System.Drawing.Size(43, 19);
this.checkEdit_4H.TabIndex = 9;
this.checkEdit_4H.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_8H
//
this.checkEdit_8H.Location = new System.Drawing.Point(104, 76);
this.checkEdit_8H.Name = "checkEdit_8H";
this.checkEdit_8H.Properties.Caption = "8H";
this.checkEdit_8H.Size = new System.Drawing.Size(43, 19);
this.checkEdit_8H.TabIndex = 9;
this.checkEdit_8H.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_12H
//
this.checkEdit_12H.Location = new System.Drawing.Point(155, 76);
this.checkEdit_12H.Name = "checkEdit_12H";
this.checkEdit_12H.Properties.Caption = "12H";
this.checkEdit_12H.Size = new System.Drawing.Size(43, 19);
this.checkEdit_12H.TabIndex = 9;
this.checkEdit_12H.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_1D
//
this.checkEdit_1D.Location = new System.Drawing.Point(6, 99);
this.checkEdit_1D.Name = "checkEdit_1D";
this.checkEdit_1D.Properties.Caption = "1D";
this.checkEdit_1D.Size = new System.Drawing.Size(43, 19);
this.checkEdit_1D.TabIndex = 9;
this.checkEdit_1D.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_15M
//
this.checkEdit_15M.Location = new System.Drawing.Point(155, 54);
this.checkEdit_15M.Name = "checkEdit_15M";
this.checkEdit_15M.Properties.Caption = "15M";
this.checkEdit_15M.Size = new System.Drawing.Size(43, 19);
this.checkEdit_15M.TabIndex = 11;
//
// checkEdit_10M
//
this.checkEdit_10M.Location = new System.Drawing.Point(104, 54);
this.checkEdit_10M.Name = "checkEdit_10M";
this.checkEdit_10M.Properties.Caption = "10M";
this.checkEdit_10M.Size = new System.Drawing.Size(43, 19);
this.checkEdit_10M.TabIndex = 12;
//
// checkEdit_5M
//
this.checkEdit_5M.Location = new System.Drawing.Point(55, 54);
this.checkEdit_5M.Name = "checkEdit_5M";
this.checkEdit_5M.Properties.Caption = "5M";
this.checkEdit_5M.Size = new System.Drawing.Size(43, 19);
this.checkEdit_5M.TabIndex = 13;
//
// checkEdit_1M
//
this.checkEdit_1M.Location = new System.Drawing.Point(6, 54);
this.checkEdit_1M.Name = "checkEdit_1M";
this.checkEdit_1M.Properties.Caption = "1M";
this.checkEdit_1M.Size = new System.Drawing.Size(43, 19);
this.checkEdit_1M.TabIndex = 14;
//
// comboBoxEdit_defaultTime
//
this.comboBoxEdit_defaultTime.Location = new System.Drawing.Point(133, 28);
this.comboBoxEdit_defaultTime.Name = "comboBoxEdit_defaultTime";
this.comboBoxEdit_defaultTime.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.comboBoxEdit_defaultTime.Size = new System.Drawing.Size(100, 20);
this.comboBoxEdit_defaultTime.TabIndex = 15;
this.comboBoxEdit_defaultTime.SelectedIndexChanged += new System.EventHandler(this.comboBoxEdit_defaultTime_SelectedIndexChanged);
//
// checkEdit_구름떼돌파몇봉이내
//
this.checkEdit_구름떼돌파몇봉이내.Location = new System.Drawing.Point(385, 138);
this.checkEdit_구름떼돌파몇봉이내.Name = "checkEdit_구름떼돌파몇봉이내";
this.checkEdit_구름떼돌파몇봉이내.Properties.Caption = "구름떼 돌파 후 몇봉 이내";
this.checkEdit_구름떼돌파몇봉이내.Size = new System.Drawing.Size(141, 19);
this.checkEdit_구름떼돌파몇봉이내.TabIndex = 12;
this.checkEdit_구름떼돌파몇봉이내.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// textEdit_구름떼돌파몇봉이내
//
this.textEdit_구름떼돌파몇봉이내.EditValue = "0";
this.textEdit_구름떼돌파몇봉이내.Location = new System.Drawing.Point(532, 137);
this.textEdit_구름떼돌파몇봉이내.Name = "textEdit_구름떼돌파몇봉이내";
this.textEdit_구름떼돌파몇봉이내.Properties.Mask.EditMask = "d";
this.textEdit_구름떼돌파몇봉이내.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
this.textEdit_구름떼돌파몇봉이내.Size = new System.Drawing.Size(42, 20);
this.textEdit_구름떼돌파몇봉이내.TabIndex = 13;
//
// checkEdit_시가볼린저40_1아래
//
this.checkEdit_시가볼린저40_1아래.Location = new System.Drawing.Point(385, 163);
this.checkEdit_시가볼린저40_1아래.Name = "checkEdit_시가볼린저40_1아래";
this.checkEdit_시가볼린저40_1아래.Properties.Caption = "시가 볼린저40 1 아래";
this.checkEdit_시가볼린저40_1아래.Size = new System.Drawing.Size(141, 19);
this.checkEdit_시가볼린저40_1아래.TabIndex = 14;
this.checkEdit_시가볼린저40_1아래.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// checkEdit_시가구름떼위
//
this.checkEdit_시가구름떼위.Location = new System.Drawing.Point(385, 188);
this.checkEdit_시가구름떼위.Name = "checkEdit_시가구름떼위";
this.checkEdit_시가구름떼위.Properties.Caption = "시가 구름 떼 위";
this.checkEdit_시가구름떼위.Size = new System.Drawing.Size(141, 19);
this.checkEdit_시가구름떼위.TabIndex = 14;
this.checkEdit_시가구름떼위.CheckedChanged += new System.EventHandler(this.checkEdit_common_CheckedChanged);
//
// TestBoardForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(853, 297);
this.ClientSize = new System.Drawing.Size(1030, 418);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.simpleButton_찬);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "TestBoardForm";
this.Text = "TestBoard";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.checkEdit_4시간_8시간구름떼위_양봉.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_4시간_8시간구름떼위.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가가볼린저401보다작음.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위에서시작.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit_종가시간판매.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_종가시간판매.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit_종목보유수별수익률계산.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit1.Properties)).EndInit();
((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.checkEdit_구매이전봉볼린저40_1이하.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_이전봉40_2볼린저이하.Properties)).EndInit();
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.checkEdit_1H.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_4H.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_8H.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_12H.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_1D.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_15M.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_10M.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_5M.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_1M.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit_defaultTime.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_구름떼돌파몇봉이내.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.textEdit_구름떼돌파몇봉이내.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가볼린저40_1아래.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.checkEdit_시가구름떼위.Properties)).EndInit();
this.ResumeLayout(false);
}
@@ -161,5 +525,33 @@ namespace Million_Hunter.HunterSubForm
private System.Windows.Forms.GroupBox groupBox3;
private DevExpress.XtraEditors.SimpleButton simpleButton_Reset;
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_종목보유수별수익률계산;
private DevExpress.XtraEditors.TextEdit textEdit_종가시간판매;
private DevExpress.XtraEditors.CheckEdit checkEdit_종가시간판매;
private DevExpress.XtraEditors.TextEdit textEdit1;
private DevExpress.XtraEditors.CheckEdit checkEdit1;
private DevExpress.XtraEditors.CheckEdit checkEdit_시가구름떼위에서시작;
private DevExpress.XtraEditors.CheckEdit checkEdit_시가가볼린저401보다작음;
private DevExpress.XtraEditors.CheckEdit checkEdit_4시간_8시간구름떼위_양봉;
private DevExpress.XtraEditors.CheckEdit checkEdit_4시간_8시간구름떼위;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.GroupBox groupBox4;
private DevExpress.XtraEditors.CheckEdit checkEdit_15M;
private DevExpress.XtraEditors.CheckEdit checkEdit_10M;
private DevExpress.XtraEditors.CheckEdit checkEdit_5M;
private DevExpress.XtraEditors.CheckEdit checkEdit_1M;
private DevExpress.XtraEditors.CheckEdit checkEdit_1D;
private DevExpress.XtraEditors.CheckEdit checkEdit_12H;
private DevExpress.XtraEditors.CheckEdit checkEdit_8H;
private DevExpress.XtraEditors.CheckEdit checkEdit_4H;
private DevExpress.XtraEditors.CheckEdit checkEdit_1H;
private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit_defaultTime;
private DevExpress.XtraEditors.CheckEdit checkEdit_구름떼돌파몇봉이내;
private DevExpress.XtraEditors.TextEdit textEdit_구름떼돌파몇봉이내;
private DevExpress.XtraEditors.CheckEdit checkEdit_시가구름떼위;
private DevExpress.XtraEditors.CheckEdit checkEdit_시가볼린저40_1아래;
}
}

View File

@@ -34,6 +34,10 @@ namespace Million_Hunter.HunterSubForm
parentForm = resultViewerForm;
analysisDatas = parentForm._analysisDatas;
// 시간 단위 가져오기
var candleTimeTypeList = Enum.GetNames(enumType: typeof(CommonProperty.MCandleTimeType));
comboBoxEdit_defaultTime.Properties.Items.AddRange(candleTimeTypeList);
comboBoxEdit_defaultTime.SelectedText = "H1";
}
@@ -80,10 +84,15 @@ namespace Million_Hunter.HunterSubForm
});
#endregion
MCandleTimeType = candleTypes.First();
/*
Enum.TryParse(comboBoxEdit_defaultTime.SelectedItem.ToString(),
out CommonProperty.MCandleTimeType mCandleTimeType);
*/
MCandleTimeType = CommonProperty.MCandleTimeType.H1;
//차트 Date Time 설정하기
var StartDateInterval = 60;
var StartDateInterval = 80 * 30;
var EndDateInterval = 100;
foreach(var analysisData in parentForm._analysisDatas)
@@ -94,6 +103,8 @@ namespace Million_Hunter.HunterSubForm
var chartStartDate = startDate;
var chartEndDate = endDate;
// Default : 1 시간
// 추가 : 4, 8,
switch (candleTypes.First())
{
case CommonProperty.MCandleTimeType.H1:
@@ -114,10 +125,10 @@ namespace Million_Hunter.HunterSubForm
chartEndDate = startDate + new TimeSpan(0, 0, EndDateInterval, 0);
break;
case CommonProperty.MCandleTimeType.M10:
case CommonProperty.MCandleTimeType.M15:
case CommonProperty.MCandleTimeType.M5:
case CommonProperty.MCandleTimeType.M3:
case CommonProperty.MCandleTimeType.M30:
case CommonProperty.MCandleTimeType.M5:
case CommonProperty.MCandleTimeType.M15:
break;
case CommonProperty.MCandleTimeType.D1:
chartStartDate = startDate - new TimeSpan(StartDateInterval, 0, 0, 0);
@@ -130,7 +141,36 @@ namespace Million_Hunter.HunterSubForm
var dic = DataManager.GetStandardData(_chartIndicatorCoditionSetups, chartStartDate, chartEndDate, analysisData.OriginalSearchResult.MarketData
, _chartIndicatorCoditionSetups, true, candleTypes);
if(analysisData.CandleDatas != null)
var dic_4 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H4);
foreach (var setup in _chartIndicatorCoditionSetups)
{
setup.excute(dic_4);
}
var dic_8 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H8);
foreach (var setup in _chartIndicatorCoditionSetups)
{
setup.excute(dic_8);
}
var dic_12 = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.H12);
foreach (var setup in _chartIndicatorCoditionSetups)
{
setup.excute(dic_12);
}
var dic_1d = DataManager.GetConvertCandleDataList(dic[CommonProperty.MCandleTimeType.H1], CommonProperty.MCandleTimeType.D1);
foreach (var setup in _chartIndicatorCoditionSetups)
{
setup.excute(dic_1d);
}
dic.Add(CommonProperty.MCandleTimeType.H4, dic_4);
dic.Add(CommonProperty.MCandleTimeType.H8, dic_8);
dic.Add(CommonProperty.MCandleTimeType.H12, dic_12);
dic.Add(CommonProperty.MCandleTimeType.D1, dic_1d);
if (analysisData.CandleDatas != null)
{
analysisData.CandleDatas.Clear();
analysisData.CandleDatas = null;
@@ -177,7 +217,6 @@ namespace Million_Hunter.HunterSubForm
public void calcurateFilter()
{
// 필터 초기화
resetFilter();
@@ -195,28 +234,9 @@ namespace Million_Hunter.HunterSubForm
var 구매이전봉 = startDate;
//차트 Date Time 설정하기
var StartDateInterval = 1;
var StartDateInterval = -1;
switch (MCandleTimeType)
{
case CommonProperty.MCandleTimeType.H1:
구매이전봉 = Convert.ToDateTime(startDate.ToString("yyyy-MM-dd HH:00")) - new TimeSpan(0, StartDateInterval, 0, 0);
break;
case CommonProperty.MCandleTimeType.H4:
구매이전봉 = Convert.ToDateTime(startDate.ToString("yyyy-MM-dd HH:00")) - new TimeSpan(0, StartDateInterval * 4, 0, 0);
break;
case CommonProperty.MCandleTimeType.M1:
break;
case CommonProperty.MCandleTimeType.M10:
case CommonProperty.MCandleTimeType.M15:
case CommonProperty.MCandleTimeType.M3:
case CommonProperty.MCandleTimeType.M30:
case CommonProperty.MCandleTimeType.M5:
break;
case CommonProperty.MCandleTimeType.D1:
구매이전봉 = Convert.ToDateTime(endDate.ToString("yyyy-MM-dd")) - new TimeSpan(StartDateInterval, 0, 0, 0);
break;
}
구매이전봉 = changeDatetimeFormat(구매이전봉, StartDateInterval);
var candleData = analysisData.CandleDatas[MCandleTimeType].Find(item => item.DateTime == 구매이전봉);
// 시간대 캔들이 없으면 결과에서 제외
@@ -264,28 +284,9 @@ namespace Million_Hunter.HunterSubForm
var 구매이전봉 = startDate;
//차트 Date Time 설정하기
var StartDateInterval = 1;
var StartDateInterval = -1;
switch (MCandleTimeType)
{
case CommonProperty.MCandleTimeType.H1:
구매이전봉 = Convert.ToDateTime(startDate.ToString("yyyy-MM-dd HH:00")) - new TimeSpan(0, StartDateInterval, 0, 0);
break;
case CommonProperty.MCandleTimeType.H4:
구매이전봉 = Convert.ToDateTime(startDate.ToString("yyyy-MM-dd HH:00")) - new TimeSpan(0, StartDateInterval * 4, 0, 0);
break;
case CommonProperty.MCandleTimeType.M1:
break;
case CommonProperty.MCandleTimeType.M10:
case CommonProperty.MCandleTimeType.M15:
case CommonProperty.MCandleTimeType.M3:
case CommonProperty.MCandleTimeType.M30:
case CommonProperty.MCandleTimeType.M5:
break;
case CommonProperty.MCandleTimeType.D1:
구매이전봉 = Convert.ToDateTime(endDate.ToString("yyyy-MM-dd")) - new TimeSpan(StartDateInterval, 0, 0, 0);
break;
}
구매이전봉 = changeDatetimeFormat(구매이전봉, StartDateInterval);
var candleData = analysisData.CandleDatas[MCandleTimeType].Find(item => item.DateTime == 구매이전봉);
// 시간대 캔들이 없으면 결과에서 제외
@@ -314,14 +315,447 @@ namespace Million_Hunter.HunterSubForm
analysisData.Inclusion = false;
}
}
else
{
}
}
}
}
parentForm.treeList_ResultData.RefreshDataSource();
parentForm.CalcurateProfitAndWinRate();
if (checkEdit_구름떼상한선하락시판매.Checked)
{
// 평균 승률 계산하기
double winRate = 0;
// 평균 수익률 계산하기
double profitRate = 0;
var count__ = 0;
var count_2 = 0;
var count_3 = 0;
foreach (var analysisData in parentForm._analysisDatas)
{
if (!analysisData.Inclusion) continue;
var startDate = changeDatetimeFormat(analysisData.StartDate, 0);
var endDate = changeDatetimeFormat(analysisData.EndDate, 0);
var candleData = analysisData.CandleDatas.First().Value.Find(item => item.DateTime > startDate && item.DateTime < endDate &&
item.IndicatorDic["Ich2695226"]?.value != null && ((IchimokData)item.IndicatorDic["Ich2695226"]).GetOverValue() > item.LowValue);
if (candleData != null)
{
var endResut = changeDatetimeFormat(candleData.DateTime, 0);
var ichValue = ((IchimokData)candleData.IndicatorDic["Ich2695226"]).GetOverValue();
if (ichValue > analysisData.BuyValue)
{
analysisData.WinFlag = true;
}
else
{
analysisData.WinFlag = false;
}
analysisData.EarningRate = analysisData.EarningRate = (-100 + (ichValue / analysisData.BuyValue) * 100);
if (analysisData.EarningRate < -4)
{
}
}
}
var allCount = parentForm._analysisDatas.Count(item => item.Inclusion == true);
winRate = winRate * 100 / allCount;
MessageBox.Show(string.Format("승률 : {0:0.00} % 수익률 : {1:0.00} % 개수 : {2}",
double.Parse(winRate.ToString()), double.Parse(profitRate.ToString()), allCount.ToString()) );
}
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);
//r Con
//inCount =
}
// 종가 판매
if (checkEdit_종가시간판매.Checked)
{
// 종가 판매 봉기준
var candleInterval = Convert.ToInt32(textEdit_종가시간판매.Text);
foreach (var analysisData in parentForm._analysisDatas)
{
var startDate = changeDatetimeFormat(analysisData.StartDate, 0);
var endDate = changeDatetimeFormat(analysisData.EndDate, 0);
var 종가판매기준시간 = changeDatetimeFormat(startDate, candleInterval);
if (analysisData.Inclusion)
{
if (changeDatetimeFormat(endDate, 0) > 종가판매기준시간)
{
var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == 종가판매기준시간);
if(data == null)
{
var date = new DateTime();
date = 종가판매기준시간;
while (data == null)
{
date = changeDatetimeFormat(date, -1);
data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == date);
}
}
// 수익률 구하기
analysisData.EarningRate = (-100 + (data.EndValue / analysisData.BuyValue) * 100);
analysisData.WinFlag = analysisData.EarningRate > 0 ? true : false;
analysisData.SellValue = data.EndValue;
}
}
continue;
}
}
if(checkEdit_시가구름떼위에서시작.Checked)
{
foreach (var analysisData in parentForm._analysisDatas)
{
var startDate = changeDatetimeFormat(analysisData.StartDate, 0);
var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == startDate);
var maxich = Math.Max(((IchimokData)data.IndicatorDic["Ich2695226"]).value, ((IchimokData)data.IndicatorDic["Ich2695226"]).value2);
if (analysisData.Inclusion)
if (maxich >= data.StartValue) analysisData.Inclusion = false;
}
}
if (checkEdit_시가가볼린저401보다작음.Checked)
{
foreach (var analysisData in parentForm._analysisDatas)
{
var startDate = changeDatetimeFormat(analysisData.StartDate, 0);
var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == startDate);
if (analysisData.Inclusion)
if (data.IndicatorDic["Bol401"].value <= data.StartValue) analysisData.Inclusion = false;
}
}
if(checkEdit_4시간_8시간구름떼위.Checked)
{
foreach (var analysisData in parentForm._analysisDatas)
{
if (!analysisData.Inclusion) continue;
var startDate = changeDatetimeFormat(analysisData.StartDate, 0);
var data = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H1].Find(item => item.DateTime == startDate);
var data4 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H4].Find(item => changeDatetimeFormat(startDate, -4) <= item.DateTime && item.DateTime <= startDate);
if (data4 == null)
{
var dateT4 = new DateTime();
dateT4 = startDate;
while (data4 == null)
{
data4 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H4].Find(item => changeDatetimeFormat(dateT4, -4) <= item.DateTime && item.DateTime <= dateT4);
dateT4 = changeDatetimeFormat(dateT4, -4);
}
}
var data8 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H8].Find(item => changeDatetimeFormat(startDate, -8) <= item.DateTime && item.DateTime <= startDate);
if (data8 == null)
{
var dateT8 = new DateTime();
dateT8 = startDate;
while (data8 == null)
{
data8 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H8].Find(item => changeDatetimeFormat(dateT8, -8) <= item.DateTime && item.DateTime <= dateT8);
dateT8 = changeDatetimeFormat(dateT8, -8);
}
}
var maxich = Math.Max(((IchimokData)data.IndicatorDic["Ich2695226"]).value, ((IchimokData)data.IndicatorDic["Ich2695226"]).value2);
var maxich4 = Math.Max(((IchimokData)data4.IndicatorDic["Ich2695226"]).value, ((IchimokData)data4.IndicatorDic["Ich2695226"]).value2);
var maxich8 = Math.Max(((IchimokData)data8.IndicatorDic["Ich2695226"]).value, ((IchimokData)data8.IndicatorDic["Ich2695226"]).value2);
if(analysisData.Inclusion)
if (maxich8 >= data8.StartValue || maxich4 >= data4.StartValue) analysisData.Inclusion = false;
}
}
if(checkEdit_4시간_8시간구름떼위_양봉.Checked)
{
foreach (var analysisData in parentForm._analysisDatas)
{
if (!analysisData.Inclusion) continue;
var startDate = changeDatetimeFormat(analysisData.StartDate, 0);
var data = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H1].Find(item => item.DateTime == startDate);
var data4 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H4].Find(item => changeDatetimeFormat(startDate, -4) <= item.DateTime && item.DateTime <= startDate);
if (data4 == null)
{
var dateT4 = new DateTime();
dateT4 = startDate;
while (data4 == null)
{
data4 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H4].Find(item => changeDatetimeFormat(dateT4, -4) <= item.DateTime && item.DateTime <= dateT4);
dateT4 = changeDatetimeFormat(dateT4, -4);
}
}
var data8 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H8].Find(item => changeDatetimeFormat(startDate, -8) <= item.DateTime && item.DateTime <= startDate);
if (data8 == null)
{
var dateT8 = new DateTime();
dateT8 = startDate;
while (data8 == null)
{
data8 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H8].Find(item => changeDatetimeFormat(dateT8, -8) <= item.DateTime && item.DateTime <= dateT8);
dateT8 = changeDatetimeFormat(dateT8, -8);
}
}
var data12 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H12].Find(item => changeDatetimeFormat(startDate, -12) <= item.DateTime && item.DateTime <= startDate);
if (data12 == null)
{
var dateT12 = new DateTime();
dateT12 = startDate;
while (data12 == null)
{
data12 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.H12].Find(item => changeDatetimeFormat(dateT12, -12) <= item.DateTime && item.DateTime <= dateT12);
dateT12 = changeDatetimeFormat(dateT12, -12);
}
}
var data24 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.D1].Find(item => changeDatetimeFormat(startDate, -24) <= item.DateTime && item.DateTime <= startDate);
if (data24 == null)
{
var dateT24 = new DateTime();
dateT24 = startDate;
while (data24 == null)
{
data24 = analysisData.CandleDatas[CommonProperty.MCandleTimeType.D1].Find(item => changeDatetimeFormat(dateT24, -24) <= item.DateTime && item.DateTime <= dateT24);
dateT24 = changeDatetimeFormat(dateT24, -24);
}
}
var maxich = Math.Max(((IchimokData)data.IndicatorDic["Ich2695226"]).value, ((IchimokData)data.IndicatorDic["Ich2695226"]).value2);
var maxich4 = Math.Max(((IchimokData)data4.IndicatorDic["Ich2695226"]).value, ((IchimokData)data4.IndicatorDic["Ich2695226"]).value2);
var maxich8 = Math.Max(((IchimokData)data8.IndicatorDic["Ich2695226"]).value, ((IchimokData)data8.IndicatorDic["Ich2695226"]).value2);
var maxich12 = Math.Max(((IchimokData)data12.IndicatorDic["Ich2695226"]).value, ((IchimokData)data12.IndicatorDic["Ich2695226"]).value2);
//var maxichD1 = Math.Max(((IchimokData)data24.IndicatorDic["Ich2695226"]).value, ((IchimokData)data24.IndicatorDic["Ich2695226"]).value2);
if (analysisData.Inclusion)
{
//if (!(maxichD1 < data24.StartValue && maxich12 < data12.StartValue && maxich8 < data8.StartValue && maxich4 < data4.StartValue
if(!(maxich12 < data12.StartValue && maxich8 < data8.StartValue && maxich4 < data4.StartValue
//&& data12.IndicatorDic["Bol401"].value < data12.StartValue
// && data8.IndicatorDic["Bol401"].value < data8.StartValue
// && data4.IndicatorDic["Bol401"].value < data4.StartValue
)) analysisData.Inclusion = false;
}
}
}
if(checkEdit_구름떼돌파몇봉이내.Checked)
{
var timeInterval = Convert.ToInt32(textEdit_구름떼돌파몇봉이내.Text);
foreach (var analysisData in parentForm._analysisDatas)
{
if (analysisData.Inclusion)
{
var 몇봉이내이전봉시간 = changeDatetimeFormat(analysisData.StartDate, -timeInterval -1);
var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == 몇봉이내이전봉시간);
if (data == null)
{
analysisData.Description += "데이터 없음" + analysisData.Description;
continue;
}
var ichData = (IchimokData)data.IndicatorDic["Ich2695226"];
if (data.HighValue < Math.Max(ichData.value2, ichData.value2))
{
analysisData.Inclusion = true;
}
else analysisData.Inclusion = false;
}
}
}
if (checkEdit_시가볼린저40_1아래.Checked)
{
foreach (var analysisData in parentForm._analysisDatas)
{
var startDate = changeDatetimeFormat(analysisData.StartDate, 0);
var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == startDate);
if (data == null)
{
analysisData.Description += "데이터 없음" + analysisData.Description;
continue;
}
if (analysisData.Inclusion)
{
if (data.StartValue < data.IndicatorDic["Bol401"].value) analysisData.Inclusion = true;
else analysisData.Inclusion = false;
}
}
}
if (checkEdit_시가구름떼위.Checked)
{
foreach (var analysisData in parentForm._analysisDatas)
{
var startDate = changeDatetimeFormat(analysisData.StartDate, 0);
var data = analysisData.CandleDatas.First().Value.Find(item => item.DateTime == startDate);
if (data == null)
{
analysisData.Description += "데이터 없음" + analysisData.Description;
continue;
}
if (analysisData.Inclusion)
{
var ichData = (IchimokData)data.IndicatorDic["Ich2695226"];
if (data.StartValue > Math.Max(ichData.value, ichData.value2)) analysisData.Inclusion = true;
else analysisData.Inclusion = false;
}
}
}
parentForm.CalcurateProfitAndWinRate();
parentForm.treeList_ResultData.RefreshDataSource();
}
/// <summary>
/// 시간/분/일 등의 Datetime 과 비교하기 위한 Format String 변경 함수
/// </summary>
/// <param name="dateTime"></param>
/// <param name="StartDateInterval"></param>
/// <returns></returns>
public DateTime changeDatetimeFormat(DateTime dateTime, int StartDateInterval)
{
var _dateTime = dateTime;
switch (MCandleTimeType)
{
case CommonProperty.MCandleTimeType.H1:
_dateTime = Convert.ToDateTime(dateTime.ToString("yyyy-MM-dd HH:00")) + new TimeSpan(0, StartDateInterval, 0, 0);
break;
case CommonProperty.MCandleTimeType.H4:
_dateTime = Convert.ToDateTime(dateTime.ToString("yyyy-MM-dd HH:00")) + new TimeSpan(0, StartDateInterval * 4, 0, 0);
break;
case CommonProperty.MCandleTimeType.M1:
break;
case CommonProperty.MCandleTimeType.M10:
case CommonProperty.MCandleTimeType.M5:
case CommonProperty.MCandleTimeType.M3:
case CommonProperty.MCandleTimeType.M30:
case CommonProperty.MCandleTimeType.M15:
break;
case CommonProperty.MCandleTimeType.D1:
_dateTime = Convert.ToDateTime(dateTime.ToString("yyyy-MM-dd")) + new TimeSpan(StartDateInterval, 0, 0, 0);
break;
}
return _dateTime;
}
/// <summary>
@@ -422,5 +856,12 @@ namespace Million_Hunter.HunterSubForm
aver.ToString();
}
private void comboBoxEdit_defaultTime_SelectedIndexChanged(object sender, EventArgs e)
{
Enum.TryParse(comboBoxEdit_defaultTime.SelectedItem.ToString(),
out CommonProperty.MCandleTimeType mCandleTimeType);
}
}
}

View File

@@ -153,6 +153,7 @@
<EmbeddedResource Include="HunterSubForm\TestBoardForm.resx">
<DependentUpon>TestBoardForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\licenses.licx" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>

View File

@@ -197,7 +197,7 @@ namespace Million_Prototype
{
if (firstFlag == 0)
{
realTimeMsg = new RealtimeDataSettingManager(null, BuyerMode.BuyerTicker,PaymentType.KRW);
dataList = realTimeMsg.GetRealTimeCandleData(candleTypeList,DateTime.Now, DateTime.Now, 200);
foreach (var item in realTimeMsg.coinFullNameList)
{
@@ -216,7 +216,7 @@ namespace Million_Prototype
if (DateTime.Now.Minute == 0 && saveFlag)
{
realTimeMsg.ClearTicker();
if (resultDataList.Count > 0)
{

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>

View File

@@ -39,6 +39,7 @@
this.textBox_log.Location = new System.Drawing.Point(12, 12);
this.textBox_log.Multiline = true;
this.textBox_log.Name = "textBox_log";
this.textBox_log.ReadOnly = true;
this.textBox_log.Size = new System.Drawing.Size(284, 579);
this.textBox_log.TabIndex = 0;
//

View File

@@ -1,14 +1,8 @@
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
@@ -28,7 +22,7 @@ namespace Million_Update_Server
private void writeLog(string text)
{
log = text + log;
log = text+"\r\n" + log;
Invoke(new MethodInvoker(delegate ()
{
@@ -72,43 +66,18 @@ namespace Million_Update_Server
try
{
// 수신한 데이터를 저장할 버퍼
byte[] messageBuffer = new byte[4096];
// 받은 데이터의 총 길이
int bytesRead;
while (true)
string data = "";
do
{
bytesRead = 0;
try
{
// 클라이언트에서 데이터 수신 대기
bytesRead = clientStream.Read(messageBuffer, 0, 4096);
}
catch
{
// 연결이 끊어졌을 경우 예외 발생
break;
}
byte[] buffer = new byte[tcpClient.ReceiveBufferSize];
int bytesRead = clientStream.Read(buffer, 0, buffer.Length);
data += Encoding.UTF8.GetString(buffer, 0, bytesRead);
} while (clientStream.DataAvailable);
// 수신한 데이터가 없을 경우
if (bytesRead == 0)
{
// 연결이 끊어졌음을 알리기 위해 예외 발생
throw new Exception("연결이 끊어졌습니다.");
}
//var receivedPeople = JsonConvert.DeserializeObject<Million.SaveData.SavedResultData>(data);
// 수신한 데이터를 문자열로 변환
string message = Encoding.UTF8.GetString(messageBuffer, 0, bytesRead);
// 문자열을 Person 객체로 역직렬화
/*Person person = JsonConvert.DeserializeObject<Person>(message);
// 수신한 Person 객체를 출력
Console.WriteLine("수신한 Person 객체:");
Console.WriteLine("이름: " + person.Name);
Console.WriteLine("나이: " + person.Age);*/
}
}
catch (Exception ex)
{

View File

@@ -8,13 +8,29 @@
<OutputType>WinExe</OutputType>
<RootNamespace>Million_Update_Server</RootNamespace>
<AssemblyName>Million Update Server</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@@ -68,6 +84,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
@@ -83,5 +100,23 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Million\Million Core.csproj">
<Project>{10ef08cb-bf38-4882-a92a-30db34e8e8bd}</Project>
<Name>Million Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8%28x86 및 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>ko-KR</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

View File

@@ -8,62 +8,54 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace Million_Update_Server.Properties
{
namespace Million_Update_Server.Properties {
using System;
/// <summary>
/// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다.
/// </summary>
// 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder
// 클래스에서 자동으로 생성되었습니다.
// 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여
// ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
// 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을
// 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Million_Update_Server.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을
/// 재정의합니다.
/// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대한 현재 스레드의 CurrentUICulture
/// 속성을 재정의합니다.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}

View File

@@ -1,28 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// 이 코드는 도구를 사용하여 생성되었습니다.
// 런타임 버전:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
// 이러한 변경 내용이 손실됩니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Million_Update_Server.Properties
{
namespace Million_Update_Server.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
public static Settings Default {
get {
return defaultInstance;
}
}

View File

@@ -137,14 +137,23 @@ namespace Million
public enum MCandleTimeType
{
M1 = 1,
M2 = 2,
M3 = 3,
M4 = 4,
M5 = 5,
M6 = 6,
M10 = 10,
M15 = 15,
M20 = 20,
M30 = 30,
H1 = 60,
H2 = 120,
H3 = 180,
H4 = 240,
D1 = 1000,
H6 = 360,
H8 = 480,
H12 = 720,
D1 = 1440,
W1 = 10000,
MT1 = 100000
}
@@ -351,8 +360,7 @@ namespace Million
public enum BuyerMode
{
BuyerRealtime,
Buyer,
BuyerTicker,
Buyer,
HunterRealtime
}
@@ -360,7 +368,7 @@ namespace Million
#region Realtime Hunter Flag
public static bool RealtimeHunterMode = false;
public static bool StarValueLowOverlapUp = false;
public static bool StarValueLowBuyValueUp = false;
#endregion
#region Realtime 관련 Sub data 사용하는 부분예외처리

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; }

View File

@@ -19,6 +19,8 @@ namespace Million.Data.SaveData
public bool UpperMainIndicatorFlag { get; set; }
public bool StarValueLowOverlapUp { get; set; }
public bool IncludeClearIndicator { get; set; }
public bool DownBeforeValueFlag { get; set; }

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Million.Data.Upbit
{
/// <summary>
/// 실시간 체결량 관련 Class
/// </summary>
public class RealtimeConclusion
{
public string type { get; set; }
public string code { get; set; }
public long timestamp { get; set; }
public string trade_date { get; set; }
public string trade_time { get; set; }
public long trade_timestamp { get; set; }
public double trade_price { get; set; }
public double trade_volume { get; set; }
public string ask_bid { get; set; }
public double prev_closing_price { get; set; }
public string change { get; set; }
public double change_price { get; set; }
public long sequential_id { get; set; }
public string stream_type { get; set; }
public DateTime TradeDateTime { get; set; }
public RealtimeConclusion Clone()
{
var dt = new DateTime(1970, 1, 1);
dt = dt.AddMilliseconds(trade_timestamp);
dt = dt.AddHours(9);
return new RealtimeConclusion()
{
type = type,
code = code,
timestamp= timestamp,
trade_date = trade_date,
trade_time = trade_time,
trade_timestamp = trade_timestamp,
trade_price = trade_price,
trade_volume = trade_volume,
ask_bid = ask_bid,
prev_closing_price = prev_closing_price,
change = change,
change_price = change_price,
sequential_id = sequential_id,
stream_type = stream_type,
TradeDateTime = dt
};
}
}
}

View File

@@ -220,20 +220,20 @@ namespace Million.DbManagement
if (candleTimeType == MCandleTimeType.M1 || candleTimeType == MCandleTimeType.M3 || candleTimeType == MCandleTimeType.M5 ||
candleTimeType == MCandleTimeType.M10 | candleTimeType == MCandleTimeType.M15|| candleTimeType == MCandleTimeType.M30)
startDate = startDate.AddMinutes(-72 * (int)candleTimeType);
startDate = startDate.AddMinutes(-80 * (int)candleTimeType);
else if(candleTimeType == MCandleTimeType.H1 | candleTimeType == MCandleTimeType.H4)
{
var val = 1;
if (candleTimeType == MCandleTimeType.H4)
val = 4;
startDate = startDate.AddHours(-72 * val);
startDate = startDate.AddHours(-80 * val);
}
else if(candleTimeType == MCandleTimeType.D1)
startDate = startDate.AddDays(-72 * 1);
startDate = startDate.AddDays(-80 * 1);
else if (candleTimeType == MCandleTimeType.W1)
startDate = startDate.AddDays(-72 * 7);
startDate = startDate.AddDays(-80 * 7);
else if (candleTimeType == MCandleTimeType.MT1)
startDate = startDate.AddMonths(-72);
startDate = startDate.AddMonths(-80);
var sqlQuery = string.Format(@"SELECT [DateTime],[StartValue],[EndValue],[HighValue],[LowValue],[MoneyVolume],[CandleTimeType] FROM [{0}] WHERE [DateTime] >= '{1}' AND [DateTime] < '{2}' AND [CandleTimeType] = {3} ORDER BY [DateTime] ASC", marketData.CoinFullName, startDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"), (int)candleTimeType);
@@ -265,20 +265,20 @@ namespace Million.DbManagement
if (candleTimeType == MCandleTimeType.M1 || candleTimeType == MCandleTimeType.M3 || candleTimeType == MCandleTimeType.M5 ||
candleTimeType == MCandleTimeType.M10 | candleTimeType == MCandleTimeType.M15 || candleTimeType == MCandleTimeType.M30)
startDate = startDate.AddMinutes(-72 * (int)candleTimeType);
startDate = startDate.AddMinutes(-80 * (int)candleTimeType);
else if (candleTimeType == MCandleTimeType.H1 | candleTimeType == MCandleTimeType.H4)
{
var val = 1;
if (candleTimeType == MCandleTimeType.H4)
val = 4;
startDate = startDate.AddHours(-72 * val);
startDate = startDate.AddHours(-80 * val);
}
else if (candleTimeType == MCandleTimeType.D1)
startDate = startDate.AddDays(-72 * 1);
startDate = startDate.AddDays(-80 * 1);
else if (candleTimeType == MCandleTimeType.W1)
startDate = startDate.AddDays(-72 * 7);
startDate = startDate.AddDays(-80 * 7);
else if (candleTimeType == MCandleTimeType.MT1)
startDate = startDate.AddMonths(-72);
startDate = startDate.AddMonths(-80);
var sqlQuery = string.Format(@"SELECT TOP({0}) [DateTime],[StartValue],[EndValue],[HighValue],[LowValue],[MoneyVolume],[CandleTimeType] FROM [{1}] WHERE [DateTime] >= '{2}' AND [CandleTimeType] = {3} ORDER BY [DateTime] ASC", count, marketData.CoinFullName, startDate.ToString("yyyy-MM-dd HH:mm:ss"), ((int)candleTimeType).ToString());

View File

@@ -1,6 +1,9 @@
using Million.Data;
using Million.Data.Upbit;
using Million.DbManagement;
using Million.IndicatorConditionSetup;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -168,7 +171,7 @@ namespace Million.Manager
{
var recentlyList = orderList.Where(t => t.RecentlyDataFlag).ToList();
if (recentlyList.Count > 0)
returnData = recentlyList[0];
returnData = recentlyList[0];
}
else
{
@@ -219,5 +222,284 @@ namespace Million.Manager
result.SellCount = sellCandleData.BuyCount;
return result;
}
private static CandleData CreateCandleData( CandleData candle,int timeFlagValue, string timeFlag)
{
var firstData = candle;
if (timeFlag == "minute")
{
var minute = firstData.DateTime.Minute / timeFlagValue * timeFlagValue;
return new CandleData()
{
DateTime = new DateTime(firstData.DateTime.Year, firstData.DateTime.Month, firstData.DateTime.Day, firstData.DateTime.Hour, minute, 0),
HighValue = firstData.HighValue,
StartValue = firstData.StartValue,
LowValue = firstData.LowValue,
EndValue = firstData.EndValue,
RecentlyDataFlag = true,
MoneyVolume = firstData.MoneyVolume
};
}
else if (timeFlag == "hour")
{
var hour = firstData.DateTime.Hour / timeFlagValue * timeFlagValue;
return new CandleData()
{
DateTime = new DateTime(firstData.DateTime.Year, firstData.DateTime.Month, firstData.DateTime.Day, hour, 0, 0),
HighValue = firstData.HighValue,
StartValue = firstData.StartValue,
LowValue = firstData.LowValue,
RecentlyDataFlag = true,
EndValue = firstData.EndValue,
MoneyVolume = firstData.MoneyVolume
};
}
else //if (timeFlag == "day")
{
//var hour = firstData.DateTime.Day / timeFlagValue * timeFlagValue;
return new CandleData()
{
DateTime = new DateTime(firstData.DateTime.Year, firstData.DateTime.Month, firstData.DateTime.Day, 0, 0, 0),
HighValue = firstData.HighValue,
StartValue = firstData.StartValue,
LowValue = firstData.LowValue,
RecentlyDataFlag = true,
EndValue = firstData.EndValue,
MoneyVolume = firstData.MoneyVolume
};
}
}
/// <summary>
/// CandleList 만들어주는거
/// </summary>
/// <param name="currentCandleList"></param>
/// <param name="mCandleTimeType"></param>
/// <returns></returns>
public static List<CandleData> GetConvertCandleDataList(List<CandleData> currentCandleList, MCandleTimeType mCandleTimeType) {
var returnData = new List<CandleData>();
var timeFlag = "minute";
var timeFlagValue = 0;
if(mCandleTimeType < MCandleTimeType.H1)
{
timeFlagValue = (int)mCandleTimeType;
}
else if(mCandleTimeType < MCandleTimeType.D1)
{
timeFlag = "hour";
timeFlagValue = ((int) mCandleTimeType) / 60;
}
else if(mCandleTimeType < MCandleTimeType.W1)
{
timeFlag = "day";
timeFlagValue = 1;
}
if (currentCandleList == null || currentCandleList.Count == 0)
return null;
foreach (var item in currentCandleList)
{
var recentlyData = returnData.LastOrDefault();
if(recentlyData == null)
{
returnData.Add(CreateCandleData(item, timeFlagValue, timeFlag));
continue;
}
var coverTime = recentlyData.DateTime;
if (timeFlag == "minute")
{
coverTime = coverTime.AddMinutes(timeFlagValue);
}
else if (timeFlag == "hour")
{
coverTime = coverTime.AddHours(timeFlagValue);
}
else if (timeFlag == "day")
{
coverTime = coverTime.AddDays(timeFlagValue);
}
if (!(recentlyData.DateTime < item.DateTime && item.DateTime < coverTime))
{
returnData.Add(CreateCandleData(item, timeFlagValue, timeFlag));
continue;
}
recentlyData.HighValue = recentlyData.HighValue < item.HighValue ? item.HighValue : recentlyData.HighValue;
recentlyData.LowValue = recentlyData.LowValue < item.LowValue ? recentlyData.LowValue : item.LowValue;
recentlyData.EndValue = item.EndValue;
recentlyData.MoneyVolume += item.MoneyVolume;
recentlyData.RecentlyDataFlag = true;
}
return returnData;
}
/// <summary>
/// 최근 데이터 업데이트 하는 로직
/// </summary>
/// <param name="candleData"></param>
/// <param name="recentlyData"></param>
/// <param name="mCandleTimeType"></param>
/// <param name="newFlag"></param>
/// <returns></returns>
public static CandleData GetRecentlyCandleData(CandleData candleData, CandleData recentlyData, MCandleTimeType mCandleTimeType, ref bool newFlag)
{
var timeFlag = "minute";
var timeFlagValue = 0;
if (mCandleTimeType < MCandleTimeType.H1)
{
timeFlagValue = (int)mCandleTimeType;
}
else if (mCandleTimeType < MCandleTimeType.D1)
{
timeFlag = "hour";
timeFlagValue = ((int)mCandleTimeType) / 60;
}
else if(mCandleTimeType < MCandleTimeType.W1)
{
timeFlag = "day";
timeFlagValue = 1;
}
var flag = false;
if (recentlyData != null)
{
if (timeFlag == "minute")
{
if (candleData.DateTime.Minute % timeFlagValue == 0)
{
if (recentlyData.DateTime.Minute != candleData.DateTime.Minute)
flag = true;
}
}
else if (timeFlag == "hour")
{
if (candleData.DateTime.Hour % timeFlagValue == 1)
{
if (recentlyData.DateTime.Hour != candleData.DateTime.Hour)
flag = true;
}
}
else if(timeFlag == "day")
{
if (recentlyData.DateTime.Day != candleData.DateTime.Day)
flag = true;
}
}
//새로 생성
if (flag)
{
newFlag = true;
var candle = new CandleData();
candle.CandleTimeType = (int)mCandleTimeType;
candle.StartValue = candleData.StartValue;
candle.HighValue = candleData.HighValue;
candle.LowValue = candleData.LowValue;
candle.RecentlyDataFlag = true;
candle.EndValue = candleData.EndValue;
candle.MoneyVolume = candleData.MoneyVolume;
if (timeFlag == "minute")
{
var date = recentlyData.DateTime.AddMinutes((int)mCandleTimeType);
date = date.AddSeconds(-1 * date.Second);
candle.DateTime = date;
}
else if (timeFlag == "hour")
{
var date = recentlyData.DateTime.AddHours((int)mCandleTimeType / 60);
date = date.AddMinutes(-1 * date.Minute);
date = date.AddSeconds(-1 * date.Second);
candle.DateTime = date;
}
else if (timeFlag == "day")
{
var date = recentlyData.DateTime.AddDays(1);
date = date.AddHours(-1 * date.Hour);
date = date.AddMinutes(-1 * date.Minute);
date = date.AddSeconds(-1 * date.Second);
candle.DateTime = date;
}
return candle;
}
//기존 데이터 엎어쓰기
else
{
recentlyData.HighValue = recentlyData.HighValue < candleData.HighValue ? candleData.HighValue : recentlyData.HighValue;
recentlyData.LowValue = recentlyData.LowValue < candleData.LowValue ? recentlyData.LowValue : candleData.LowValue;
recentlyData.EndValue = candleData.EndValue;
recentlyData.RecentlyDataFlag = true;
recentlyData.MoneyVolume += candleData.MoneyVolume;
return recentlyData;
}
}
/// <summary>
/// 실시간 체결 데이터 1분봉 처리
/// </summary>
/// <param name="realtimeConclusions"></param>
/// <returns></returns>
public static List<CandleData> GetOneMinuteCandleDataFromConclusionList(List<RealtimeConclusion> realtimeConclusions)
{
var returnData = new List<CandleData>();
var dateTimeList = realtimeConclusions.Select(t => t.TradeDateTime.Minute).Distinct().ToList();
foreach (var item in dateTimeList)
{
var list = realtimeConclusions.Where(t => t.TradeDateTime.Minute == item).ToList();
if (list.Count > 0)
{
var valueList = list.Select(t => t.trade_price).ToList();
var startValue = list[0].trade_price;
var endValue = list[list.Count - 1].trade_price;
var highValue = valueList.Max();
var lowValue = valueList.Min();
var candle = new CandleData();
candle.DateTime = list[0].TradeDateTime;
candle.DateTime = candle.DateTime.AddSeconds(candle.DateTime.Second * -1);
candle.CandleTimeType = 1;
candle.StartValue = startValue;
candle.HighValue = highValue;
candle.LowValue = lowValue;
candle.RecentlyDataFlag = true;
candle.EndValue = endValue;
candle.MoneyVolume = list.Select(t => t.trade_volume).Sum();
returnData.Add(candle);
}
}
return returnData;
}
/// <summary>
/// Json 검사
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool ValidateJSON(string s)
{
try
{
JToken.Parse(s);
return true;
}
catch (JsonReaderException)
{
return false;
}
}
}
}

View File

@@ -2,12 +2,14 @@
using Million.Data.Upbit;
using Million.DbManagement;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static Million.CommonProperty;
namespace Million.Manager
{
@@ -15,34 +17,25 @@ namespace Million.Manager
/// Data Setting하는 Manager Class
/// </summary>
public class RealtimeDataSettingManager
{
/// <summary>
/// Ticker에 들어갈 데이터
/// </summary>
public List<Ticker> tickerList = new List<Ticker>();
/// <summary>
/// Buyer Ticker모드에서 사용할 전체 Tick List
/// </summary>
public List<Ticker> totalTickerList = new List<Ticker>();
{
public List<RealtimeConclusion> realtimeConclusions = new List<RealtimeConclusion>();
private object obj = new object();
public List<string> coinFullNameList = null;
public PaymentType buyType = PaymentType.KRW;
public CommonProperty.PaymentType buyType = CommonProperty.PaymentType.KRW;
public DateTime basicDateTime { get; set; }
public BuyerMode buyerMode;
public CommonProperty.BuyerMode buyerMode;
public DateTime startDateTime { get; set; }
public DateTime endDateTime { get; set; }
public System.Threading.Timer timer = null;
public TimerCallback tc = null;
public bool flag = true;
/// <summary>
/// Websocket 관련 데이터 처리
/// </summary>
public bool Flag { get; set; } = true;
/// <summary>
/// 생성자
/// </summary>
public RealtimeDataSettingManager(List<string> coinFullNameList, BuyerMode buyerMode, PaymentType buyType, string tableName = "Upbit")
public RealtimeDataSettingManager(List<string> coinFullNameList, CommonProperty.BuyerMode buyerMode, CommonProperty.PaymentType buyType, string tableName = "Upbit")
{
this.buyType = buyType;
this.buyerMode = buyerMode;
@@ -62,21 +55,23 @@ namespace Million.Manager
//TODO Market ignore 처리 필요 -> 임시로 비트토랜트만 삭제
this.coinFullNameList.Remove("KRW-BTT");
if (CommonProperty.selectedMarketOfPlaceList != null)
CommonProperty.selectedMarketOfPlaceList.Remove(selectedMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == "KRW-BTT"));
CommonProperty.selectedMarketOfPlaceList.Remove(CommonProperty.selectedMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == "KRW-BTT"));
if (CommonProperty.recentlyMarketOfPlaceList != null)
CommonProperty.recentlyMarketOfPlaceList.Remove(recentlyMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == "KRW-BTT"));
CommonProperty.recentlyMarketOfPlaceList.Remove(CommonProperty.recentlyMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == "KRW-BTT"));
}
/// <summary>
/// 실시간 데이터 가져오는 함수(Ticker와 CandleDataList두개를 Return 할 수 있도록 구성)
/// 실시간 데이터 가져오는 함수(Ticker와 CandleDataList두개를 Return 할 수 있도록 구성) => Ticker 에서 실시간 체결 데이터로 이전
/// </summary>
/// <param name="candleDatas"></param>
/// <param name="coinFullNameList"></param>
/// <param name="tableName"></param>
/// <returns></returns>
public List<Ticker> GetRecentlyCandleData()
public List<RealtimeConclusion> GetRecentlyCandleData()
{
return CommonProperty.UpbitApi.GetTickerList(coinFullNameList);
var returnData = new List<RealtimeConclusion>();
return returnData;
}
/// <summary>
@@ -86,16 +81,14 @@ namespace Million.Manager
/// <param name="coinFullNameList"></param>
/// <param name="tableName"></param>
/// <returns></returns>
public List<CandleDataList> GetBasicDataSetting(MCandleTimeType timeType, DateTime basicDateTime, int count = 200)
public List<CandleDataList> GetBasicDataSetting(CommonProperty.MCandleTimeType timeType, DateTime basicDateTime, int count = 200)
{
var returnData = new List<CandleDataList>();
var resultList = new List<CandleData>();
foreach (var item in coinFullNameList)
{
var val = new CandleDataList();
val.ConGoodsData = selectedMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == item);
val.ConGoodsData = CommonProperty.selectedMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == item);
val.CandleDataLists_Im = CommonProperty.UpbitApi.GetCandleStics(item, timeType, basicDateTime, count).OrderBy(t => t.DateTime).ToList();
returnData.Add(val);
Thread.Sleep(400);
@@ -103,34 +96,7 @@ namespace Million.Manager
return returnData;
}
public void StartGetRealTimeTicker(object state, int duTime = 0, int period = 50)
{
if (this.timer != null)
{
flag = false;
this.timer.Dispose();
this.timer = null;
}
this.tc = new TimerCallback(TimerEvent); // 이벤트 발생 처리 루틴
//0.5초 마다 쌓는거 진행 -> DB데이터 가지고와서 부터 데이터 처리
this.timer = new System.Threading.Timer(tc, null, 0, 500);
flag = true;
}
public void EndRealTimeTicker()
{
flag = false;
if (timer != null)
{
this.timer.Dispose();
this.timer = null;
}
}
/// <summary>
/// 실시간 데이터 가져오는 함수(Buyer에서 시작과 동시에 호출되는 함수)
@@ -139,22 +105,14 @@ namespace Million.Manager
/// <param name="type"></param>
/// <param name="count"></param>
/// <returns></returns>
public Dictionary<MCandleTimeType, List<CandleDataList>> GetRealTimeCandleData(List<MCandleTimeType> types,DateTime startDate, DateTime endDate, int count = 200)
public Dictionary<CommonProperty.MCandleTimeType, List<CandleDataList>> GetRealTimeCandleData(List<CommonProperty.MCandleTimeType> types,DateTime startDate, DateTime endDate, int count = 200)
{
//여기는 한번만 동작하므로 RealtimeConclusion 처리 해야함
var thread = new Thread(new ThreadStart(ThreadEventAsync));
thread.Start();
var data = new Dictionary<MCandleTimeType, List<CandleDataList>>();
if (this.buyerMode != BuyerMode.BuyerTicker)
{
StartGetRealTimeTicker(null);
}
else
{
startDateTime = startDate;
endDateTime = endDate;
GetAllTickerDataList();
}
var data = new Dictionary<CommonProperty.MCandleTimeType, List<CandleDataList>>();
foreach (var type in types)
{
data[type] = GetBasicDataSetting(type, startDate, count);
@@ -163,23 +121,6 @@ namespace Million.Manager
return ProcessRecentlyCandleDatas(data, types);
}
/// <summary>
/// 전체 Ticker Data List가져오는 함수
/// </summary>
private void GetAllTickerDataList()
{
var tickerDickList = DBConnection.QueryGetExecuter_VerifyTickerData(startDateTime, endDateTime);
tickerDickList = tickerDickList.OrderBy(t => t["DateTime"]?.ToString()).ToList();
foreach (var item in tickerDickList)
{
var tick = new Ticker();
tick.DateTime = Convert.ToDateTime(item["DateTime"]?.ToString());
double.TryParse(item["EndValue"]?.ToString(), out double val);
tick.TradePrice = val;
tick.CoinFullName = item["CoinFullName"]?.ToString();
totalTickerList.Add(tick);
}
}
/// <summary>
@@ -188,18 +129,24 @@ namespace Million.Manager
/// <param name="candleDatas"></param>
/// <param name="tickers"></param>
/// <returns></returns>
public Dictionary<MCandleTimeType, List<CandleDataList>> ProcessRecentlyCandleDatas(Dictionary<MCandleTimeType, List<CandleDataList>> candleDatas, List<MCandleTimeType> types)
public Dictionary<CommonProperty.MCandleTimeType, List<CandleDataList>> ProcessRecentlyCandleDatas(Dictionary<CommonProperty.MCandleTimeType, List<CandleDataList>> candleDatas, List<CommonProperty.MCandleTimeType> types)
{
if(buyerMode == BuyerMode.BuyerTicker)
var cloneRealtimeConclusion = new List<RealtimeConclusion>();
lock (obj)
{
tickerList.Clear();
if (totalTickerList.Count < coinFullNameList.Count) return null;
foreach (var item in coinFullNameList)
try
{
var tick = totalTickerList.FirstOrDefault(t => t.CoinFullName == item);
tickerList.Add(tick);
totalTickerList.Remove(tick);
}
foreach (var item in realtimeConclusions)
{
cloneRealtimeConclusion.Add(item.Clone());
}
realtimeConclusions.Clear();
}
catch (Exception e)
{
LogManager.WriteLog(e.Message);
}
}
foreach (var type in types)
@@ -207,253 +154,121 @@ namespace Million.Manager
var candleList = candleDatas[type];
//Parallel.ForEach(candleList, item =>
//{
var tickList = new List<Ticker>();
var cloneTickList = new List<Ticker>();
lock (obj)
{
try
{
foreach (var item in tickerList)
{
cloneTickList.Add(item.Clone());
}
}
catch (Exception e)
{
LogManager.WriteLog(e.Message);
}
}
var list = new List<RealtimeConclusion>();
foreach (var item in candleList)
{
if (item.CandleDataLists_Im.Count > 0)
basicDateTime = item.CandleDataLists_Im.Select(t => t.DateTime).Max();
//if (item.CandleDataLists_Im.Count > 0)
// basicDateTime = item.CandleDataLists_Im.Select(t => t.DateTime).Max();
var coinFullName = item.ConGoodsData.CoinFullName;
tickList = cloneTickList.Where(t => t.CoinFullName == coinFullName).OrderBy(t=>t.DateTime).ToList();
list = cloneRealtimeConclusion.Where(t => t.code == coinFullName).OrderBy(t=>t.TradeDateTime).ToList();
// 호출 당시 시, 분, 초
var callH = basicDateTime.Hour;
var callM = basicDateTime.Minute;
var callS = basicDateTime.Second;
try
#region 여러 Type 다 호환 되도록 새로 구성
/*
* 1. Tick -> 1분봉으로 모두 변환(시가는 제일 작은거로 처리
* 2. 기존에 가지고 있는 봉 마지막꺼를 포함한 모든 데이터를 가지고 GetConvertCandleDataList로 처리
* 3. 마지막 봉삭제 후 모두 Addrange
* 4. 이후 300개 이상일 경우 삭제 처리
*/
var returnList = DataManager.GetOneMinuteCandleDataFromConclusionList(list);
if(item.CandleDataLists_Im.Count > 0)
{
if (type == MCandleTimeType.M1)
{
var equalMinuteList = tickList.Where(t => t.DateTime.Minute == callM).ToList();
//해당 분 고가
if (equalMinuteList.Count != 0)
{
var equalListM = equalMinuteList.Select(t => t.TradePrice).ToList();
double equalListMax = 0;
if (equalListM.Count != 0)
{
equalListMax = equalListM.Max();
}
//해당 분 저가
var equalListL = equalMinuteList.Select(t => t.TradePrice).ToList();
double equalListMin = 0;
if (equalListL.Count != 0)
{
equalListMin = equalListL.Min();
}
if (item.CandleDataLists_Im.Count != 0)
{
if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue < equalListMax && equalListMax != 0)
item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue = equalListMax;
if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue > equalListMin && equalListMin != 0)
item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue = equalListMin;
item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].RecentlyDataFlag = true;
item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].EndValue = equalMinuteList[equalMinuteList.Count - 1].TradePrice;
}
else
{
var candle = new CandleData();
candle.CandleTimeType = (int)MCandleTimeType.M1;
candle.StartValue = equalMinuteList[0].TradePrice;
candle.HighValue = equalListMax;
candle.LowValue = equalListMin;
candle.RecentlyDataFlag = true;
candle.EndValue = equalMinuteList[equalMinuteList.Count - 1].TradePrice;
var date = basicDateTime.AddMinutes(1);
date = date.AddSeconds(-1 * callS);
candle.DateTime = date;
if (item.CandleDataLists_Im.Count > 300)
item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 300);
item.CandleDataLists_Im.Add(candle);
}
}
var list = tickList.Where(t => t.DateTime > basicDateTime && t.DateTime.Minute != basicDateTime.Minute).ToList();
if (list.Count > 0)
{
// 데이터 가져올떄 1분 이상 걸릴 시 처리할 데이터
var minList = list.Select(t => t.DateTime.Minute).Distinct().ToList();
minList.Sort();
foreach (var min in minList)
{
var equalList = list.Where(t => t.DateTime.Minute == min).OrderBy(t => t.DateTime).ToList();
//해당 분 고가
var max = equalList.Select(t => t.TradePrice).ToList().Max();
//해당 분 저가
var low = equalList.Select(t => t.TradePrice).ToList().Min();
var candle = new CandleData();
candle.CandleTimeType = (int)MCandleTimeType.M1;
candle.StartValue = equalList[0].TradePrice;
candle.HighValue = max;
candle.LowValue = low;
candle.RecentlyDataFlag = true;
candle.EndValue = equalList[equalList.Count - 1].TradePrice;
var intervalMin = min - callM;
var date = basicDateTime.AddMinutes(intervalMin);
if(intervalMin < 0) date = date.AddHours(1);
date = date.AddSeconds(-1 * callS);
candle.DateTime = date;
if (item.CandleDataLists_Im.Count > 300)
item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 300);
item.CandleDataLists_Im.Add(candle);
}
}
}
else if (type == MCandleTimeType.H1)
{
var equalHourList = tickList.Where(t => t.DateTime.Hour == callH).ToList();
if (equalHourList.Count != 0)
{
var equalListM = equalHourList.Select(t => t.TradePrice).ToList();
double equalListMax = 0;
if (equalListM.Count != 0)
{
equalListMax = equalListM.Max();
}
//해당 분 저가
var equalListL = equalHourList.Select(t => t.TradePrice).ToList();
double equalListMin = 0;
if (equalListL.Count != 0)
{
equalListMin = equalListL.Min();
}
if (item.CandleDataLists_Im.Count > 0)
{
if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue < equalListMax && equalListMax != 0)
item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].HighValue = equalListMax;
if (item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue > equalListMin && equalListMin != 0)
item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].LowValue = equalListMin;
item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].RecentlyDataFlag = true;
item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1].EndValue = equalHourList[equalHourList.Count - 1].TradePrice;
}
else
{
var candle = new CandleData();
candle.CandleTimeType = (int)MCandleTimeType.H1;
candle.StartValue = equalHourList[0].TradePrice;
candle.HighValue = equalListMax;
candle.LowValue = equalListMin;
candle.RecentlyDataFlag = true;
candle.EndValue = equalHourList[equalHourList.Count - 1].TradePrice;
var date = basicDateTime.AddHours(1);
date = date.AddMinutes(-1 * callM);
date = date.AddSeconds(-1 * callS);
candle.DateTime = date;
if (item.CandleDataLists_Im.Count > 300)
item.CandleDataLists_Im.RemoveRange(0, 100);
item.CandleDataLists_Im.Add(candle);
}
}
var list = tickList.Where(t => t.DateTime > basicDateTime && t.DateTime.Hour != basicDateTime.Hour).ToList();
if (list.Count > 0)
{
//해당 분 고가
var max = list.Select(t => t.TradePrice).ToList().Max();
//해당 분 저가
var low = list.Select(t => t.TradePrice).ToList().Min();
var candle = new CandleData();
candle.CandleTimeType = (int)MCandleTimeType.H1;
candle.StartValue = list[0].TradePrice;
candle.HighValue = max;
candle.LowValue = low;
candle.RecentlyDataFlag = true;
candle.EndValue = list[list.Count - 1].TradePrice;
var date = basicDateTime.AddHours(1);
date = date.AddMinutes(-1 * callM);
date = date.AddSeconds(-1 * callS);
candle.DateTime = date;
if (item.CandleDataLists_Im.Count > 300)
item.CandleDataLists_Im.RemoveRange(0, 100);
item.CandleDataLists_Im.Add(candle);
}
}
var lastData = item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1];
returnList.Insert(0, lastData);
}
catch (Exception e)
var dataList = DataManager.GetConvertCandleDataList(returnList, type);
if (item.CandleDataLists_Im.Count > 0)
{
throw;
item.CandleDataLists_Im.Remove(item.CandleDataLists_Im[item.CandleDataLists_Im.Count - 1]);
}
item.CandleDataLists_Im.AddRange(dataList);
if(item.CandleDataLists_Im.Count > 150)
{
item.CandleDataLists_Im.RemoveRange(0, item.CandleDataLists_Im.Count - 150);
}
#endregion
}
//});
}
return candleDatas;
}
public void ClearTicker()
{
lock (obj)
{
try {
if (tickerList.Count > 2000)
tickerList.RemoveRange(0, tickerList.Count - 1000);
}
catch (Exception e)
{
LogManager.WriteLog(e.Message);
}
}
}
/// <summary>
/// Timer Event
/// </summary>
/// <param name="state"></param>
private void TimerEvent(object state)
private async void ThreadEventAsync()
{
lock (obj)
string WebSocketUrl = "wss://api.upbit.com/websocket/v1";
realtimeConclusions.Clear();
while (Flag)
{
ClientWebSocket webSocket = new ClientWebSocket();
try
{
var temp = GetRecentlyCandleData();
await webSocket.ConnectAsync(new Uri(WebSocketUrl), CancellationToken.None);
var dic = new List<Dictionary<string, object>>();
dic.Add(new Dictionary<string, object>() { { "ticket", "test" } });
dic.Add(new Dictionary<string, object>() { { "type", "trade" }, { "codes", CommonProperty.recentlyMarketOfPlaceList.Where(t => t.CoinFullName.Contains("KRW-")).Select(t => t.CoinFullName).ToList() } });
if (temp != null)
await SendMessage(webSocket, JsonConvert.SerializeObject(dic));
// 데이터 수신을 위한 반복문 시작
while (webSocket.State == WebSocketState.Open && Flag)
{
tickerList.AddRange(temp);
ClearTicker();
}
byte[] buffer = new byte[1024 * 10];
WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
// 수신한 데이터 처리
var message = System.Text.Encoding.UTF8.GetString(buffer, 0, result.Count);
if (!DataManager.ValidateJSON(message)) continue;
var data = JsonConvert.DeserializeObject<RealtimeConclusion>(message);
lock (obj)
{
realtimeConclusions.Add(data);
}
}
}
catch (Exception e)
catch (Exception ex)
{
LogManager.WriteLog(e.Message);
LogManager.WriteLog(ex.Message);
}
finally
{
if (webSocket.State == WebSocketState.Open)
await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "WebSocket 연결 종료", CancellationToken.None);
webSocket.Dispose();
}
}
}
/// <summary>
/// Websocket 관련 SendMessage function
/// </summary>
/// <param name="webSocket"></param>
/// <param name="message"></param>
/// <returns></returns>
private async Task SendMessage(ClientWebSocket webSocket, string message)
{
byte[] buffer = Encoding.UTF8.GetBytes(message);
await webSocket.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Text, true, CancellationToken.None);
}
}
}
;

View File

@@ -173,6 +173,7 @@
<Compile Include="Data\Upbit\OrderBook\Unit.cs" />
<Compile Include="Data\Upbit\Order\Order.cs" />
<Compile Include="Data\Upbit\Order\Trade.cs" />
<Compile Include="Data\Upbit\RealtimeConclusion.cs" />
<Compile Include="Data\Upbit\Ticker.cs" />
<Compile Include="DbMangement\DBConnection.cs" />
<Compile Include="DbMangement\DBServiceFunctions.cs" />

View File

@@ -82,10 +82,10 @@ namespace Million.SubForm
visualRangeStartValueFix = new TimeSpan(0, 0, 1, 0);
break;
case CommonProperty.MCandleTimeType.M10:
case CommonProperty.MCandleTimeType.M15:
case CommonProperty.MCandleTimeType.M5:
case CommonProperty.MCandleTimeType.M3:
case CommonProperty.MCandleTimeType.M30:
case CommonProperty.MCandleTimeType.M5:
case CommonProperty.MCandleTimeType.M15:
visualRangeStartValueFix = new TimeSpan(0, 0, 1, 0);
break;
case CommonProperty.MCandleTimeType.D1:
@@ -145,12 +145,11 @@ namespace Million.SubForm
diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Hour;
viewRangeEndDate = startTime + new TimeSpan(0, setTimeInterval, 0, 0);
break;
case CommonProperty.MCandleTimeType.M1:
case CommonProperty.MCandleTimeType.M10:
case CommonProperty.MCandleTimeType.M15:
case CommonProperty.MCandleTimeType.M5:
case CommonProperty.MCandleTimeType.M3:
case CommonProperty.MCandleTimeType.M30:
case CommonProperty.MCandleTimeType.M5:
case CommonProperty.MCandleTimeType.M15:
diagram.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Minute;
viewRangeEndDate = startTime + new TimeSpan(0, 0, setTimeInterval, 0);
break;

View File

@@ -338,7 +338,7 @@ namespace Million.WebMangement.Upbit
}
return returnData;
}
}
/// <summary>
/// Coin Full name List를 기준으로 현재가 가져오는 함수