From c70caa902e4c6c857b9bb618dde809f7273a3403 Mon Sep 17 00:00:00 2001 From: kyh <1329522@naver.com> Date: Tue, 25 Oct 2022 16:18:50 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=98=EC=A0=95=20(=ED=95=98=EB=A3=A8=20?= =?UTF-8?q?=EB=82=B4=EB=82=B4=20=EB=8F=8C=EB=A0=A4=EB=B3=B4=EA=B3=A0=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=20=EC=98=88=EC=A0=95)=20->=20=EC=9D=B4?= =?UTF-8?q?=EC=83=81=ED=95=98=EA=B2=8C=20=EC=A0=80=EC=9E=A5=EB=90=98?= =?UTF-8?q?=EB=8A=94=EA=B1=B0=20=EC=96=B4=EB=96=BB=EA=B2=8C=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=ED=95=A0=EC=A7=80=20=EA=B3=A0=EB=AF=BC=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Million Buyer/MainForm.Designer.cs | 56 ++-------------- Million Buyer/MainForm.cs | 29 ++++---- Million/Manager/CalculateManager.cs | 15 ++--- Million/Manager/ResultLogicManager.cs | 20 +++++- Million/WebMangement/Upbit/UpbitAPI.cs | 73 +++++++++++++++++---- Million/WebMangement/WebServiceFunctions.cs | 16 ++--- 6 files changed, 109 insertions(+), 100 deletions(-) diff --git a/Million Buyer/MainForm.Designer.cs b/Million Buyer/MainForm.Designer.cs index b5a9529..f08e8ec 100644 --- a/Million Buyer/MainForm.Designer.cs +++ b/Million Buyer/MainForm.Designer.cs @@ -43,11 +43,7 @@ this.groupBox2 = new System.Windows.Forms.GroupBox(); this.lb_StartDate = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); - this.lb_TotalMoneyValue = new System.Windows.Forms.Label(); - this.lb_TotalRate = new System.Windows.Forms.Label(); this.lb_BuyMarketCount = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.bt_Start = new System.Windows.Forms.Button(); this.bt_Stop = new System.Windows.Forms.Button(); @@ -225,15 +221,11 @@ // this.groupBox2.Controls.Add(this.lb_StartDate); this.groupBox2.Controls.Add(this.label10); - this.groupBox2.Controls.Add(this.lb_TotalMoneyValue); - this.groupBox2.Controls.Add(this.lb_TotalRate); this.groupBox2.Controls.Add(this.lb_BuyMarketCount); - this.groupBox2.Controls.Add(this.label7); - this.groupBox2.Controls.Add(this.label5); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Location = new System.Drawing.Point(12, 312); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(362, 132); + this.groupBox2.Size = new System.Drawing.Size(362, 72); this.groupBox2.TabIndex = 6; this.groupBox2.TabStop = false; this.groupBox2.Text = "데이터 현황"; @@ -241,7 +233,7 @@ // lb_StartDate // this.lb_StartDate.AutoSize = true; - this.lb_StartDate.Location = new System.Drawing.Point(102, 105); + this.lb_StartDate.Location = new System.Drawing.Point(102, 49); this.lb_StartDate.Name = "lb_StartDate"; this.lb_StartDate.Size = new System.Drawing.Size(0, 12); this.lb_StartDate.TabIndex = 9; @@ -249,28 +241,12 @@ // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(39, 105); + this.label10.Location = new System.Drawing.Point(39, 49); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(57, 12); this.label10.TabIndex = 8; this.label10.Text = "시작 시간"; // - // lb_TotalMoneyValue - // - this.lb_TotalMoneyValue.AutoSize = true; - this.lb_TotalMoneyValue.Location = new System.Drawing.Point(102, 80); - this.lb_TotalMoneyValue.Name = "lb_TotalMoneyValue"; - this.lb_TotalMoneyValue.Size = new System.Drawing.Size(0, 12); - this.lb_TotalMoneyValue.TabIndex = 7; - // - // lb_TotalRate - // - this.lb_TotalRate.AutoSize = true; - this.lb_TotalRate.Location = new System.Drawing.Point(102, 53); - this.lb_TotalRate.Name = "lb_TotalRate"; - this.lb_TotalRate.Size = new System.Drawing.Size(0, 12); - this.lb_TotalRate.TabIndex = 6; - // // lb_BuyMarketCount // this.lb_BuyMarketCount.AutoSize = true; @@ -279,24 +255,6 @@ this.lb_BuyMarketCount.Size = new System.Drawing.Size(0, 12); this.lb_BuyMarketCount.TabIndex = 5; // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(27, 80); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(69, 12); - this.label7.TabIndex = 3; - this.label7.Text = "전체 수익금"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(27, 53); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(69, 12); - this.label5.TabIndex = 2; - this.label5.Text = "전체 수익율"; - // // label3 // this.label3.AutoSize = true; @@ -518,10 +476,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, 450); + this.lb_log.Location = new System.Drawing.Point(12, 390); this.lb_log.Name = "lb_log"; this.lb_log.ScrollAlwaysVisible = true; - this.lb_log.Size = new System.Drawing.Size(362, 280); + this.lb_log.Size = new System.Drawing.Size(362, 340); this.lb_log.TabIndex = 16; // // bt_alive @@ -750,15 +708,11 @@ private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Button bt_Modify; private System.Windows.Forms.Label lb_BuyMarketCount; private System.Windows.Forms.Label lb_TotalMoney; - private System.Windows.Forms.Label lb_TotalMoneyValue; - private System.Windows.Forms.Label lb_TotalRate; private System.Windows.Forms.Button bt_Start; private System.Windows.Forms.Button bt_Stop; private System.Windows.Forms.Label lb_IndiName; diff --git a/Million Buyer/MainForm.cs b/Million Buyer/MainForm.cs index bf55d0c..97ef481 100644 --- a/Million Buyer/MainForm.cs +++ b/Million Buyer/MainForm.cs @@ -238,6 +238,12 @@ namespace Million_Buyer item.CreateOrderTime.ToString("yyyy-MM-dd HH:mm:ss") }, null); } + + + var tempData = orderList.Select(t => t.Uuid).Distinct().ToList(); + var count = tempData.Count + buyList.Count; + buyCycleCount = count; + lb_BuyMarketCount.Text = buyCycleCount.ToString(); })); //1초에 한번씩 부르게 처리 @@ -342,6 +348,9 @@ namespace Million_Buyer CommonProperty.subIndicatorStateManagement[item.IndexString] = dic; } + // TODO 이미 구매되어 있는 종목에 대한 기본 데이터 Setting 필요 + + firstFlag = 1; InsertLog("Deafult Data Setting 완료.."); sw.Stop(); @@ -484,7 +493,7 @@ namespace Million_Buyer var time = DateTime.Now; var sellItem = recentlyData; var valDic = ResultLogicManager.GetIndicateValue(sellItem.CalculateFlag, totalIndicatorList, sellItem); - sellItem.SellValue = OrderbookManager.GetAskPrice(CalculateManager.GetConditionValue(sellRex, valDic, sellItem.CalculateFlag), false); + sellItem.SellValue = OrderbookManager.GetAskPrice(CalculateManager.GetConditionValue(sellRex, valDic, sellItem.CalculateFlag)); sellItem.SellTime = time; var buyCandleData = buyItem.CandleDataLists_Im[0]; @@ -539,7 +548,7 @@ namespace Million_Buyer } } - var moneyVal = (sellVal * (1 - 0.0005) - buyCandleData.BuyValue * (1 - 0.0005)) * result.SellCount; + var moneyVal = (sellVal * (1 - 0.0015) - buyCandleData.BuyValue * (1 - 0.0015)) * result.SellCount; tl_Result.AppendNode(new object[] { buyNode.GetValue("BuyMarket"), @@ -556,22 +565,6 @@ namespace Million_Buyer tl_BuyList.Nodes.Remove(buyNode); lb_BuyMarketCount.Text = buyList.Count.ToString(); - double totalRate = 0; - double totalMoneyValue = 0; - foreach (var resultData in resultDataList) - { - totalRate += resultData.FirstEarningRate; - if (!RealTimeMode) - { - // 총 돈량 측정 - totalMoneyValue += (resultData.SellValue * (1 - 0.0005) - resultData.BuyValueList[0] * (1 - 0.0005)) * resultData.SellCount; - } - } - - lb_TotalRate.Text = totalRate + "%"; - - if (!RealTimeMode) - lb_TotalMoneyValue.Text = totalMoneyValue + "원"; })); if (sw.Elapsed.TotalSeconds > 1) InsertLog("Sell 계산 로직 : " + sw.Elapsed.ToString()); diff --git a/Million/Manager/CalculateManager.cs b/Million/Manager/CalculateManager.cs index f69f121..92df4b0 100644 --- a/Million/Manager/CalculateManager.cs +++ b/Million/Manager/CalculateManager.cs @@ -627,8 +627,7 @@ namespace Million.Manager if (overlapData < subVal) continue; } - //최초 시점이 아닐 경우 - + //최초 시점이 아닐 경우 if ((subManagement != null && subManagement[coinFullName]) || !firstFlag) { if (!parent.IndicatorDic.ContainsKey(key)) continue; @@ -799,8 +798,6 @@ namespace Million.Manager if (value == 0 || overlapData == 0) continue; - - if (CompareSettingValueOfTranspierce(setUp.IndicatorOver, overlapData, value)) { var childList = new List(); @@ -937,7 +934,7 @@ namespace Million.Manager } } } - item.CalculateFlag[setUp.IndexString] = true; + item.CalculateFlag[setUp.IndexString] = true; } } } @@ -952,14 +949,14 @@ namespace Million.Manager { if (type == CommonProperty.Indicator_over.아래) { - if (overlapData > value) + if (overlapData >= value) { return true; } } else if (type == CommonProperty.Indicator_over.위) { - if (overlapData < value) + if (overlapData <= value) { return true; } @@ -980,14 +977,14 @@ namespace Million.Manager { if (type == CommonProperty.Indicator_over.아래) { - if (overlapData > value) + if (overlapData >= value) { return true; } } else if (type == CommonProperty.Indicator_over.위) { - if (overlapData < value) + if (overlapData <= value) { return true; } diff --git a/Million/Manager/ResultLogicManager.cs b/Million/Manager/ResultLogicManager.cs index 622697c..0f631c0 100644 --- a/Million/Manager/ResultLogicManager.cs +++ b/Million/Manager/ResultLogicManager.cs @@ -31,7 +31,25 @@ namespace Million.Manager var keyData = CalculateManager.GetKeyData(indicate); if (item.IndicatorDic.ContainsKey(keyData)) - valDic.Add(key.Key, item.IndicatorDic[keyData].overlapValue); + { + if(item.IndicatorDic[keyData].GetType() == typeof(IchimokData)) + { + var indiData = ((IchimokData)item.IndicatorDic[keyData]); + var val = indiData.GetOverValue(); + + var indi = ((IchimokuConditionSetup)indicate); + if (indi.IndicatorIchmokuOverLine == Indicator_IchmokuOverLine.선행스팬1) + val = indiData.value; + else if (indi.IndicatorIchmokuOverLine == Indicator_IchmokuOverLine.선행스팬2) + val = indiData.value2; + + valDic.Add(key.Key, val); + } + else + { + valDic.Add(key.Key, item.IndicatorDic[keyData].value); + } + } else valDic.Add(key.Key, 0); } diff --git a/Million/WebMangement/Upbit/UpbitAPI.cs b/Million/WebMangement/Upbit/UpbitAPI.cs index e96e38a..1869e6d 100644 --- a/Million/WebMangement/Upbit/UpbitAPI.cs +++ b/Million/WebMangement/Upbit/UpbitAPI.cs @@ -43,8 +43,9 @@ namespace Million.WebMangement.Upbit else if (candleType == MCandleTimeType.W1) url = UpbitURL_WCandleStick; else if (candleType == MCandleTimeType.MT1) url = UpbitURL_MTCandleStick; - var resResult = process.CallAPI(url, HttpMethod.Get, - new NameValueCollection { { "market", coinFullName }, { "to", (datetime == default(DateTime)) ? process.DateTime2String(DateTime.Now) : process.DateTime2String(datetime) }, { "count", count.ToString() } }); + var resResult = process.CallAPI(url, HttpMethod.Get, + new NameValueCollection { { "market", coinFullName }, { "to", (datetime == default(DateTime)) ? + process.DateTime2String(DateTime.Now) : process.DateTime2String(datetime) }, { "count", count.ToString() } }); List returnData; @@ -54,11 +55,16 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + resResult = process.CallAPI(url, HttpMethod.Get, + new NameValueCollection { { "market", coinFullName }, { "to", (datetime == default(DateTime)) ? + process.DateTime2String(DateTime.Now) : process.DateTime2String(datetime) }, { "count", count.ToString() } }); Thread.Sleep(500); + } } return returnData; } - + /// /// Get Market List Data /// @@ -76,9 +82,12 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + resResult = process.CallAPI(url, HttpMethod.Get); Thread.Sleep(500); + } } - return returnData; + return returnData; } /// @@ -98,7 +107,11 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + process.CallAPI(url, HttpMethod.Get); Thread.Sleep(500); + } + } return returnData; } @@ -111,7 +124,7 @@ namespace Million.WebMangement.Upbit public OrderableInformation GetOrderableInformation(string CoinFullName) { var url = UpbitURL_OrderChace; - var resResult = process.CallAPI(url, HttpMethod.Get, new NameValueCollection { { "market", CoinFullName } }); + var resResult = process.CallAPI(url, HttpMethod.Get, new NameValueCollection { { "market", CoinFullName } }); OrderableInformation returnData; @@ -121,7 +134,11 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + resResult = process.CallAPI(url, HttpMethod.Get, new NameValueCollection { { "market", CoinFullName } }); Thread.Sleep(500); + } + } return returnData; } @@ -134,7 +151,7 @@ namespace Million.WebMangement.Upbit public Order GetOrderInformation(string uuid) { var url = UpbitURL_Order; - var resResult = process.CallAPI(url, HttpMethod.Get, new NameValueCollection {{ "uuid", uuid } }); + var resResult = process.CallAPI(url, HttpMethod.Get, new NameValueCollection { { "uuid", uuid } }); Order returnData; @@ -144,7 +161,11 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + process.CallAPI(url, HttpMethod.Get, new NameValueCollection { { "uuid", uuid } }); Thread.Sleep(500); + } + } return returnData; } @@ -179,7 +200,10 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + resResult = process.CallAPI(url, HttpMethod.Get, data); Thread.Sleep(500); + } } return returnData; } @@ -198,15 +222,15 @@ namespace Million.WebMangement.Upbit string url = UpbitURL_Orders; var namevalCollection = new NameValueCollection { { "market", coinFullName }, - { "side", side.ToString() }, + { "side", side.ToString() }, { "ord_type", ord_type.ToString() } }; if (volume != 0) namevalCollection.Add("volume", volume.ToString()); - if(price != 0) + if (price != 0) namevalCollection.Add("price", price.ToString()); - var resResult = process.CallAPI(url, HttpMethod.Post, namevalCollection); + var resResult = process.CallAPI(url, HttpMethod.Post, namevalCollection); Order returnData; @@ -216,7 +240,11 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else - Thread.Sleep(300); + { + resResult = process.CallAPI(url, HttpMethod.Post, namevalCollection); + Thread.Sleep(500); + } + } return returnData; } @@ -239,9 +267,13 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + resResult = process.CallAPI(url, HttpMethod.Delete, new NameValueCollection { { "uuid", uuid } }); Thread.Sleep(500); + } + } - return returnData; + return returnData; } /// @@ -255,8 +287,8 @@ namespace Million.WebMangement.Upbit { string url = UpbitURL_Ticks; var resResult = process.CallAPI(url, HttpMethod.Get, new NameValueCollection { { "market", coinFullName }, - { "to", (to == default(DateTime)) ? process.DateTime2String(DateTime.Now) : process.DateTime2String(to) }, - { "count", count.ToString() } + { "to", (to == default(DateTime)) ? process.DateTime2String(DateTime.Now) : process.DateTime2String(to) }, + { "count", count.ToString() } }); List returnData; @@ -267,7 +299,14 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + resResult = process.CallAPI(url, HttpMethod.Get, new NameValueCollection { { "market", coinFullName }, + { "to", (to == default(DateTime)) ? process.DateTime2String(DateTime.Now) : process.DateTime2String(to) }, + { "count", count.ToString() } + }); Thread.Sleep(500); + } + } return returnData; } @@ -293,7 +332,11 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + resResult = process.CallAPI(url, HttpMethod.Get, new NameValueCollection { { "markets", list } }); Thread.Sleep(500); + } + } return returnData; } @@ -319,7 +362,11 @@ namespace Million.WebMangement.Upbit if (returnData != null) break; else + { + resResult = process.CallAPI(url, HttpMethod.Get, new NameValueCollection { { "markets", list } }); Thread.Sleep(500); + } + } return returnData; } diff --git a/Million/WebMangement/WebServiceFunctions.cs b/Million/WebMangement/WebServiceFunctions.cs index a7c52e7..1af2cc0 100644 --- a/Million/WebMangement/WebServiceFunctions.cs +++ b/Million/WebMangement/WebServiceFunctions.cs @@ -90,7 +90,7 @@ namespace Million.WebServices } catch (Exception e) { - return new List(); + return null; } } @@ -136,7 +136,7 @@ namespace Million.WebServices if (data.ContainsKey("trades")) { - var tradeList = JsonConvert.DeserializeObject>>(JsonConvert.SerializeObject(data["trades"]?.ToString())); + var tradeList = JsonConvert.DeserializeObject>>(data["trades"]?.ToString()); //(List>)data["trades"]; foreach (var item in tradeList) @@ -163,7 +163,7 @@ namespace Million.WebServices } catch (Exception e) { - return new Order(); + return null; } } @@ -206,7 +206,7 @@ namespace Million.WebServices } catch (Exception e) { - return new List(); + return null; } } @@ -262,7 +262,7 @@ namespace Million.WebServices } catch (Exception e) { - return returnData; + return null; } @@ -331,7 +331,7 @@ namespace Million.WebServices } catch (Exception e) { - return new List(); + return null; } } @@ -428,7 +428,7 @@ namespace Million.WebServices } catch (Exception e) { - return new List(); + return null; } } @@ -509,7 +509,7 @@ namespace Million.WebServices } catch (Exception e) { - return new OrderableInformation(); + return null; } }