1. 임시로 데이터 넣기 완료
2. Class 정규화 완료 3. Insert 관련 데이터 처리 완료
This commit is contained in:
@@ -73,7 +73,14 @@ namespace Million
|
||||
simpleButton_TobuyList.Visible = true;
|
||||
simpleButton_ToSellList.Visible = true;
|
||||
|
||||
DbServiceFunctions.GetMarketTable_FromDB("Upbit", "KRW");
|
||||
DbServiceFunctions.GetMarketTable_FromDB("Upbit", "KRW");
|
||||
|
||||
// Result Data DB에 생성
|
||||
Million.DbManagement.DBConnection.QueryUpdateExcuter
|
||||
(CommonProperty.DbConnectionResultData, DbServiceFunctions.CreateSavedAnalysisDataTableQuery());
|
||||
Million.DbManagement.DBConnection.QueryUpdateExcuter
|
||||
(CommonProperty.DbConnectionResultData, DbServiceFunctions.CreateSavedResultDataTableQuery());
|
||||
|
||||
}
|
||||
|
||||
// 지표 콤보박스 클릭 시 이벤트
|
||||
|
||||
@@ -134,7 +134,6 @@
|
||||
<EmbeddedResource Include="HunterMainForm.resx">
|
||||
<DependentUpon>HunterMainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\licenses.licx" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
||||
13
Million Prototype/Form1.Designer.cs
generated
13
Million Prototype/Form1.Designer.cs
generated
@@ -46,6 +46,7 @@
|
||||
this.button9 = new System.Windows.Forms.Button();
|
||||
this.chartControl1 = new DevExpress.XtraCharts.ChartControl();
|
||||
this.button10 = new System.Windows.Forms.Button();
|
||||
this.button11 = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.chartControl1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(xyDiagram1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(series1)).BeginInit();
|
||||
@@ -201,11 +202,22 @@
|
||||
this.button10.UseVisualStyleBackColor = true;
|
||||
this.button10.Click += new System.EventHandler(this.button10_Click);
|
||||
//
|
||||
// button11
|
||||
//
|
||||
this.button11.Location = new System.Drawing.Point(35, 438);
|
||||
this.button11.Name = "button11";
|
||||
this.button11.Size = new System.Drawing.Size(75, 23);
|
||||
this.button11.TabIndex = 15;
|
||||
this.button11.Text = "file to db";
|
||||
this.button11.UseVisualStyleBackColor = true;
|
||||
this.button11.Click += new System.EventHandler(this.button11_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1415, 703);
|
||||
this.Controls.Add(this.button11);
|
||||
this.Controls.Add(this.button10);
|
||||
this.Controls.Add(this.chartControl1);
|
||||
this.Controls.Add(this.button9);
|
||||
@@ -249,6 +261,7 @@
|
||||
private System.Windows.Forms.Button button9;
|
||||
private DevExpress.XtraCharts.ChartControl chartControl1;
|
||||
private System.Windows.Forms.Button button10;
|
||||
private System.Windows.Forms.Button button11;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ using Million;
|
||||
using System.IO;
|
||||
using Million.FileDBManagement;
|
||||
using Million.SaveData;
|
||||
using Million.DbManagement;
|
||||
|
||||
namespace Million_Prototype
|
||||
{
|
||||
@@ -379,11 +380,68 @@ namespace Million_Prototype
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File 에서 DB로 데이터 입력
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void button11_Click(object sender, EventArgs e)
|
||||
{
|
||||
//1회용임 Class 변경 때문에
|
||||
|
||||
//// Result Data DB에 생성
|
||||
//Million.DbManagement.DBConnection.QueryUpdateExcuter
|
||||
// (CommonProperty.DbConnectionResultData, DbServiceFunctions.CreateSavedAnalysisDataTableQuery());
|
||||
//Million.DbManagement.DBConnection.QueryUpdateExcuter
|
||||
// (CommonProperty.DbConnectionResultData, DbServiceFunctions.CreateSavedResultDataTableQuery());
|
||||
|
||||
////file Data전체 불러와서 처리
|
||||
|
||||
//var savedResultDatas = new List<SavedResultData>();
|
||||
|
||||
//foreach (var filePath in Directory.GetFiles(CommonProperty.SaveProgramDirecotryPath).ToList()
|
||||
// .FindAll(item => item.Contains(CommonProperty.InfoExtend)))
|
||||
//{
|
||||
// var savedResult = FileManager.LoadResultDataInfoFromFile(filePath);
|
||||
// savedResult.SavedInfoDataPath = filePath;
|
||||
// savedResult.SavedResultDataPath =
|
||||
// filePath.Replace(CommonProperty.InfoExtend, CommonProperty.DataExtend);
|
||||
// savedResult.SavedResultAnalysisDataPath =
|
||||
// filePath.Replace(CommonProperty.InfoExtend, CommonProperty.AnalysisExtendFolder);
|
||||
|
||||
// savedResult.SearchResultList = FileManager.LoadResultDataFromFile(savedResult.SavedResultDataPath);
|
||||
// savedResultDatas.Add(savedResult);
|
||||
//}
|
||||
|
||||
////saved result for문 돌면서 데이터 처리
|
||||
//foreach(var item in savedResultDatas)
|
||||
//{
|
||||
// var savedAnalysisDataList = new List<SavedAnalysisData>();
|
||||
// if (Directory.Exists(item.SavedResultAnalysisDataPath))
|
||||
// {
|
||||
// var fileList = Directory.GetFiles(item.SavedResultAnalysisDataPath, "*info");
|
||||
|
||||
// foreach (var filePath in fileList)
|
||||
// {
|
||||
// var savedSnalysisData = FileManager.LoadResultAnalysisDataInfoFromFile(filePath);
|
||||
// savedSnalysisData.SavedInfoDataPath = filePath;
|
||||
// savedSnalysisData.SavedResultDataPath = filePath.Replace("info", "data");
|
||||
// savedSnalysisData.AnalysisDataList = FileManager.LoadResultAnalysisDataFromFile(savedSnalysisData.SavedResultDataPath);
|
||||
// savedAnalysisDataList.Add(savedSnalysisData);
|
||||
// }
|
||||
// }
|
||||
// //SavedResultData 먼저 DB에 Insert 후 SavedAnalysisData 처리
|
||||
// Million.DbManagement.DBConnection.QueryUpdateExcuter_SavedResultData(item);
|
||||
// foreach(var analysis in savedAnalysisDataList)
|
||||
// {
|
||||
// Million.DbManagement.DBConnection.QueryUpdateExcuter_SavedAnalysisData(analysis, item);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void button4_Click(object sender, EventArgs e)
|
||||
{
|
||||
//DbServiceFunctions.GetMarketTable_FromDB("Upbit");
|
||||
@@ -1101,6 +1159,7 @@ namespace Million_Prototype
|
||||
//diagram.AxisX.VisualRange.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public class DataPoint
|
||||
{
|
||||
|
||||
@@ -263,6 +263,7 @@ namespace Million
|
||||
private const string DbServerUserPassword = "million!";
|
||||
public static string DbConnectionStr = $"Data Source={DbServerIp};uid={DbServerUserId};pwd={DbServerUserPassword};Database=";
|
||||
public static string DbConnectionMarket = DbConnectionStr + "Market";
|
||||
public static string DbConnectionResultData = DbConnectionStr + "ResultData";
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Windows.Forms;
|
||||
using DevExpress.Charts.Native;
|
||||
using DevExpress.DataAccess.Native.Sql;
|
||||
using Million.Data;
|
||||
using Million.SaveData;
|
||||
|
||||
namespace Million.DbManagement
|
||||
{
|
||||
@@ -212,5 +215,107 @@ namespace Million.DbManagement
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert SavedResultData
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public static void QueryUpdateExcuter_SavedResultData(SavedResultData item)
|
||||
{
|
||||
var baBinaryFormatter = new BinaryFormatter();
|
||||
|
||||
var sqlQuery = DbServiceFunctions.InsertSavedResultDataQuery(item);
|
||||
var strDBCon = CommonProperty.DbConnectionResultData;
|
||||
|
||||
SqlConnection conn = null;
|
||||
SqlDataReader rdr = null;
|
||||
|
||||
try
|
||||
{
|
||||
using (conn = new SqlConnection(strDBCon))
|
||||
{
|
||||
using (var cmd = new SqlCommand(sqlQuery, conn))
|
||||
{
|
||||
var buySetupListStream = new MemoryStream();
|
||||
baBinaryFormatter.Serialize(buySetupListStream, item.BuySetupList);
|
||||
buySetupListStream.Position = 0;
|
||||
|
||||
var sellSetupListStream = new MemoryStream();
|
||||
baBinaryFormatter.Serialize(sellSetupListStream, item.SellSetupList);
|
||||
sellSetupListStream.Position = 0;
|
||||
|
||||
var searchResultListStream = new MemoryStream();
|
||||
baBinaryFormatter.Serialize(searchResultListStream, item.SearchResultList);
|
||||
searchResultListStream.Position = 0;
|
||||
|
||||
|
||||
cmd.Parameters.Add("@BuySetupList", SqlDbType.VarBinary, (int)buySetupListStream.Length).Value = buySetupListStream.ToArray();
|
||||
cmd.Parameters.Add("@SellSetupList", SqlDbType.VarBinary, (int)sellSetupListStream.Length).Value = sellSetupListStream.ToArray();
|
||||
cmd.Parameters.Add("@SearchResultList", SqlDbType.VarBinary, (int)searchResultListStream.Length).Value = searchResultListStream.ToArray();
|
||||
conn.Open();
|
||||
using (rdr = cmd.ExecuteReader())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(" ============= exception ===============");
|
||||
Console.WriteLine(e.Message);
|
||||
if (rdr != null)
|
||||
rdr.Close();
|
||||
if (conn != null)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Insert SavedAnalysisData
|
||||
/// </summary>
|
||||
/// <param name="analysis"></param>
|
||||
/// <param name="item"></param>
|
||||
public static void QueryUpdateExcuter_SavedAnalysisData(SavedAnalysisData savedAnalysisData, SavedResultData savedResultData)
|
||||
{
|
||||
var baBinaryFormatter = new BinaryFormatter();
|
||||
|
||||
var sqlQuery = DbServiceFunctions.InsertSavedAnalysisDataQuery(savedAnalysisData, savedResultData);
|
||||
var strDBCon = CommonProperty.DbConnectionResultData;
|
||||
|
||||
SqlConnection conn = null;
|
||||
SqlDataReader rdr = null;
|
||||
|
||||
try
|
||||
{
|
||||
using (conn = new SqlConnection(strDBCon))
|
||||
{
|
||||
using (var cmd = new SqlCommand(sqlQuery, conn))
|
||||
{
|
||||
var analysisDataListStream = new MemoryStream();
|
||||
baBinaryFormatter.Serialize(analysisDataListStream, savedAnalysisData.AnalysisDataList);
|
||||
analysisDataListStream.Position = 0;
|
||||
|
||||
cmd.Parameters.Add("@AnalysisDataList", SqlDbType.VarBinary, (int)analysisDataListStream.Length).Value = analysisDataListStream.ToArray();
|
||||
|
||||
conn.Open();
|
||||
using (rdr = cmd.ExecuteReader())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(" ============= exception ===============");
|
||||
Console.WriteLine(e.Message);
|
||||
if (rdr != null)
|
||||
rdr.Close();
|
||||
if (conn != null)
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,64 @@ using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading.Tasks;
|
||||
using Million.Manager;
|
||||
using Million.SaveData;
|
||||
|
||||
namespace Million.DbManagement
|
||||
{
|
||||
public static class DbServiceFunctions
|
||||
{
|
||||
/// <summary>
|
||||
/// Create SavedAnalysisData table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string CreateSavedAnalysisDataTableQuery()
|
||||
{
|
||||
return @"if not exists (select * from sysobjects where name='SavedAnalysisData' and xtype='U')
|
||||
create table " + "\"SavedAnalysisData\"" + @"(
|
||||
Id int IDENTITY (1,1) NOT NULL,
|
||||
SavedResultDataId int NOT NULL,
|
||||
Name nvarchar(50) NOT NULL,
|
||||
TreeListFilterString nvarchar(50) NOT NULL,
|
||||
AnalysisDataList varbinary(MAX) NOT NULL,
|
||||
Description nvarchar(MAX) NULL,
|
||||
ResultDataCount int NOT NULL,
|
||||
FirstProfitRate float NOT NULL,
|
||||
FirstWinRate float NOT NULL,
|
||||
SavedDateTime datetime NOT NULL
|
||||
)";
|
||||
}
|
||||
/// <summary>
|
||||
/// Create SavedResultData Table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string CreateSavedResultDataTableQuery()
|
||||
{
|
||||
return @"if not exists (select * from sysobjects where name='SavedResultData' and xtype='U')
|
||||
create table " + "\"SavedResultData\"" + @"(
|
||||
Id int IDENTITY (1,1) NOT NULL,
|
||||
ParentId int NULL,
|
||||
Name nvarchar(50) NOT NULL,
|
||||
StartDateTime datetime NOT NULL,
|
||||
EndDateTime datetime NOT NULL,
|
||||
SavedDateTime datetime NOT NULL,
|
||||
BuySetupList varbinary(MAX) NULL,
|
||||
SellSetupList varbinary(MAX) NULL,
|
||||
BuyRegularExpression varchar(100) NOT NULL,
|
||||
SellRegularExpression varchar(100) NOT NULL,
|
||||
SearchResultList varbinary(MAX) NULL,
|
||||
ResultDataCount int NOT NULL,
|
||||
WinRate float NOT NULL,
|
||||
ProfitRate float NOT NULL,
|
||||
FirstProfitRate float NOT NULL,
|
||||
FirstWinRate float NOT NULL,
|
||||
ExchangePlace nvarchar(50) NOT NULL,
|
||||
Type nvarchar(50) NOT NULL,
|
||||
SaveResultType nvarchar(50) NOT NULL,
|
||||
Description nvarchar(MAX) NULL
|
||||
|
||||
)";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DB Market 테이블 생성
|
||||
/// </summary>
|
||||
@@ -182,6 +235,8 @@ namespace Million.DbManagement
|
||||
return returnData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// DB에서 각 Market 별 가장 최신, 오래된 데이터 한개씩 가져오기
|
||||
/// </summary>
|
||||
@@ -386,6 +441,117 @@ namespace Million.DbManagement
|
||||
Console.WriteLine("Completed Set Candle Data of Table : " + tableName + ", Times : " + sw.Elapsed.ToString());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Insert SavedResultData Query
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public static string InsertSavedResultDataQuery(SavedResultData item)
|
||||
{
|
||||
|
||||
var str = string.Format(@"INSERT INTO [ResultData].[dbo].[SavedResultData]
|
||||
(
|
||||
[ParentId]
|
||||
,[Name]
|
||||
,[StartDateTime]
|
||||
,[EndDateTime]
|
||||
,[SavedDateTime]
|
||||
,[BuySetupList]
|
||||
,[SellSetupList]
|
||||
,[SearchResultList]
|
||||
,[BuyRegularExpression]
|
||||
,[SellRegularExpression]
|
||||
,[ResultDataCount]
|
||||
,[WinRate]
|
||||
,[ProfitRate]
|
||||
,[FirstProfitRate]
|
||||
,[FirstWinRate]
|
||||
,[ExchangePlace]
|
||||
,[Type]
|
||||
,[SaveResultType]
|
||||
,[Description]
|
||||
)VALUES(NULL,
|
||||
'{0}',
|
||||
'{1}',
|
||||
'{2}',
|
||||
'{3}',
|
||||
@BuySetupList,
|
||||
@SellSetupList,
|
||||
@SearchResultList,
|
||||
'{4}',
|
||||
'{5}',
|
||||
'{6}',
|
||||
'{7}',
|
||||
'{8}',
|
||||
'{9}',
|
||||
'{10}',
|
||||
'{11}',
|
||||
'{12}',
|
||||
'{13}',
|
||||
'{14}'
|
||||
);",
|
||||
item.ParentId,
|
||||
item.Name,
|
||||
item.StartDateTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
item.EndDateTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
item.SavedDateTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
item.BuyRegularExpression,
|
||||
item.SellRegularExpression,
|
||||
item.ResultDataCount.ToString(),
|
||||
item.WinRate,
|
||||
item.ProfitRate,
|
||||
item.FirstProfitRate,
|
||||
item.FirstWinRate,
|
||||
item.ExchangePlace,
|
||||
item.Type,
|
||||
item.SaveResultType,
|
||||
item.Description
|
||||
);
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="savedAnalysisData"></param>
|
||||
/// <param name="savedResultData"></param>
|
||||
/// <returns></returns>
|
||||
public static string InsertSavedAnalysisDataQuery(SavedAnalysisData savedAnalysisData, SavedResultData savedResultData)
|
||||
{
|
||||
var str = string.Format(@"INSERT INTO [ResultData].[dbo].[SavedResultData]
|
||||
(
|
||||
[SavedResultDataId]
|
||||
,[Name]
|
||||
,[TreeListFilterString]
|
||||
,[AnalysisDataList]
|
||||
,[Description]
|
||||
,[ResultDataCount]
|
||||
,[FirstProfitRate]
|
||||
,[FirstWinRate]
|
||||
,[SavedDateTime]
|
||||
)VALUES(
|
||||
'{0}',
|
||||
'{1}',
|
||||
'{2}',
|
||||
@AnalysisDataList,
|
||||
'{3}',
|
||||
'{4}',
|
||||
'{5}',
|
||||
'{6}',
|
||||
'{7}'
|
||||
);",
|
||||
savedResultData.Id,
|
||||
savedAnalysisData.Name,
|
||||
savedAnalysisData.TreeListFilterString,
|
||||
savedAnalysisData.Description,
|
||||
savedAnalysisData.ResultDataCount,
|
||||
savedAnalysisData.FirstProfitRate,
|
||||
savedAnalysisData.FirstWinRate,
|
||||
savedAnalysisData.SavedTime.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Million.SaveData
|
||||
[Serializable]
|
||||
public class SavedAnalysisData
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
// 적용된 필터 스트링
|
||||
public string TreeListFilterString { get; set; }
|
||||
|
||||
|
||||
@@ -13,6 +13,14 @@ namespace Million.SaveData
|
||||
[Serializable]
|
||||
public class SavedResultData
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int? ParentId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ExchangePlace { get; set; }
|
||||
|
||||
public string Type { get; set; }
|
||||
public string SaveResultType { get; set; }
|
||||
public string Description { get; set; }
|
||||
// 기간
|
||||
public DateTime StartDateTime { get; set; }
|
||||
public DateTime EndDateTime { get; set; }
|
||||
@@ -22,7 +30,7 @@ namespace Million.SaveData
|
||||
|
||||
// 조건 설정
|
||||
public List<object> BuySetupList { get; set; }
|
||||
public List<object> SellSetupList { get; set; }
|
||||
public List<object> SellSetupList { get; set; }
|
||||
|
||||
// 정규식 (Buy)
|
||||
public string BuyRegularExpression { get; set; }
|
||||
@@ -61,6 +69,11 @@ namespace Million.SaveData
|
||||
{
|
||||
var clone = new SavedResultData
|
||||
{
|
||||
Id = Id,
|
||||
ExchangePlace = ExchangePlace,
|
||||
Type = Type,
|
||||
SaveResultType = SaveResultType,
|
||||
Description = Description,
|
||||
StartDateTime = StartDateTime,
|
||||
EndDateTime = EndDateTime,
|
||||
SavedDateTime = SavedDateTime,
|
||||
@@ -74,9 +87,5 @@ namespace Million.SaveData
|
||||
};
|
||||
return clone;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user