diff --git a/Million Buyer/MainForm.Designer.cs b/Million Buyer/MainForm.Designer.cs index 4703eb0..93ba181 100644 --- a/Million Buyer/MainForm.Designer.cs +++ b/Million Buyer/MainForm.Designer.cs @@ -103,6 +103,9 @@ cb_BigMoneyVolType = new DevExpress.XtraEditors.ComboBoxEdit(); ck_BigMoneyVol = new System.Windows.Forms.CheckBox(); ck_BuyBigthanHighVal = new System.Windows.Forms.CheckBox(); + label5 = new System.Windows.Forms.Label(); + tb_SellNowCoinFullName = new System.Windows.Forms.TextBox(); + bt_SellNow = new System.Windows.Forms.Button(); groupBox1.SuspendLayout(); groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)tl_BuyList).BeginInit(); @@ -891,11 +894,43 @@ ck_BuyBigthanHighVal.Text = "Buy가격>고가"; ck_BuyBigthanHighVal.UseVisualStyleBackColor = true; // + // label5 + // + label5.AutoSize = true; + label5.Location = new System.Drawing.Point(1013, 945); + label5.Name = "label5"; + label5.Size = new System.Drawing.Size(59, 15); + label5.TabIndex = 24; + label5.Text = "바로 팔기"; + // + // tb_SellNowCoinFullName + // + tb_SellNowCoinFullName.Location = new System.Drawing.Point(1078, 939); + tb_SellNowCoinFullName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + tb_SellNowCoinFullName.Name = "tb_SellNowCoinFullName"; + tb_SellNowCoinFullName.Size = new System.Drawing.Size(108, 23); + tb_SellNowCoinFullName.TabIndex = 27; + // + // bt_SellNow + // + bt_SellNow.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + bt_SellNow.Location = new System.Drawing.Point(1192, 937); + bt_SellNow.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + bt_SellNow.Name = "bt_SellNow"; + bt_SellNow.Size = new System.Drawing.Size(75, 29); + bt_SellNow.TabIndex = 28; + bt_SellNow.Text = "Sellb"; + bt_SellNow.UseVisualStyleBackColor = true; + bt_SellNow.Click += bt_SellNow_Click; + // // MainForm // AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ClientSize = new System.Drawing.Size(1610, 979); + Controls.Add(bt_SellNow); + Controls.Add(tb_SellNowCoinFullName); + Controls.Add(label5); Controls.Add(groupBox4); Controls.Add(bt_AllSell); Controls.Add(splitContainerControl1); @@ -1020,6 +1055,9 @@ private System.Windows.Forms.CheckBox ck_SlopeSell; private DevExpress.XtraEditors.ComboBoxEdit cb_buy; private DevExpress.XtraEditors.ComboBoxEdit cb_sell; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox tb_SellNowCoinFullName; + private System.Windows.Forms.Button bt_SellNow; } } diff --git a/Million Buyer/MainForm.cs b/Million Buyer/MainForm.cs index d2d3179..2197083 100644 --- a/Million Buyer/MainForm.cs +++ b/Million Buyer/MainForm.cs @@ -65,14 +65,14 @@ namespace Million_Buyer private int BigMoneyVolCnt = 0; private bool BigMoneyVolFlag = false; - private MCandleTimeType BigMoneyVolType; - + private MCandleTimeType BigMoneyVolType; + private Dictionary slopeDic = new Dictionary(); private bool slopeFlag = false; private string indicatorNum = ""; private string slopeBuy = ""; private string slopeSell = ""; - + private Dictionary sellNowDic = new Dictionary(); public MainForm() { @@ -122,7 +122,7 @@ namespace Million_Buyer private void rd_Realtime_CheckedChanged(object sender, EventArgs e) { programMode = BuyerMode.BuyerRealtime; - SetReadOnly(true); + SetReadOnly(true); } /// @@ -133,7 +133,7 @@ namespace Million_Buyer private void rd_buyer_CheckedChanged(object sender, EventArgs e) { programMode = BuyerMode.Buyer; - SetReadOnly(false); + SetReadOnly(false); } /// @@ -192,11 +192,11 @@ namespace Million_Buyer TopVolFlag = cb_TopVol.Checked; BigMoneyVolFlag = ck_BigMoneyVol.Checked; - if(BigMoneyVolFlag) + if (BigMoneyVolFlag) BigMoneyVolType = (MCandleTimeType)Enum.Parse(typeof(MCandleTimeType), cb_BigMoneyVolType.Text.ToString()); BuyBigthanHighValFlag = ck_BuyBigthanHighVal.Checked; - if(BuyBigthanHighValFlag) + if (BuyBigthanHighValFlag) BuyBigthanHighValType = (MCandleTimeType)Enum.Parse(typeof(MCandleTimeType), cb_BigMoneyVolType.Text.ToString()); bt_BuyStart_Click(null, null); @@ -410,7 +410,7 @@ namespace Million_Buyer if (programMode == BuyerMode.BuyerRealtime) InsertLog("실시간 검증 구동 중.."); else if (programMode == BuyerMode.Buyer) - InsertLog("Buyer 구동 중.."); + InsertLog("Buyer 구동 중.."); var cnt = 0; sw.Start(); @@ -434,7 +434,7 @@ namespace Million_Buyer realTimeMsg = new RealtimeDataSettingManager(null, programMode, this.payment); var startDateTime = DateTime.Now; - var endDateTime = startDateTime; + var endDateTime = startDateTime; dataList = realTimeMsg.GetRealTimeCandleData(candleTypeList, startDateTime, endDateTime, 200); @@ -464,12 +464,12 @@ namespace Million_Buyer } lb_BuyMarketCount.Text = buyList.Count.ToString(); - })); + })); #endregion firstFlag = false; - + sw.Stop(); InsertLog("Deafult Data Setting 완료..\\r\n" + "Default 계산 시간 : " + sw.Elapsed.ToString()); LogManager.WriteLog("Default 계산 시간 : " + sw.Elapsed.ToString()); @@ -500,22 +500,22 @@ namespace Million_Buyer if (tickDataList == null) tickDataList = new List(); - if (tickDataList.Select(t => t.TrendType).Where(t=>t == "RISE").ToList().Count > tickDataList.Count * 0.7) + if (tickDataList.Select(t => t.TrendType).Where(t => t == "RISE").ToList().Count > tickDataList.Count * 0.7) { topVolTempCnt = (int)(topVolTempCnt * 15 / 10); } if (tickDataList.Count > topVolTempCnt) { - var AccumulateTradeVolume = tickDataList.OrderByDescending(t => t.AccumulateTradeVolume).Select(t=>t.CoinFullName).ToList(); + var AccumulateTradeVolume = tickDataList.OrderByDescending(t => t.AccumulateTradeVolume).Select(t => t.CoinFullName).ToList(); var AccumulateTradePrice = tickDataList.OrderByDescending(t => t.AccumulateTradePrice).Select(t => t.CoinFullName).ToList(); AccumulateTradeVolume.RemoveRange(topVolTempCnt, AccumulateTradeVolume.Count - topVolTempCnt); AccumulateTradePrice.RemoveRange(topVolTempCnt, AccumulateTradePrice.Count - topVolTempCnt); - foreach(var item in AccumulateTradePrice) + foreach (var item in AccumulateTradePrice) { - foreach(var item2 in AccumulateTradeVolume) + foreach (var item2 in AccumulateTradeVolume) { if (item == item2) filterNameList.Add(item); } @@ -553,7 +553,7 @@ namespace Million_Buyer // } // } //} - } + } } if (buyList.Count == 0) allSell = false; @@ -593,7 +593,7 @@ namespace Million_Buyer var recentlyData = DataManager.GetRecentlyData(dic, MCandleTimeType.M1, true); var recentlyDate = recentlyData.DateTime; - + if ((int)smallCandleType < 60) recentlyDate = recentlyDate.AddMinutes(-1 * (int)smallCandleType); else { @@ -749,13 +749,13 @@ namespace Million_Buyer if (beforeVal < recentlyVal) slopeDic[item] = true; } - else if(slopeBuy == "-") + else if (slopeBuy == "-") { if (beforeVal > recentlyVal) slopeDic[item] = true; - } + } } - } + } } } } @@ -768,9 +768,14 @@ namespace Million_Buyer } else { - if(this.account.Balance / 10 < 5000) + this.BeginInvoke(new Action(delegate () { - InsertLog("5000원이 안됨 " + this.account.Balance / 10); + this.SetAccountData(); + })); + + if (this.account.Balance / 10 < 5000) + { + InsertLog("5000원이 안됨 " + this.account.Balance / 5); continue; } @@ -778,7 +783,7 @@ namespace Million_Buyer for (var i = 0; i < 3; i++) buyValueTick = OrderbookManager.GetAskPrice(buyValueTick + 0.01, true); - recentlyData.BuyCount = Math.Round((this.account.Balance / 10) / buyValueTick, 8); + recentlyData.BuyCount = Math.Round((this.account.Balance / 5) / buyValueTick, 8); var orderData = OrderBuy(item, recentlyData.BuyCount, buyValueTick); if (orderData == null) @@ -789,12 +794,9 @@ namespace Million_Buyer buyData.Uuid = orderData.Uuid; recentlyData.BuyValue = orderData.OrderPrice; - + buyCycleCount++; - this.BeginInvoke(new Action(delegate () - { - this.SetAccountData(); - })); + } buyList.Add(buyData); @@ -850,6 +852,12 @@ namespace Million_Buyer } } + if(sellNowDic.ContainsKey(item) && sellNowDic[item]) + { + str = "exception"; + flag = true; + } + if (!flag) { var buyItem = buyList.FirstOrDefault(x => x.ConGoodsData.CoinFullName == item); @@ -895,10 +903,11 @@ namespace Million_Buyer if (slopeFlag) { + if (!slopeDic.ContainsKey(item)) slopeDic[item] = true; if (slopeDic[item]) { var indi = totalIndicatorList.FirstOrDefault(t => t.IndexString == indicatorNum); - + if (indi != null) { var timeType = indi.MCandleTimeType; @@ -923,7 +932,7 @@ namespace Million_Buyer slopeDic[item] = false; flag = true; } - + } else if (slopeSell == "-") { @@ -931,7 +940,7 @@ namespace Million_Buyer { slopeDic[item] = false; flag = true; - } + } } } } @@ -950,7 +959,7 @@ namespace Million_Buyer //{ // flag = true; //} - } + } } if (flag) @@ -987,8 +996,8 @@ namespace Million_Buyer var sellOrder = OrderSell(buyItem.ConGoodsData.CoinFullName, buyItem.Uuid, sellVal); result.SellCount = sellOrder.ExecutedVolume; - if(sellVal == 0) - { + if (sellVal == 0) + { sellVal = sellItem.SellValue; } @@ -1328,8 +1337,9 @@ namespace Million_Buyer } private void SetAccountData() - { - this.account = this.accounts.FirstOrDefault(t => t.Currency == cb_AccountList.Text); + { + this.accounts = CommonProperty.UpbitApi.GetAccounts(); + this.account = this.accounts.FirstOrDefault(t => t.Currency == cb_AccountList.Text); if (this.account == null) { @@ -1418,5 +1428,18 @@ namespace Million_Buyer { } + + private void bt_SellNow_Click(object sender, EventArgs e) + { + var sellNowCoinFullName = tb_SellNowCoinFullName.Text; + if (!string.IsNullOrEmpty(sellNowCoinFullName)) + { + sellNowDic[sellNowCoinFullName] = true; + } + else { + InsertLog("Sell Now CoinFullName 입력 바람"); + } + + } } } \ No newline at end of file diff --git a/Million/Manager/ResultLogicManager.cs b/Million/Manager/ResultLogicManager.cs index e9ec97f..a4d18ae 100644 --- a/Million/Manager/ResultLogicManager.cs +++ b/Million/Manager/ResultLogicManager.cs @@ -1,4 +1,5 @@ using DevExpress.CodeParser; +using DocumentFormat.OpenXml; using Million.Data; using Million.IndicatorConditionSetup; using System; @@ -49,7 +50,11 @@ namespace Million.Manager val = indiData.GetDownOverValue(); if (indi.SubIndicatorSetupType == SubIndicatorSetupType.크로스) - val = indiData.overlapValue; + { + if (programMode == BuyerMode.Buyer || programMode == BuyerMode.BuyerRealtime) + val = item.EndValue; + else val = item.IndicatorDic[keyData].overlapValue; + } valDic.Add(key.Key, val); } @@ -58,7 +63,9 @@ namespace Million.Manager var val = item.IndicatorDic[keyData].value; if (indicate.SubIndicatorSetupType == SubIndicatorSetupType.크로스) { - val = item.IndicatorDic[keyData].overlapValue; + if (programMode == BuyerMode.Buyer || programMode == BuyerMode.BuyerRealtime) + val = item.EndValue; + else val = item.IndicatorDic[keyData].overlapValue; } valDic.Add(key.Key, val);