From b7079ed944a827741d2179311ef6bb945248234c Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Sat, 9 Apr 2022 00:32:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E4=BD=93=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Db/Exchange/ExchangeAPIKey.cs | 36 +++++++++---------- .../Db/Exchange/ExchangeAccount.cs | 25 ++++--------- .../Db/Order/ExecutionLog.cs | 8 ++--- .../Db/Order/LoanOrder.cs | 18 +++++----- .../Db/Order/SpotOrder.cs | 26 +++++++------- .../Db/Policy/Spot/D21Policy.cs | 15 ++++---- .../Db/Policy/UPrep/PyramidPolicy.cs | 9 +++-- Binance.TradeRobot.Model/Db/Robot/Robot.cs | 15 ++++---- .../Db/Robot/RobotAccount.cs | 12 ++++--- Binance.TradeRobot.Model/Db/User/User.cs | 10 +++--- .../Db/User/UserAccountFundChangeRecord.cs | 13 ++++--- .../Db/User/UserAccountProfitLossRecord.cs | 20 +++++------ .../Db/代码生成/Exchangeaccount.cs | 32 ----------------- .../Db/代码生成/Exchangeapikey.cs | 35 ------------------ 14 files changed, 100 insertions(+), 174 deletions(-) delete mode 100644 Binance.TradeRobot.Model/Db/代码生成/Exchangeaccount.cs delete mode 100644 Binance.TradeRobot.Model/Db/代码生成/Exchangeapikey.cs diff --git a/Binance.TradeRobot.Model/Db/Exchange/ExchangeAPIKey.cs b/Binance.TradeRobot.Model/Db/Exchange/ExchangeAPIKey.cs index 2339f66..1191c49 100644 --- a/Binance.TradeRobot.Model/Db/Exchange/ExchangeAPIKey.cs +++ b/Binance.TradeRobot.Model/Db/Exchange/ExchangeAPIKey.cs @@ -3,32 +3,28 @@ using System; namespace Binance.TradeRobot.Model.Db { + [Table(Name = "exchangeapikey", DisableSyncStructure = true)] + public partial class ExchangeAPIKey + { - [Table(DisableSyncStructure = true, Name = "exchangeapikey")] - public partial class ExchangeAPIKey - { + [Column(DbType = "bigint", IsPrimary = true)] + public long Id { get; set; } - [Column(IsPrimary = true, DbType = "bigint")] - public long Id { get; set; } + [Column(DbType = "bigint")] + public long AccountId { get; set; } - /// - /// 交易所账号Id - /// - [Column(DbType = "bigint")] - public long AccountId { get; set; } + [Column(StringLength = 100, IsNullable = false)] + public string APIKey { get; set; } - [Column(StringLength = 100, IsNullable = false)] - public string APIKey { get; set; } + [Column(DbType = "datetime")] + public DateTime CreateTime { get; set; } - [Column(DbType = "datetime")] - public DateTime CreateTime { get; set; } + [Column(DbType = "bigint")] + public long? RobotId { get; set; } - [Column(DbType = "bigint")] - public long? RobotId { get; set; } + [Column(StringLength = 100, IsNullable = false)] + public string SecretKey { get; set; } - [Column(StringLength = 100, IsNullable = false)] - public string SecretKey { get; set; } - - } + } } diff --git a/Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs b/Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs index 5b6c0c2..dd85109 100644 --- a/Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs +++ b/Binance.TradeRobot.Model/Db/Exchange/ExchangeAccount.cs @@ -5,41 +5,28 @@ using System; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true, Name = "exchangeaccount")] + [Table(Name = "exchangeaccount", DisableSyncStructure = true)] public partial class ExchangeAccount { - public ExchangeAccount() - { - CreateTime = DateTime.Now; - } [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } - /// - /// 业务类型 - /// - [Column(MapType = typeof(int))] + [Column(DbType = "int", MapType = typeof(int))] public Enums.BusinessType BusinessType { get; set; } [Column(DbType = "datetime")] public DateTime CreateTime { get; set; } - /// - /// 账号登录名 - /// + [Column(DbType = "int", MapType = typeof(int))] + public Enums.Exchange ExchangeId { get; set; } + [Column(StringLength = 50, IsNullable = false)] public string LoginName { get; set; } - /// - /// 交易策略 - /// - [Column(MapType = typeof(int))] + [Column(DbType = "int", 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/Order/ExecutionLog.cs b/Binance.TradeRobot.Model/Db/Order/ExecutionLog.cs index 41aac46..6c489dc 100644 --- a/Binance.TradeRobot.Model/Db/Order/ExecutionLog.cs +++ b/Binance.TradeRobot.Model/Db/Order/ExecutionLog.cs @@ -4,19 +4,19 @@ using System; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "executionlog", DisableSyncStructure = true)] public partial class ExecutionLog { - [ Column(IsPrimary = true)] + [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } [Column(StringLength = 250, IsNullable = false)] public string Content { get; set; } - [Column(InsertValueSql = "getdate()")] + [Column(DbType = "datetime")] public DateTime CreateTime { get; set; } - + [Column(DbType = "bigint")] public long RobotId { get; set; } } diff --git a/Binance.TradeRobot.Model/Db/Order/LoanOrder.cs b/Binance.TradeRobot.Model/Db/Order/LoanOrder.cs index 05c59e1..42dc5b2 100644 --- a/Binance.TradeRobot.Model/Db/Order/LoanOrder.cs +++ b/Binance.TradeRobot.Model/Db/Order/LoanOrder.cs @@ -5,24 +5,24 @@ using System; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "loanorder", DisableSyncStructure = true)] public partial class LoanOrder { - [Column(IsPrimary = true)] + [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } - [Column(InsertValueSql = "getdate()")] + [Column(DbType = "datetime")] public DateTime CreateTime { get; set; } /// /// 交易所Id /// + [Column(DbType = "int", MapType = typeof(int))] + public Enums.Exchange ExchangeId { get; set; } - public int ExchangeId { get; set; } - - [Column(MapType = typeof(int))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.LoanState LoadState { get; set; } = Enums.LoanState.Loaning; /// @@ -40,13 +40,13 @@ namespace Binance.TradeRobot.Model.Db [Column(StringLength = 50, IsNullable = false)] public string LoanOrderId { get; set; } - + [Column(DbType = "datetime")] public DateTime ReturnTime { get; set; } - + [Column(DbType = "bigint")] public long RobotId { get; set; } - + [Column(DbType = "bigint")] public long SpotOrderId { get; set; } } diff --git a/Binance.TradeRobot.Model/Db/Order/SpotOrder.cs b/Binance.TradeRobot.Model/Db/Order/SpotOrder.cs index 93dee84..f0bef2c 100644 --- a/Binance.TradeRobot.Model/Db/Order/SpotOrder.cs +++ b/Binance.TradeRobot.Model/Db/Order/SpotOrder.cs @@ -5,21 +5,21 @@ using System; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "spotorder", DisableSyncStructure = true)] public partial class SpotOrder { - [Column(IsPrimary = true)] + [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } - [Column(InsertValueSql = "getdate()")] + [Column(DbType = "datetime")] public DateTime CreateTime { get; set; } /// /// 交易所Id /// - - public int ExchangeId { get; set; } + [Column(DbType = "int", MapType = typeof(int))] + public Enums.Exchange ExchangeId { get; set; } /// /// 历史利润 @@ -30,14 +30,14 @@ namespace Binance.TradeRobot.Model.Db /// /// 最后交易时间 /// - + [Column(DbType = "datetime")] public DateTime? LastTradeTime { get; set; } /// /// 交易策略 /// - - public int PolicyType { get; set; } + [Column(DbType = "int", MapType = typeof(int))] + public Enums.TradePolicy PolicyType { get; set; } /// /// 订单利润 @@ -45,14 +45,14 @@ namespace Binance.TradeRobot.Model.Db [Column(DbType = "decimal(18,8)")] public decimal Profit { get; set; } = 0.0M; - + [Column(DbType = "bigint")] public long RobotId { get; set; } - [Column(MapType = typeof(int))] - public Enums.OrderState States { get; set; } + [Column(MapType = typeof(int), DbType = "int")] + public Enums.OrderState State { get; set; } - [Column(MapType = typeof(int))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.TradeDirection TradeDirection { get; set; } [Column(StringLength = 50, IsNullable = false)] @@ -67,7 +67,7 @@ namespace Binance.TradeRobot.Model.Db /// /// 交易次数 /// - + [Column(DbType = "int")] public int TradeCount { get; set; } = 0; /// diff --git a/Binance.TradeRobot.Model/Db/Policy/Spot/D21Policy.cs b/Binance.TradeRobot.Model/Db/Policy/Spot/D21Policy.cs index 61492af..8e1f938 100644 --- a/Binance.TradeRobot.Model/Db/Policy/Spot/D21Policy.cs +++ b/Binance.TradeRobot.Model/Db/Policy/Spot/D21Policy.cs @@ -5,20 +5,20 @@ using System; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "d21policy", DisableSyncStructure = true)] public partial class D21Policy { - [Column(IsPrimary = true)] + [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } - [Column(InsertValueSql = "getdate()")] + [Column(DbType = "datetime")] public DateTime CreateTime { get; set; } /// /// 执行模式 /// - [Column(MapType = typeof(int))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.ExecutionMode ExecutionMode { get; set; } = Enums.ExecutionMode.Both; /// @@ -42,7 +42,7 @@ namespace Binance.TradeRobot.Model.Db /// /// 信号周期 /// - + [Column(DbType = "int", MapType = typeof(int))] public Enums.SignalPeriod PeriodicSignal { get; set; } /// @@ -51,13 +51,14 @@ namespace Binance.TradeRobot.Model.Db [Column(DbType = "decimal(18,8)")] public decimal Position { get; set; } = 0.0M; - + [Column(DbType = "bigint")] public long RobotId { get; set; } /// /// 止损比例 /// - public decimal StopLossRatio { get; set; } + [Column(DbType = "decimal(18,2)")] + public decimal StopLossRatio { get; set; } = 0.0M; } } diff --git a/Binance.TradeRobot.Model/Db/Policy/UPrep/PyramidPolicy.cs b/Binance.TradeRobot.Model/Db/Policy/UPrep/PyramidPolicy.cs index 0a0603a..e780344 100644 --- a/Binance.TradeRobot.Model/Db/Policy/UPrep/PyramidPolicy.cs +++ b/Binance.TradeRobot.Model/Db/Policy/UPrep/PyramidPolicy.cs @@ -3,20 +3,22 @@ using FreeSql.DataAnnotations; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "pyramidpolicy", DisableSyncStructure = true)] public partial class PyramidPolicy { - [Column(IsPrimary = true)] + [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } - [Column(MapType = typeof(int))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.SignalPeriod SignalPeriod { get; set; } + [Column(DbType = "bigint")] public long RobotId { get; set; } /// /// ܸ˱(1-125) /// + [Column(DbType = "int")] public int Leverage { get; set; } = 1; /// @@ -28,6 +30,7 @@ namespace Binance.TradeRobot.Model.Db /// /// /// + [Column(DbType = "int")] public int Pyramid { get; set; } = 0; } diff --git a/Binance.TradeRobot.Model/Db/Robot/Robot.cs b/Binance.TradeRobot.Model/Db/Robot/Robot.cs index 737d1e2..31490e7 100644 --- a/Binance.TradeRobot.Model/Db/Robot/Robot.cs +++ b/Binance.TradeRobot.Model/Db/Robot/Robot.cs @@ -5,34 +5,35 @@ using System; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "robot", DisableSyncStructure = true)] public partial class Robot { - [Column(IsPrimary = true)] + [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } - [Column(InsertValueSql = "getdate()")] + [Column(DbType = "datetime")] public DateTime CreateTime { get; set; } - [Column(MapType = (typeof(int)))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.TradePolicy TradePolicy { get; set; } /// /// 运行时长(s) /// + [Column(DbType = "bigint")] public long RunningTime { get; set; } = 0; - [Column(MapType = (typeof(int)))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.RobotState State { get; set; } [Column(StringLength = 50, IsNullable = false)] public string Symbol { get; set; } - [Column(MapType = (typeof(int)))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.BusinessType BusinessType { get; set; } - [Column(MapType = (typeof(int)))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.Exchange ExchangeId { get; set; } #region RobotAccount Extension diff --git a/Binance.TradeRobot.Model/Db/Robot/RobotAccount.cs b/Binance.TradeRobot.Model/Db/Robot/RobotAccount.cs index 5b8b0e3..76d90a1 100644 --- a/Binance.TradeRobot.Model/Db/Robot/RobotAccount.cs +++ b/Binance.TradeRobot.Model/Db/Robot/RobotAccount.cs @@ -3,19 +3,20 @@ using FreeSql.DataAnnotations; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "robotaccount", DisableSyncStructure = true)] public partial class RobotAccount { - [Column(IsPrimary = true)] + [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } /// /// 平仓次数 /// - public long ClosePositionCount { get; set; } = 0; - + [Column(DbType = "int")] + public int ClosePositionCount { get; set; } = 0; + [Column(DbType = "bigint")] public long RobotId { get; set; } /// @@ -39,7 +40,8 @@ namespace Binance.TradeRobot.Model.Db /// /// 盈利次数 /// - public long WinCount { get; set; } = 0; + [Column(DbType = "int")] + public int WinCount { get; set; } = 0; /// /// 总借币金额 diff --git a/Binance.TradeRobot.Model/Db/User/User.cs b/Binance.TradeRobot.Model/Db/User/User.cs index d327eaa..5ef0740 100644 --- a/Binance.TradeRobot.Model/Db/User/User.cs +++ b/Binance.TradeRobot.Model/Db/User/User.cs @@ -4,19 +4,19 @@ using System; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "user", DisableSyncStructure = true)] public partial class User { - [Column(IsPrimary = true)] + [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } /// /// 投资本金 /// - [ Column(DbType = "decimal(18,8)")] + [Column(DbType = "decimal(18,8)")] public decimal CostAmount { get; set; } = 0.0M; - [Column(InsertValueSql = "getdate()")] + [Column(DbType = "datetime")] public DateTime? CreateTime { get; set; } /// @@ -28,7 +28,7 @@ namespace Binance.TradeRobot.Model.Db [Column(StringLength = 20)] public string Pwd { get; set; } - [Column(InsertValueSql = "getdate()")] + [Column(DbType = "datetime")] public DateTime? UpdateTime { get; set; } [Column(StringLength = 20)] diff --git a/Binance.TradeRobot.Model/Db/User/UserAccountFundChangeRecord.cs b/Binance.TradeRobot.Model/Db/User/UserAccountFundChangeRecord.cs index d084bb9..3a11fca 100644 --- a/Binance.TradeRobot.Model/Db/User/UserAccountFundChangeRecord.cs +++ b/Binance.TradeRobot.Model/Db/User/UserAccountFundChangeRecord.cs @@ -5,11 +5,11 @@ using System; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "useraccountfundchangerecord", DisableSyncStructure = true)] public partial class UserAccountFundChangeRecord { - [Column(IsPrimary = true)] + [Column(DbType = "bigint", IsPrimary = true)] public long Id { get; set; } /// @@ -18,28 +18,31 @@ namespace Binance.TradeRobot.Model.Db [Column(DbType = "decimal(18,8)")] public decimal ChangeAmount { get; set; } - [Column(InsertValueSql = "getdate()")] + [Column(DbType = "datetime")] public DateTime? CreateTime { get; set; } - [Column(MapType = typeof(int))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.FundDirection Direction { get; set; } - [Column(MapType = typeof(int))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.CapitalChangeType OperationType { get; set; } /// /// 操作者Id /// + [Column(DbType = "bigint")] public long OperationUserId { get; set; } /// /// 用户Id /// + [Column(DbType = "bigint")] public long UserId { get; set; } /// /// 对端用户Id /// + [Column(DbType = "bigint")] public long? ToUserId { get; set; } [Column(StringLength = 100)] diff --git a/Binance.TradeRobot.Model/Db/User/UserAccountProfitLossRecord.cs b/Binance.TradeRobot.Model/Db/User/UserAccountProfitLossRecord.cs index fb08e16..e26ea7d 100644 --- a/Binance.TradeRobot.Model/Db/User/UserAccountProfitLossRecord.cs +++ b/Binance.TradeRobot.Model/Db/User/UserAccountProfitLossRecord.cs @@ -5,14 +5,17 @@ using System; namespace Binance.TradeRobot.Model.Db { - [Table(DisableSyncStructure = true)] + [Table(Name = "useraccountprofitlossrecord", DisableSyncStructure = true)] public partial class UserAccountProfitLossRecord { + [Column(DbType = "bigint", IsPrimary = true)] + public long Id { get; set; } + /// /// 业务类型 /// - [Column(MapType = typeof(int))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.BusinessType BusinessType { get; set; } /// @@ -21,7 +24,7 @@ namespace Binance.TradeRobot.Model.Db [Column(DbType = "decimal(18,8)")] public decimal ChangeAmount { get; set; } = 0.0M; - [Column(InsertValueSql = "getdate()")] + [Column(DbType = "datetime")] public DateTime? CreateTime { get; set; } /// @@ -30,10 +33,7 @@ namespace Binance.TradeRobot.Model.Db [Column(DbType = "decimal(18,2)")] public decimal DividendRatio { get; set; } = 0.0M; - [Column(IsPrimary = true)] - public long Id { get; set; } - - + [Column(DbType = "bigint")] public long OrderId { get; set; } /// @@ -42,10 +42,10 @@ namespace Binance.TradeRobot.Model.Db [Column(DbType = "decimal(18,8)")] public decimal OrderProfit { get; set; } = 0.0M; - + [Column(DbType = "bigint")] public long RobotId { get; set; } - + [Column(DbType = "bigint")] public long UserId { get; set; } /// @@ -54,7 +54,7 @@ namespace Binance.TradeRobot.Model.Db [Column(DbType = "decimal(18,8)")] public decimal UserProfit { get; set; } = 0.0M; - [Column(MapType = (typeof(int)))] + [Column(MapType = typeof(int), DbType = "int")] public Enums.Exchange ExchangeId { get; set; } } diff --git a/Binance.TradeRobot.Model/Db/代码生成/Exchangeaccount.cs b/Binance.TradeRobot.Model/Db/代码生成/Exchangeaccount.cs deleted file mode 100644 index c40d8c8..0000000 --- a/Binance.TradeRobot.Model/Db/代码生成/Exchangeaccount.cs +++ /dev/null @@ -1,32 +0,0 @@ -using FreeSql.DatabaseModel;using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Newtonsoft.Json; -using FreeSql.DataAnnotations; - -namespace Binance.TradeRobot.Model.Db { - - [JsonObject(MemberSerialization.OptIn), Table(Name = "exchangeaccount", DisableSyncStructure = true)] - public partial class Exchangeaccount { - - [JsonProperty, Column(DbType = "bigint", IsPrimary = true)] - public long Id { get; set; } - - [JsonProperty, Column(DbType = "int")] - public int? BusinessType { get; set; } - - [JsonProperty, Column(DbType = "datetime")] - public DateTime? CreateTime { get; set; } - - [JsonProperty, Column(StringLength = 50)] - public string LoginName { get; set; } - - [JsonProperty, Column(DbType = "int")] - public int? TradePolicy { get; set; } - - } - -} diff --git a/Binance.TradeRobot.Model/Db/代码生成/Exchangeapikey.cs b/Binance.TradeRobot.Model/Db/代码生成/Exchangeapikey.cs deleted file mode 100644 index 93f46a5..0000000 --- a/Binance.TradeRobot.Model/Db/代码生成/Exchangeapikey.cs +++ /dev/null @@ -1,35 +0,0 @@ -using FreeSql.DatabaseModel;using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Newtonsoft.Json; -using FreeSql.DataAnnotations; - -namespace Binance.TradeRobot.Model.Db { - - [JsonObject(MemberSerialization.OptIn), Table(Name = "exchangeapikey", DisableSyncStructure = true)] - public partial class Exchangeapikey { - - [JsonProperty, Column(DbType = "bigint", IsPrimary = true)] - public long Id { get; set; } - - [JsonProperty, Column(DbType = "bigint")] - public long AccountId { get; set; } - - [JsonProperty, Column(StringLength = 100, IsNullable = false)] - public string APIKey { get; set; } - - [JsonProperty, Column(DbType = "datetime")] - public DateTime CreateTime { get; set; } - - [JsonProperty, Column(DbType = "bigint")] - public long? RobotId { get; set; } - - [JsonProperty, Column(StringLength = 100, IsNullable = false)] - public string SecretKey { get; set; } - - } - -}