From 0b95b4bf32d2b373a3b8c586a383fdd5ac7d098e Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sun, 3 Apr 2022 04:04:44 +0800 Subject: [PATCH] =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E6=89=80Id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Binance.TradeRobot.API.xml | 3 ++- .../Controllers/ExchangeAccountController.cs | 5 +++-- .../Binance.TradeRobot.Business.xml | 3 ++- .../Business/ExchangeBusiness.cs | 6 ++++-- .../Business/RobotBusiness.cs | 3 ++- Binance.TradeRobot.Model/Base/Enums.cs | 18 +++++++++++++++++ .../Binance.TradeRobot.Model.xml | 20 +++++++++++++++++++ .../Db/Exchange/ExchangeAccount.cs | 3 +++ Binance.TradeRobot.Model/Db/Robot/Robot.cs | 2 ++ .../Db/Robot/RobotAccount.cs | 5 +++++ .../Db/User/UserAccountProfitLossRecord.cs | 3 +++ .../Exchange/AddExchangeAccountRequest.cs | 2 ++ .../Dto/Request/Robot/AddRobotRequest.cs | 2 ++ 13 files changed, 68 insertions(+), 7 deletions(-) diff --git a/Binance.TradeRobot.API/Binance.TradeRobot.API.xml b/Binance.TradeRobot.API/Binance.TradeRobot.API.xml index a4bb4d5..d30aeb6 100644 --- a/Binance.TradeRobot.API/Binance.TradeRobot.API.xml +++ b/Binance.TradeRobot.API/Binance.TradeRobot.API.xml @@ -23,11 +23,12 @@ 交易策略 - + 获取APIKey未使用的交易所账户列表 + diff --git a/Binance.TradeRobot.API/Controllers/ExchangeAccountController.cs b/Binance.TradeRobot.API/Controllers/ExchangeAccountController.cs index eb88f78..64b17cb 100644 --- a/Binance.TradeRobot.API/Controllers/ExchangeAccountController.cs +++ b/Binance.TradeRobot.API/Controllers/ExchangeAccountController.cs @@ -53,11 +53,12 @@ namespace Binance.TradeRobot.API.Controllers /// 获取APIKey未使用的交易所账户列表 /// /// + /// /// [HttpGet("{tradePolicy}")] - public IList GetNoUsedExchangeAccountList([FromRoute]Enums.TradePolicy tradePolicy) + public IList GetNoUsedExchangeAccountList([FromRoute] Enums.TradePolicy tradePolicy, [FromRoute] Enums.Exchange exchangeId) { - return exchangeBusiness.GetNoUsedExchangeAccountList(tradePolicy); + return exchangeBusiness.GetNoUsedExchangeAccountList(tradePolicy, exchangeId); } } } diff --git a/Binance.TradeRobot.Business/Binance.TradeRobot.Business.xml b/Binance.TradeRobot.Business/Binance.TradeRobot.Business.xml index 0d455e1..ea5a435 100644 --- a/Binance.TradeRobot.Business/Binance.TradeRobot.Business.xml +++ b/Binance.TradeRobot.Business/Binance.TradeRobot.Business.xml @@ -4,11 +4,12 @@ Binance.TradeRobot.Business - + 获取APIKey未使用交易所账户列表 + diff --git a/Binance.TradeRobot.Business/Business/ExchangeBusiness.cs b/Binance.TradeRobot.Business/Business/ExchangeBusiness.cs index ca0b772..b0b3421 100644 --- a/Binance.TradeRobot.Business/Business/ExchangeBusiness.cs +++ b/Binance.TradeRobot.Business/Business/ExchangeBusiness.cs @@ -135,10 +135,12 @@ namespace Binance.TradeRobot.Business.Exchange /// 获取APIKey未使用交易所账户列表 /// /// + /// /// - public IList GetNoUsedExchangeAccountList(Enums.TradePolicy tradePolicy) + public IList GetNoUsedExchangeAccountList(Enums.TradePolicy tradePolicy, Enums.Exchange exchangeId) { - var exchangeAccountList = fsql.Select().Where(ea => ea.TradePolicy == tradePolicy).ToList().Map>(); + var exchangeAccountList = fsql.Select().Where(ea => ea.TradePolicy == tradePolicy && ea.ExchangeId == exchangeId) + .ToList().Map>(); var accountIdList = exchangeAccountList.Select(ea => ea.Id); var exchangeAPIKeyList = fsql.Select().Where(k => k.RobotId == null && accountIdList.Contains(k.AccountId)) .ToList() diff --git a/Binance.TradeRobot.Business/Business/RobotBusiness.cs b/Binance.TradeRobot.Business/Business/RobotBusiness.cs index 6f798b1..b985941 100644 --- a/Binance.TradeRobot.Business/Business/RobotBusiness.cs +++ b/Binance.TradeRobot.Business/Business/RobotBusiness.cs @@ -51,7 +51,8 @@ namespace Binance.TradeRobot.Business Id = idGenerator.NewLong(), Symbol = addRobotRequest.Symbol, TradePolicy = addRobotRequest.TradePolicy, - BusinessType = addRobotRequest.TradePolicy.GetBusinessType() + BusinessType = addRobotRequest.TradePolicy.GetBusinessType(), + ExchangeId = addRobotRequest.ExchangeId, }; } diff --git a/Binance.TradeRobot.Model/Base/Enums.cs b/Binance.TradeRobot.Model/Base/Enums.cs index eed48b6..7a8f251 100644 --- a/Binance.TradeRobot.Model/Base/Enums.cs +++ b/Binance.TradeRobot.Model/Base/Enums.cs @@ -97,5 +97,23 @@ namespace Binance.TradeRobot.Model.Base _1M } #endregion + + #region 交易所 + + /// + /// Binance=0, Gate.io=1 + /// + public enum Exchange + { + /// + /// 币安 + /// + Binance = 0, + /// + /// 芝麻开门 + /// + Gate_IO = 1 + } + #endregion } } diff --git a/Binance.TradeRobot.Model/Binance.TradeRobot.Model.xml b/Binance.TradeRobot.Model/Binance.TradeRobot.Model.xml index 4ce0f16..fbb4d82 100644 --- a/Binance.TradeRobot.Model/Binance.TradeRobot.Model.xml +++ b/Binance.TradeRobot.Model/Binance.TradeRobot.Model.xml @@ -74,6 +74,21 @@ 信号周期 1m=0,3m=1,5m=2,15m=3,30m=4,1h=5,2h=6,4h=7,6h=8,8h=9,12h=10,1d=11,3d=12,1w=13,1M=14 + + + Binance=0, Gate.io=1 + + + + + 币安 + + + + + 芝麻开门 + + 业务类型 @@ -139,6 +154,11 @@ 盈利次数 + + + 总借币金额 + + 投资本金 diff --git a/Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs b/Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs index fe5d9ad..1cec070 100644 --- a/Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs +++ b/Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs @@ -33,6 +33,9 @@ namespace Binance.TradeRobot.Model.Db [Column(MapType = typeof(int))] public Enums.TradePolicy TradePolicy { get; set; } + [Column(MapType = typeof(int))] + public Enums.Exchange ExchangeId { get; set; } + } } diff --git a/Binance.TradeRobot.Model/Db/Robot/Robot.cs b/Binance.TradeRobot.Model/Db/Robot/Robot.cs index e361767..99878cd 100644 --- a/Binance.TradeRobot.Model/Db/Robot/Robot.cs +++ b/Binance.TradeRobot.Model/Db/Robot/Robot.cs @@ -32,6 +32,8 @@ namespace Binance.TradeRobot.Model.Db [Column(MapType = (typeof(int)))] public Enums.BusinessType BusinessType { get; set; } + [Column(MapType = (typeof(int)))] + public Enums.Exchange ExchangeId { get; set; } } } diff --git a/Binance.TradeRobot.Model/Db/Robot/RobotAccount.cs b/Binance.TradeRobot.Model/Db/Robot/RobotAccount.cs index 838922f..7d2538d 100644 --- a/Binance.TradeRobot.Model/Db/Robot/RobotAccount.cs +++ b/Binance.TradeRobot.Model/Db/Robot/RobotAccount.cs @@ -41,6 +41,11 @@ namespace Binance.TradeRobot.Model.Db /// public long WinCount { get; set; } = 0; + /// + /// 总借币金额 + /// + [Column(DbType = "decimal(18,8)")] + public decimal LoanAmount { get; set; } = 0.0M; } } diff --git a/Binance.TradeRobot.Model/Db/User/UserAccountProfitLossRecord.cs b/Binance.TradeRobot.Model/Db/User/UserAccountProfitLossRecord.cs index 46b3e86..fb08e16 100644 --- a/Binance.TradeRobot.Model/Db/User/UserAccountProfitLossRecord.cs +++ b/Binance.TradeRobot.Model/Db/User/UserAccountProfitLossRecord.cs @@ -54,6 +54,9 @@ namespace Binance.TradeRobot.Model.Db [Column(DbType = "decimal(18,8)")] public decimal UserProfit { get; set; } = 0.0M; + [Column(MapType = (typeof(int)))] + public Enums.Exchange ExchangeId { get; set; } + } } diff --git a/Binance.TradeRobot.Model/Dto/Request/Exchange/AddExchangeAccountRequest.cs b/Binance.TradeRobot.Model/Dto/Request/Exchange/AddExchangeAccountRequest.cs index a4b5f7d..0dce341 100644 --- a/Binance.TradeRobot.Model/Dto/Request/Exchange/AddExchangeAccountRequest.cs +++ b/Binance.TradeRobot.Model/Dto/Request/Exchange/AddExchangeAccountRequest.cs @@ -8,6 +8,8 @@ namespace Binance.TradeRobot.Model.Dto public string LoginName { get; set; } + public Enums.Exchange ExchangeId { get; set; } + /// /// 交易策略 /// diff --git a/Binance.TradeRobot.Model/Dto/Request/Robot/AddRobotRequest.cs b/Binance.TradeRobot.Model/Dto/Request/Robot/AddRobotRequest.cs index e1f86fe..3b13762 100644 --- a/Binance.TradeRobot.Model/Dto/Request/Robot/AddRobotRequest.cs +++ b/Binance.TradeRobot.Model/Dto/Request/Robot/AddRobotRequest.cs @@ -13,5 +13,7 @@ namespace Binance.TradeRobot.Model.Dto /// 交易所APIKeyId /// public long ExchangeAPIKeyId { get; set; } + + public Enums.Exchange ExchangeId { get; set; } } }