1. Buyer Ticker 모드 개발 중

2. Ticker 데이터 Save 로직 변경
This commit is contained in:
kyh
2022-11-24 14:06:44 +09:00
parent c988236c55
commit 448b167b88
8 changed files with 225 additions and 62 deletions

View File

@@ -304,21 +304,15 @@ namespace DataSaver
{
var date = DateTime.Now;
var tickerList = CommonProperty.UpbitApi.GetTickerList(coinFullNameList);
var dic = new Dictionary<string, object>();
var dateData = tickerList[0].DateTime;
foreach (var item in coinFullNameList)
{
dic[item] = 0;
}
if (tickerList.Count != 0)
{
foreach (var item in tickerList)
{
dic["CoinFullName"] = item.CoinFullName;
dic["Price"] = item.TradePrice;
dic["DateTime"] = item.DateTime;
}
var dic = new Dictionary<string, object>();
var ticker = tickerList.FirstOrDefault(t => t.CoinFullName == item);
dic["CoinFullName"] = item;
dic["EndValue"] = ticker.TradePrice;
dic["DateTime"] = ticker.DateTime;
list.Add(dic);
}

View File

@@ -28,8 +28,8 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.cb_DownBeforeValueFlag = new System.Windows.Forms.CheckBox();
this.cb_UpperMainIndi = new System.Windows.Forms.CheckBox();
this.cb_IncludeClearIndicator = new System.Windows.Forms.CheckBox();
this.lb_IndiName = new System.Windows.Forms.Label();
@@ -69,6 +69,10 @@
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();
@@ -85,15 +89,18 @@
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.components);
this.timer1 = new System.Windows.Forms.Timer();
this.splitContainerControl1 = new DevExpress.XtraEditors.SplitContainerControl();
this.splitContainerControl2 = new DevExpress.XtraEditors.SplitContainerControl();
this.cb_DownBeforeValueFlag = 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();
@@ -115,13 +122,25 @@
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, 123);
this.groupBox1.Location = new System.Drawing.Point(12, 172);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(362, 206);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "데이터 Setting";
//
// cb_DownBeforeValueFlag
//
this.cb_DownBeforeValueFlag.AutoSize = true;
this.cb_DownBeforeValueFlag.Checked = true;
this.cb_DownBeforeValueFlag.CheckState = System.Windows.Forms.CheckState.Checked;
this.cb_DownBeforeValueFlag.Location = new System.Drawing.Point(10, 177);
this.cb_DownBeforeValueFlag.Name = "cb_DownBeforeValueFlag";
this.cb_DownBeforeValueFlag.Size = new System.Drawing.Size(312, 16);
this.cb_DownBeforeValueFlag.TabIndex = 10;
this.cb_DownBeforeValueFlag.Text = "최초돌파 검색 시 메인조건이 사전조건보다 높아야 함";
this.cb_DownBeforeValueFlag.UseVisualStyleBackColor = true;
//
// cb_UpperMainIndi
//
this.cb_UpperMainIndi.AutoSize = true;
@@ -230,7 +249,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, 335);
this.groupBox2.Location = new System.Drawing.Point(12, 384);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(362, 72);
this.groupBox2.TabIndex = 6;
@@ -297,23 +316,23 @@
//
this.rd_Realtime.AutoSize = true;
this.rd_Realtime.Checked = true;
this.rd_Realtime.Location = new System.Drawing.Point(8, 79);
this.rd_Realtime.Location = new System.Drawing.Point(10, 79);
this.rd_Realtime.Name = "rd_Realtime";
this.rd_Realtime.Size = new System.Drawing.Size(115, 16);
this.rd_Realtime.Size = new System.Drawing.Size(145, 16);
this.rd_Realtime.TabIndex = 9;
this.rd_Realtime.TabStop = true;
this.rd_Realtime.Text = "실시간 검증 모드";
this.rd_Realtime.Text = "Buyer Realtime Mode";
this.rd_Realtime.UseVisualStyleBackColor = true;
this.rd_Realtime.CheckedChanged += new System.EventHandler(this.rd_Realtime_CheckedChanged);
//
// rd_buyer
//
this.rd_buyer.AutoSize = true;
this.rd_buyer.Location = new System.Drawing.Point(178, 79);
this.rd_buyer.Location = new System.Drawing.Point(10, 101);
this.rd_buyer.Name = "rd_buyer";
this.rd_buyer.Size = new System.Drawing.Size(84, 16);
this.rd_buyer.Size = new System.Drawing.Size(92, 16);
this.rd_buyer.TabIndex = 10;
this.rd_buyer.Text = "Buyer 모드";
this.rd_buyer.Text = "Buyer Mode";
this.rd_buyer.UseVisualStyleBackColor = true;
this.rd_buyer.CheckedChanged += new System.EventHandler(this.rd_buyer_CheckedChanged);
//
@@ -476,10 +495,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, 414);
this.lb_log.Location = new System.Drawing.Point(12, 462);
this.lb_log.Name = "lb_log";
this.lb_log.ScrollAlwaysVisible = true;
this.lb_log.Size = new System.Drawing.Size(362, 328);
this.lb_log.Size = new System.Drawing.Size(362, 280);
this.lb_log.TabIndex = 16;
//
// bt_alive
@@ -495,6 +514,10 @@
//
// 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);
@@ -503,11 +526,57 @@
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, 108);
this.groupBox3.Size = new System.Drawing.Size(362, 157);
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;
@@ -693,18 +762,6 @@
this.splitContainerControl2.SplitterPosition = 442;
this.splitContainerControl2.TabIndex = 23;
//
// cb_DownBeforeValueFlag
//
this.cb_DownBeforeValueFlag.AutoSize = true;
this.cb_DownBeforeValueFlag.Checked = true;
this.cb_DownBeforeValueFlag.CheckState = System.Windows.Forms.CheckState.Checked;
this.cb_DownBeforeValueFlag.Location = new System.Drawing.Point(10, 177);
this.cb_DownBeforeValueFlag.Name = "cb_DownBeforeValueFlag";
this.cb_DownBeforeValueFlag.Size = new System.Drawing.Size(312, 16);
this.cb_DownBeforeValueFlag.TabIndex = 10;
this.cb_DownBeforeValueFlag.Text = "최초돌파 검색 시 메인조건이 사전조건보다 높아야 함";
this.cb_DownBeforeValueFlag.UseVisualStyleBackColor = true;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -732,6 +789,10 @@
((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);
@@ -804,6 +865,10 @@
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;
}
}

View File

@@ -46,9 +46,7 @@ namespace Million_Buyer
private Stopwatch unlimitThreadStopWatch = new Stopwatch();
private bool unlimitChecker = false;
private long second = 0;
private string mode = "Buyer";
private long second = 0;
private int cycleCount = 0;
private double cycleBuyMoney = 0;
@@ -88,10 +86,11 @@ namespace Million_Buyer
/// <param name="sender"></param>
/// <param name="e"></param>
private void rd_Realtime_CheckedChanged(object sender, EventArgs e)
{
mode = "RealTime";
{
programMode = BuyerMode.BuyerRealtime;
SetReadOnly(true);
dt_Start.Enabled = false;
dt_End.Enabled = false;
}
/// <summary>
@@ -100,10 +99,20 @@ namespace Million_Buyer
/// <param name="sender"></param>
/// <param name="e"></param>
private void rd_buyer_CheckedChanged(object sender, EventArgs e)
{
mode = "Buyer";
{
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;
}
/// <summary>
@@ -111,8 +120,7 @@ namespace Million_Buyer
/// </summary>
/// <param name="flag"></param>
private void SetReadOnly(bool flag)
{
{
tb_CycleCount.ReadOnly = flag;
tb_CycleMoneyValue.ReadOnly = flag;
}
@@ -187,6 +195,8 @@ namespace Million_Buyer
cb_UpperMainIndi.Enabled = false;
rd_buyer.Enabled = false;
rd_Realtime.Enabled = false;
dt_Start.Enabled = false;
dt_End.Enabled = false;
}
}
}
@@ -214,7 +224,12 @@ namespace Million_Buyer
cb_DownBeforeValueFlag.Enabled = true;
cb_IncludeClearIndicator.Enabled = true;
cb_UpperMainIndi.Enabled = true;
if (programMode == BuyerMode.BuyerTicker)
{
dt_Start.Enabled = true;
dt_End.Enabled = true;
}
/*
* 종료 된 후 데이터 처리 소스는 여기서 처리
@@ -363,8 +378,17 @@ namespace Million_Buyer
#region 기본 데이터 Setting
if (firstFlag)
{
realTimeMsg = new RealtimeDataSettingManager(null, this.payment);
dataList = realTimeMsg.GetRealTimeCandleData(candleTypeList, 200);
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;
}
dataList = realTimeMsg.GetRealTimeCandleData(candleTypeList, startDateTime, endDateTime, 200);
if (programMode == BuyerMode.Buyer)
{
@@ -569,7 +593,7 @@ namespace Million_Buyer
try
{
//result data insert
DBConnection.QueryInsertExcuter_SavedBuyerResultData(cb_UserList.Text, mode, time, result);
DBConnection.QueryInsertExcuter_SavedBuyerResultData(cb_UserList.Text, Enum.GetName(typeof(BuyerMode), programMode), time, result);
//Grid 처리
TreeListNode buyNode = null;
@@ -933,5 +957,6 @@ namespace Million_Buyer
}
second = milli;
}
}
}

View File

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

View File

@@ -0,0 +1,2 @@
DevExpress.XtraTreeList.TreeList, DevExpress.XtraTreeList.v18.2, Version=18.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraEditors.DateEdit, DevExpress.XtraEditors.v18.2, Version=18.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a

View File

@@ -182,8 +182,8 @@ namespace Million_Prototype
{
if (firstFlag == 0)
{
realTimeMsg = new RealtimeDataSettingManager(null, PaymentType.KRW);
dataList = realTimeMsg.GetRealTimeCandleData(candleTypeList, 200);
realTimeMsg = new RealtimeDataSettingManager(null, BuyerMode.BuyerTicker,PaymentType.KRW);
dataList = realTimeMsg.GetRealTimeCandleData(candleTypeList,DateTime.Now, DateTime.Now, 200);
foreach (var item in realTimeMsg.coinFullNameList)
{
overlapBuyManagementList[item] = true;

View File

@@ -199,6 +199,8 @@ namespace Million.DbManagement
}
/// <summary>
/// Get Candle Data List
/// </summary>
@@ -630,6 +632,52 @@ namespace Million.DbManagement
return returnData;
}
/// <summary>
/// Get Ticerk List
/// </summary>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <returns></returns>
public static List<Dictionary<string, object>> QueryGetExcuter_VerifyTickerData(DateTime startDate, DateTime endDate)
{
var returnData = new List<Dictionary<string, object>>();
var sqlQuery = string.Format(@"SELECT * FROM [ResultData].[dbo].[VerifyTickerData] WHERE [SavedDateTime] >= '{0}' AND [SavedDateTime] <= '{1}';",
startDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"));
var strDBCon = CommonProperty.DbConnectionResultData;
using (var conn = new SqlConnection(strDBCon))
{
using (var cmd = new SqlCommand(sqlQuery, conn))
{
try
{
conn.Open();
using (var rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
var data = new List<Dictionary<string, object>>();
data = (List<Dictionary<string, object>>)GetBinaryConvertClass(rdr, "data");
returnData.AddRange(data);
}
}
conn.Close();
}
catch (Exception ex)
{
Console.WriteLine(" ============= exception ===============");
Console.WriteLine(ex.Message);
conn.Close();
return returnData;
}
}
}
return returnData;
}
/// <summary>
/// Get SavedResultData

View File

@@ -24,15 +24,20 @@ namespace Million.Manager
public List<string> coinFullNameList = null;
public PaymentType buyType = PaymentType.KRW;
public DateTime basicDateTime { get; set; }
public 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>
/// 생성자
/// </summary>
public RealtimeDataSettingManager(List<string> coinFullNameList, PaymentType buyType, string tableName = "Upbit")
public RealtimeDataSettingManager(List<string> coinFullNameList, BuyerMode buyerMode, PaymentType buyType, string tableName = "Upbit")
{
this.buyType = buyType;
this.buyType = buyType;
this.buyerMode = buyerMode;
//null일경우 전체가 가져옴
if (coinFullNameList == null)
@@ -73,17 +78,16 @@ namespace Million.Manager
/// <param name="coinFullNameList"></param>
/// <param name="tableName"></param>
/// <returns></returns>
public List<CandleDataList> GetBasicDataSetting(MCandleTimeType timeType, int count = 200)
public List<CandleDataList> GetBasicDataSetting(MCandleTimeType timeType, DateTime basicDateTime, int count = 200)
{
var returnData = new List<CandleDataList>();
basicDateTime = DateTime.Now;
var resultList = new List<CandleData>();
foreach (var item in coinFullNameList)
{
var val = new CandleDataList();
val.ConGoodsData = CommonProperty.selectedMarketOfPlaceList.FirstOrDefault(t => t.CoinFullName == item);
val.ConGoodsData = 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);
@@ -127,20 +131,38 @@ namespace Million.Manager
/// <param name="type"></param>
/// <param name="count"></param>
/// <returns></returns>
public Dictionary<MCandleTimeType, List<CandleDataList>> GetRealTimeCandleData(List<MCandleTimeType> types, int count = 200)
public Dictionary<MCandleTimeType, List<CandleDataList>> GetRealTimeCandleData(List<MCandleTimeType> types,DateTime startDate, DateTime endDate, int count = 200)
{
var data = new Dictionary<MCandleTimeType, List<CandleDataList>>();
StartGetRealTimeTicker(null);
if (this.buyerMode != BuyerMode.BuyerTicker)
{
StartGetRealTimeTicker(null);
}
else
{
startDateTime = startDate;
endDateTime = endDate;
GetAllTickerDataList();
}
foreach (var type in types)
{
data[type] = GetBasicDataSetting(type, count);
data[type] = GetBasicDataSetting(type, startDate, count);
}
return ProcessRecentlyCandleDatas(data, types);
}
/// <summary>
/// 전체 Ticker Data List가져오는 함수
/// </summary>
private void GetAllTickerDataList()
{
var tickerList = DBConnection.QueryGetExcuter_VerifyTickerData(startDateTime, endDateTime);
}
/// <summary>
/// CandleData를 Ticker로 계싼
@@ -150,6 +172,12 @@ namespace Million.Manager
/// <returns></returns>
public Dictionary<MCandleTimeType, List<CandleDataList>> ProcessRecentlyCandleDatas(Dictionary<MCandleTimeType, List<CandleDataList>> candleDatas, List<MCandleTimeType> types)
{
if(buyerMode == BuyerMode.BuyerTicker)
{
}
foreach (var type in types)
{
var candleList = candleDatas[type];