From 8c6ae51c9a72e3c00e1470c4f4de1e27877080d0 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Tue, 5 Apr 2022 03:48:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8A=A82.1=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Binance.TradeRobot.Model/Base/Enums.cs | 26 ++++- .../Db/Order/ExecutionLog.cs | 24 +++++ .../Db/Order/LoanOrder.cs | 54 ++++++++++ .../Db/Order/SpotOrder.cs | 99 +++++++++++++++++++ .../Db/Policy/Spot/D21Policy.cs | 63 ++++++++++++ Binance.TradeRobot.Model/Db/Robot/Robot.cs | 2 +- .../Db/代码生成/__重新生成.bat | 2 +- 7 files changed, 267 insertions(+), 3 deletions(-) create mode 100644 Binance.TradeRobot.Model/Db/Order/ExecutionLog.cs create mode 100644 Binance.TradeRobot.Model/Db/Order/LoanOrder.cs create mode 100644 Binance.TradeRobot.Model/Db/Order/SpotOrder.cs create mode 100644 Binance.TradeRobot.Model/Db/Policy/Spot/D21Policy.cs diff --git a/Binance.TradeRobot.Model/Base/Enums.cs b/Binance.TradeRobot.Model/Base/Enums.cs index 7a8f251..a92006f 100644 --- a/Binance.TradeRobot.Model/Base/Enums.cs +++ b/Binance.TradeRobot.Model/Base/Enums.cs @@ -58,7 +58,7 @@ namespace Binance.TradeRobot.Model.Base /// /// 机器人状态 Stop=0,Runing=1 /// - public enum RobotStatus + public enum RobotState { Stop = 0, Runing = 1 @@ -114,6 +114,30 @@ namespace Binance.TradeRobot.Model.Base /// Gate_IO = 1 } + + /// + /// 借币状态 Loading=0 returned=1 + /// + public enum LoanState + { + Loaning, retured + } + + /// + /// 订单状态 + /// + public enum OrderState + { + Created + } + + /// + /// 交易方向 Buy=0,Sell=1 + /// + public enum TradeDirection + { + Buy, Sell + } #endregion } } diff --git a/Binance.TradeRobot.Model/Db/Order/ExecutionLog.cs b/Binance.TradeRobot.Model/Db/Order/ExecutionLog.cs new file mode 100644 index 0000000..41aac46 --- /dev/null +++ b/Binance.TradeRobot.Model/Db/Order/ExecutionLog.cs @@ -0,0 +1,24 @@ +using FreeSql.DataAnnotations; +using System; + +namespace Binance.TradeRobot.Model.Db +{ + + [Table(DisableSyncStructure = true)] + public partial class ExecutionLog { + + [ Column(IsPrimary = true)] + public long Id { get; set; } + + [Column(StringLength = 250, IsNullable = false)] + public string Content { get; set; } + + [Column(InsertValueSql = "getdate()")] + public DateTime CreateTime { get; set; } + + + public long RobotId { get; set; } + + } + +} diff --git a/Binance.TradeRobot.Model/Db/Order/LoanOrder.cs b/Binance.TradeRobot.Model/Db/Order/LoanOrder.cs new file mode 100644 index 0000000..05c59e1 --- /dev/null +++ b/Binance.TradeRobot.Model/Db/Order/LoanOrder.cs @@ -0,0 +1,54 @@ +using Binance.TradeRobot.Model.Base; +using FreeSql.DataAnnotations; +using System; + +namespace Binance.TradeRobot.Model.Db +{ + + [Table(DisableSyncStructure = true)] + public partial class LoanOrder + { + + [Column(IsPrimary = true)] + public long Id { get; set; } + + [Column(InsertValueSql = "getdate()")] + public DateTime CreateTime { get; set; } + + /// + /// 交易所Id + /// + + public int ExchangeId { get; set; } + + + [Column(MapType = typeof(int))] + public Enums.LoanState LoadState { get; set; } = Enums.LoanState.Loaning; + + /// + /// 借币金额 + /// + [Column(DbType = "decimal(18,8)")] + public decimal LoanAmount { get; set; } = 0.0M; + + /// + /// 借币利息 + /// + [Column(DbType = "decimal(18,8)")] + public decimal LoanFee { get; set; } = 0.0M; + + [Column(StringLength = 50, IsNullable = false)] + public string LoanOrderId { get; set; } + + + public DateTime ReturnTime { get; set; } + + + public long RobotId { get; set; } + + + public long SpotOrderId { get; set; } + + } + +} diff --git a/Binance.TradeRobot.Model/Db/Order/SpotOrder.cs b/Binance.TradeRobot.Model/Db/Order/SpotOrder.cs new file mode 100644 index 0000000..93dee84 --- /dev/null +++ b/Binance.TradeRobot.Model/Db/Order/SpotOrder.cs @@ -0,0 +1,99 @@ +using Binance.TradeRobot.Model.Base; +using FreeSql.DataAnnotations; +using System; + +namespace Binance.TradeRobot.Model.Db +{ + + [Table(DisableSyncStructure = true)] + public partial class SpotOrder + { + + [Column(IsPrimary = true)] + public long Id { get; set; } + + [Column(InsertValueSql = "getdate()")] + public DateTime CreateTime { get; set; } + + /// + /// 交易所Id + /// + + public int ExchangeId { get; set; } + + /// + /// 历史利润 + /// + [Column(DbType = "decimal(18,8)")] + public decimal HistoryTotalProfit { get; set; } = 0.0M; + + /// + /// 最后交易时间 + /// + + public DateTime? LastTradeTime { get; set; } + + /// + /// 交易策略 + /// + + public int PolicyType { get; set; } + + /// + /// 订单利润 + /// + [Column(DbType = "decimal(18,8)")] + public decimal Profit { get; set; } = 0.0M; + + + public long RobotId { get; set; } + + + [Column(MapType = typeof(int))] + public Enums.OrderState States { get; set; } + + [Column(MapType = typeof(int))] + public Enums.TradeDirection TradeDirection { get; set; } + + [Column(StringLength = 50, IsNullable = false)] + public string Symbol { get; set; } + + /// + /// 成交总额 + /// + [Column(DbType = "decimal(18,8)")] + public decimal TradeAmount { get; set; } = 0.0M; + + /// + /// 交易次数 + /// + + public int TradeCount { get; set; } = 0; + + /// + /// 手续费 + /// + [Column(DbType = "decimal(18,8)")] + public decimal TradeFee { get; set; } = 0.0M; + + /// + /// 交易手续费单位 + /// + [Column(StringLength = 15, IsNullable = false)] + public string TradeFeeUnit { get; set; } + + /// + /// 成交均价 + /// + [Column(DbType = "decimal(18,8)")] + public decimal TradePrice { get; set; } = 0.0M; + + /// + /// 交易量 + /// + [Column(DbType = "decimal(18,8)")] + public decimal TradeQuantity { get; set; } + + } + +} diff --git a/Binance.TradeRobot.Model/Db/Policy/Spot/D21Policy.cs b/Binance.TradeRobot.Model/Db/Policy/Spot/D21Policy.cs new file mode 100644 index 0000000..a3c4403 --- /dev/null +++ b/Binance.TradeRobot.Model/Db/Policy/Spot/D21Policy.cs @@ -0,0 +1,63 @@ +using Binance.TradeRobot.Model.Base; +using FreeSql.DataAnnotations; +using System; + +namespace Binance.TradeRobot.Model.Db +{ + + [Table(DisableSyncStructure = true)] + public partial class D21Policy + { + + [Column(IsPrimary = true)] + public long Id { get; set; } + + [Column(InsertValueSql = "getdate()")] + public DateTime CreateTime { get; set; } + + /// + /// 执行模式 + /// + + public int ExecutionMode { get; set; } = 0; + + /// + /// 是否开启增购 + /// + + public bool IsEnabledIncreasePurchase { get; set; } = true; + + /// + /// 是否开启错误信号补救 + /// + + public bool IsEnableRemedyForErrorCrossSignal { get; set; } = true; + + /// + /// 最大追高比例 + /// + [Column(DbType = "decimal(18,2)")] + public decimal MaxFollowPurchaseRatio { get; set; } = 0.0M; + + /// + /// 信号周期 + /// + + public Enums.SignalPeriod PeriodicSignal { get; set; } + + /// + /// 仓位 + /// + [Column(DbType = "decimal(18,8)")] + public decimal Position { get; set; } = 0.0M; + + + public long RobotId { get; set; } + + /// + /// 止损比例 + /// + public decimal StopLossRatio { get; set; } + } + +} diff --git a/Binance.TradeRobot.Model/Db/Robot/Robot.cs b/Binance.TradeRobot.Model/Db/Robot/Robot.cs index 99878cd..023481a 100644 --- a/Binance.TradeRobot.Model/Db/Robot/Robot.cs +++ b/Binance.TradeRobot.Model/Db/Robot/Robot.cs @@ -24,7 +24,7 @@ namespace Binance.TradeRobot.Model.Db public long RunningTime { get; set; } = 0; [Column(MapType = (typeof(int)))] - public Enums.RobotStatus State { get; set; } + public Enums.RobotState State { get; set; } [Column(StringLength = 50, IsNullable = false)] public string Symbol { get; set; } diff --git a/Binance.TradeRobot.Model/Db/代码生成/__重新生成.bat b/Binance.TradeRobot.Model/Db/代码生成/__重新生成.bat index 9a24191..00aec37 100644 --- a/Binance.TradeRobot.Model/Db/代码生成/__重新生成.bat +++ b/Binance.TradeRobot.Model/Db/代码生成/__重新生成.bat @@ -1 +1 @@ -FreeSql.Generator -Razor 1 -NameOptions 1,0,0,0 -NameSpace Binance.TradeRobot.Model.Db -DB "SqlServer,data source=18.179.56.42;initial catalog=Binance.TradeRobot.DB;User Id=sa;Password=kaicn1132+-;TrustServerCertificate=true;pooling=true;max pool size=2" -FileName "{name}.cs" +FreeSql.Generator -Razor 1 -NameOptions 1,0,0,0 -NameSpace Binance.TradeRobot.Model.Db -DB "SqlServer,data source=.;initial catalog=Binance.TradeRobot.DB;User Id=sa;Password=pc911103;TrustServerCertificate=true;pooling=true;max pool size=2" -FileName "{name}.cs"