Browse Source

下单

master
shanji 3 years ago
parent
commit
ca99fa1297
  1. 4
      Binance.TradeRobot.API/Controllers/ExchangeAccountController.cs
  2. 2
      Binance.TradeRobot.API/Controllers/SingalController.cs
  3. 13
      Binance.TradeRobot.Business/Binance.TradeRobot.Business.xml
  4. 8
      Binance.TradeRobot.Business/Business/ExchangeBusiness.cs
  5. 94
      Binance.TradeRobot.Business/Business/RobotBusiness.cs
  6. 12
      Binance.TradeRobot.Business/Business/SingalBusiness.cs
  7. 6
      Binance.TradeRobot.Business/Business/TradeBusiness/D21TradeBusiness.cs
  8. 11
      Binance.TradeRobot.Business/Business/TradeBusiness/ITradeBusiness.cs
  9. 10
      Binance.TradeRobot.Model/Base/MappingProfiles.cs
  10. 5
      Binance.TradeRobot.Model/Binance.TradeRobot.Model.xml
  11. 2
      Binance.TradeRobot.Model/Db/Exchange/SymbolInfo.cs
  12. 20
      Binance.TradeRobot.Model/Db/Robot/Robot.cs
  13. 25
      SDKAdapter/APIClient/BaseAPIClient.cs
  14. 32
      SDKAdapter/APIClient/BinanceAPIClient.cs
  15. 43
      SDKTestConsole/Program.cs

4
Binance.TradeRobot.API/Controllers/ExchangeAccountController.cs

@ -1,4 +1,4 @@
using Binance.TradeRobot.Business.Exchange;
using Binance.TradeRobot.Business;
using Binance.TradeRobot.Model.Base;
using Binance.TradeRobot.Model.Dto;
using Microsoft.AspNetCore.Authentication.JwtBearer;
@ -44,7 +44,7 @@ namespace Binance.TradeRobot.API.Controllers
/// <param name="exchange"></param>
/// <returns></returns>
[HttpGet("{exchange}")]
public IList<SymbolInfoResponse> GetSymbolList(Enums.Exchange exchange)
public IList<SymbolInfoResponse> GetSymbolList([FromRoute] Enums.Exchange exchange)
{
return exchangeBusiness.GetSymbolList(exchange);
}

2
Binance.TradeRobot.API/Controllers/SingalController.cs

@ -1,4 +1,4 @@
using Binance.TradeRobot.Business.Business;
using Binance.TradeRobot.Business;
using Binance.TradeRobot.Model.Dto;
using Microsoft.AspNetCore.Mvc;

13
Binance.TradeRobot.Business/Binance.TradeRobot.Business.xml

@ -4,7 +4,7 @@
<name>Binance.TradeRobot.Business</name>
</assembly>
<members>
<member name="M:Binance.TradeRobot.Business.Exchange.ExchangeBusiness.GetNoUsedExchangeAccountList(Binance.TradeRobot.Model.Base.Enums.TradePolicy,Binance.TradeRobot.Model.Base.Enums.Exchange)">
<member name="M:Binance.TradeRobot.Business.ExchangeBusiness.GetNoUsedExchangeAccountList(Binance.TradeRobot.Model.Base.Enums.TradePolicy,Binance.TradeRobot.Model.Base.Enums.Exchange)">
<summary>
获取APIKey未使用交易所账户列表
</summary>
@ -66,7 +66,7 @@
现货策略
</summary>
</member>
<member name="M:Binance.TradeRobot.Business.ITradeBusiness.TrendChanged``2(``0,``1)">
<member name="M:Binance.TradeRobot.Business.ITradeBusiness.TrendChanged``2(``0,``1,Binance.TradeRobot.Model.Dto.SymbolInfoResponse)">
<summary>
趋势变化
</summary>
@ -74,8 +74,9 @@
<typeparam name="T1"></typeparam>
<param name="singalRequest"></param>
<param name="robot"></param>
<param name="symbolInfo"></param>
</member>
<member name="M:Binance.TradeRobot.Business.ITradeBusiness.LongCross``2(``0,``1,System.Boolean)">
<member name="M:Binance.TradeRobot.Business.ITradeBusiness.LongCross``2(``0,``1,System.Boolean,Binance.TradeRobot.Model.Dto.SymbolInfoResponse)">
<summary>
多交叉
</summary>
@ -84,8 +85,9 @@
<param name="singalRequest"></param>
<param name="robot"></param>
<param name="isRemedy">是否为补救信号</param>
<param name="symbolInfo"></param>
</member>
<member name="M:Binance.TradeRobot.Business.ITradeBusiness.ShortCross``2(``0,``1,System.Boolean)">
<member name="M:Binance.TradeRobot.Business.ITradeBusiness.ShortCross``2(``0,``1,System.Boolean,Binance.TradeRobot.Model.Dto.SymbolInfoResponse)">
<summary>
空交叉
</summary>
@ -93,7 +95,8 @@
<typeparam name="T1"></typeparam>
<param name="singalRequest"></param>
<param name="robot"></param>
<param name="isRemedy">是否为补救信号</param>
<param name="isRemedy">是否为补救信号</param>'
<param name="symbolInfo"></param>
</member>
<member name="M:Binance.TradeRobot.Business.UserBusiness.OneWayAssetChange(System.Int64,System.Decimal,System.Int64,Binance.TradeRobot.Model.Base.Enums.CapitalChangeType,System.String)">
<summary>

8
Binance.TradeRobot.Business/Business/ExchangeBusiness.cs

@ -16,7 +16,7 @@ using System.Threading;
using System.Threading.Tasks;
using Yitter.IdGenerator;
namespace Binance.TradeRobot.Business.Exchange
namespace Binance.TradeRobot.Business
{
[BatchRegistration(ServiceLifetime.Singleton, RegistrationType.Self)]
public class ExchangeBusiness : BaseBusiness
@ -74,6 +74,12 @@ namespace Binance.TradeRobot.Business.Exchange
return fsql.Select<SymbolInfo>().Where(s => s.ExchangeId == exchange).ToList<SymbolInfoResponse>();
}
public SymbolInfoResponse GetSymbol(Enums.Exchange exchange, string symbol)
{
return fsql.Select<SymbolInfo>().Where(s => s.ExchangeId == exchange && s.Symbol == symbol).ToOne<SymbolInfoResponse>();
}
public void AddExchangeAccount(AddExchangeAccountRequest addExchangeAccountRequest)
{
if (addExchangeAccountRequest.Id == 0 ||

94
Binance.TradeRobot.Business/Business/RobotBusiness.cs

@ -199,56 +199,57 @@ namespace Binance.TradeRobot.Business
bool isLoadRecentTradeProfit = true,
bool isLoadAPIKey = false)
{
var robotList = fsql.Select<Robot, SymbolInfo, RobotAccount, D21Policy, ExchangeAPIKey>().InnerJoin((r, s, ra, d, e) => r.Id == ra.RobotId)
.InnerJoin((r, s, ra, d, e) => r.Symbol == s.Symbol && r.ExchangeId == s.ExchangeId)
.InnerJoin((r, s, ra, d, e) => r.Id == d.RobotId)
.InnerJoin((r, s, ra, d, e) => r.Id == e.RobotId)
.WhereIf(robotState != null, (r, s, ra, d, e) => r.State == robotState)
.WhereIf(signalPeriod != null, (r, s, ra, d, e) => d.PeriodicSignal == signalPeriod)
.WhereIf(!string.IsNullOrEmpty(symbol), (r, s, ra, d, e) => r.Symbol == symbol)
.Where((r, s, ra, d, e) => r.TradePolicy == Enums.TradePolicy.D21)
.ToList((r, s, ra, d, e) => new Robot()
{
Id = r.Id,
BusinessType = r.BusinessType,
ExchangeId = r.ExchangeId,
Symbol = r.Symbol,
State = r.State,
RunningTime = r.RunningTime,
CreateTime = r.CreateTime,
TradePolicy = r.TradePolicy,
var robotList = fsql.Select<Robot, RobotAccount, D21Policy, ExchangeAPIKey>().InnerJoin((r, ra, d, e) => r.Id == ra.RobotId)
.InnerJoin((r, ra, d, e) => r.Id == d.RobotId)
.InnerJoin((r, ra, d, e) => r.Id == e.RobotId)
.WhereIf(robotState != null, (r, ra, d, e) => r.State == robotState)
.WhereIf(signalPeriod != null, (r, ra, d, e) => d.PeriodicSignal == signalPeriod)
.WhereIf(!string.IsNullOrEmpty(symbol), (r, ra, d, e) => r.Symbol == symbol)
.Where((r, ra, d, e) => r.TradePolicy == Enums.TradePolicy.D21)
.ToList((r, ra, d, e) => new Robot
{
Id = r.Id,
BusinessType = r.BusinessType,
ExchangeId = r.ExchangeId,
Symbol = r.Symbol,
State = r.State,
RunningTime = r.RunningTime,
CreateTime = r.CreateTime,
TradePolicy = r.TradePolicy,
SymbolId = s.Id,
SymbolSaleQuantityAccuracy = s.SaleQuantityAccuracy,
//SymbolId = s.Id,
//SymbolSaleQuantityAccuracy = s.SaleQuantityAccuracy,
RobotAccountId = ra.Id,
ClosePositionCount = ra.ClosePositionCount,
WinCount = ra.WinCount,
LoanAmount = ra.LoanAmount,
SoptCurrentcyAmount = ra.SoptCurrentcyAmount,
SpotCurrencyQuantity = ra.SpotCurrencyQuantity,
TotalProfit = ra.TotalProfit,
RobotAccountId = ra.Id,
ClosePositionCount = ra.ClosePositionCount,
WinCount = ra.WinCount,
LoanAmount = ra.LoanAmount,
SoptCurrentcyAmount = ra.SoptCurrentcyAmount,
SpotCurrencyQuantity = ra.SpotCurrencyQuantity,
TotalProfit = ra.TotalProfit,
ExchangeAccountId = e.AccountId,
ExchangeAPIKey = e.APIKey,
ExchangeSecretKey = e.SecretKey,
D21ExecutionMode = d.ExecutionMode,
D21IsEnabledIncreasePurchase = d.IsEnabledIncreasePurchase,
D21IsEnableRemedyForErrorCrossSignal = d.IsEnableRemedyForErrorCrossSignal,
D21MaxFollowPurchaseRatio = d.MaxFollowPurchaseRatio,
D21PeriodicSignal = d.PeriodicSignal,
D21PolicyId = d.Id,
D21Position = d.Position,
D21Assets = d.Assets,
D21Level1PositionStopLossRatio = d.Level1PositionStopLossRatio,
D21Level1PriceStopLossRatio = d.Level1PriceStopLossRatio,
D21Level2PositionStopLossRatio = d.Level2PositionStopLossRatio,
D21Level2PriceStopLossRatio = d.Level2PriceStopLossRatio,
D21MaxExchangeLoanRatio = d.MaxExchangeLoanRatio,
D21MaxSystemLoanRatio = d.MaxSystemLoanRatio,
D21CreateTime = d.CreateTime
}).Map<IList<D21PolicyRobotResponse>>();
ExchangeAccountId = e.AccountId,
ExchangeAPIKey = e.APIKey,
ExchangeSecretKey = e.SecretKey,
D21ExecutionMode = d.ExecutionMode,
D21IsEnabledIncreasePurchase = d.IsEnabledIncreasePurchase,
D21IsEnableRemedyForErrorCrossSignal = d.IsEnableRemedyForErrorCrossSignal,
D21MaxFollowPurchaseRatio = d.MaxFollowPurchaseRatio,
D21PeriodicSignal = d.PeriodicSignal,
D21PolicyId = d.Id,
D21Position = d.Position,
D21Assets = d.Assets,
D21Level1PositionStopLossRatio = d.Level1PositionStopLossRatio,
D21Level1PriceStopLossRatio = d.Level1PriceStopLossRatio,
D21Level2PositionStopLossRatio = d.Level2PositionStopLossRatio,
D21Level2PriceStopLossRatio = d.Level2PriceStopLossRatio,
D21MaxExchangeLoanRatio = d.MaxExchangeLoanRatio,
D21MaxSystemLoanRatio = d.MaxSystemLoanRatio,
D21CreateTime = d.CreateTime
}).Map<IList<D21PolicyRobotResponse>>();
if (isLoadRecentTradeProfit)
{
//统计近期订单利润
@ -259,7 +260,6 @@ namespace Binance.TradeRobot.Business
foreach (var r in robotList)
r.ExchangeAPIKey = null;
}
return robotList;
}
}

12
Binance.TradeRobot.Business/Business/SingalBusiness.cs

@ -1,5 +1,6 @@
using Binance.TradeRobot.Common.DI;
using Binance.TradeRobot.Model.Base;
using Binance.TradeRobot.Model.Db;
using Binance.TradeRobot.Model.Dto;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
@ -8,12 +9,13 @@ using System.Linq;
using System.Threading.Tasks;
using Yitter.IdGenerator;
namespace Binance.TradeRobot.Business.Business
namespace Binance.TradeRobot.Business
{
[BatchRegistration(ServiceLifetime.Singleton, RegistrationType.Self)]
public class SingalBusiness : BaseBusiness
{
private RobotBusiness robotBusiness;
private ExchangeBusiness exchangeBusiness;
private IEnumerable<ITradeBusiness> tradeBusinessList;
public SingalBusiness(IFreeSql fsql,
@ -21,9 +23,11 @@ namespace Binance.TradeRobot.Business.Business
IIdGenerator idGenerator,
IMemoryCache memoryCache,
RobotBusiness robotBusiness,
ExchangeBusiness exchangeBusiness,
IEnumerable<ITradeBusiness> tradeBusinessList) : base(fsql, logManager, idGenerator, memoryCache)
{
this.robotBusiness = robotBusiness;
this.exchangeBusiness = exchangeBusiness;
this.tradeBusinessList = tradeBusinessList;
}
@ -34,7 +38,9 @@ namespace Binance.TradeRobot.Business.Business
if (robotList == null || robotList.Count() == 0)
throw new BusinessException("未找到符合条件的机器人");
//var robot = robotList.FirstOrDefault();
var symbolInfo = exchangeBusiness.GetSymbol(robotList[0].ExchangeId, robotList[0].Symbol);
if (symbolInfo == null)
throw new BusinessException($"未找到交易对{robotList[0].Symbol}({robotList[0].ExchangeId})");
var d21TradeBusiness = tradeBusinessList.FirstOrDefault(t => t.TradePolicy == Enums.TradePolicy.D21);
foreach (var robot in robotList)
@ -43,7 +49,7 @@ namespace Binance.TradeRobot.Business.Business
{
case Enums.SingalType.:
case Enums.SingalType.:
Task.Factory.StartNew(() => d21TradeBusiness.TrendChanged(d21SingalRequest, robot));
Task.Factory.StartNew(() => d21TradeBusiness.TrendChanged(d21SingalRequest, robot, symbolInfo));
break;
case Enums.SingalType.:

6
Binance.TradeRobot.Business/Business/TradeBusiness/D21TradeBusiness.cs

@ -41,7 +41,7 @@ namespace Binance.TradeRobot.Business
};
}
public void TrendChanged<T, T1>(T singalRequest, T1 robot) where T : BaseSingalRequest where T1 : RobotResponse
public void TrendChanged<T, T1>(T singalRequest, T1 robot, SymbolInfoResponse symbolInfo) where T : BaseSingalRequest where T1 : RobotResponse
{
try
{
@ -67,7 +67,7 @@ namespace Binance.TradeRobot.Business
}
}
public void LongCross<T, T1>(T singalRequest, T1 robot, bool isRemedy) where T : BaseSingalRequest where T1 : RobotResponse
public void LongCross<T, T1>(T singalRequest, T1 robot, bool isRemedy, SymbolInfoResponse symbolInfo) where T : BaseSingalRequest where T1 : RobotResponse
{
string step = string.Empty;
var logList = new List<ExecutionLog>();
@ -247,7 +247,7 @@ namespace Binance.TradeRobot.Business
}
}
public void ShortCross<T, T1>(T singalRequest, T1 robot, bool isRemedy) where T : BaseSingalRequest where T1 : RobotResponse
public void ShortCross<T, T1>(T singalRequest, T1 robot, bool isRemedy, SymbolInfoResponse symbolInfo) where T : BaseSingalRequest where T1 : RobotResponse
{
}

11
Binance.TradeRobot.Business/Business/TradeBusiness/ITradeBusiness.cs

@ -14,7 +14,8 @@ namespace Binance.TradeRobot.Business
/// <typeparam name="T1"></typeparam>
/// <param name="singalRequest"></param>
/// <param name="robot"></param>
void TrendChanged<T, T1>(T singalRequest, T1 robot) where T : BaseSingalRequest where T1 : RobotResponse;
/// <param name="symbolInfo"></param>
void TrendChanged<T, T1>(T singalRequest, T1 robot, SymbolInfoResponse symbolInfo) where T : BaseSingalRequest where T1 : RobotResponse;
/// <summary>
/// 多交叉
@ -24,7 +25,8 @@ namespace Binance.TradeRobot.Business
/// <param name="singalRequest"></param>
/// <param name="robot"></param>
/// <param name="isRemedy">是否为补救信号</param>
void LongCross<T, T1>(T singalRequest, T1 robot, bool isRemedy) where T : BaseSingalRequest where T1 : RobotResponse;
/// <param name="symbolInfo"></param>
void LongCross<T, T1>(T singalRequest, T1 robot, bool isRemedy, SymbolInfoResponse symbolInfo) where T : BaseSingalRequest where T1 : RobotResponse;
/// <summary>
/// 空交叉
@ -33,7 +35,8 @@ namespace Binance.TradeRobot.Business
/// <typeparam name="T1"></typeparam>
/// <param name="singalRequest"></param>
/// <param name="robot"></param>
/// <param name="isRemedy">是否为补救信号</param>
void ShortCross<T, T1>(T singalRequest, T1 robot, bool isRemedy) where T : BaseSingalRequest where T1 : RobotResponse;
/// <param name="isRemedy">是否为补救信号</param>'
/// <param name="symbolInfo"></param>
void ShortCross<T, T1>(T singalRequest, T1 robot, bool isRemedy, SymbolInfoResponse symbolInfo) where T : BaseSingalRequest where T1 : RobotResponse;
}
}

10
Binance.TradeRobot.Model/Base/MappingProfiles.cs

@ -26,11 +26,11 @@ namespace Binance.TradeRobot.Model.Base
.ForPath(t => t.RobotAccount.WinCount, opt => opt.MapFrom(f => f.WinCount))
.ForPath(t => t.ExchangeAPIKey.AccountId, opt => opt.MapFrom(f => f.ExchangeAccountId))
.ForPath(t => t.ExchangeAPIKey.APIKey, opt => opt.MapFrom(f => f.ExchangeAPIKey))
.ForPath(t => t.ExchangeAPIKey.SecretKey, opt => opt.MapFrom(f => f.ExchangeSecretKey))
.ForPath(t => t.SymbolInfo.Id, opt => opt.MapFrom(f => f.SymbolId))
.ForPath(t => t.SymbolInfo.Symbol, opt => opt.MapFrom(f => f.Symbol))
.ForPath(t => t.SymbolInfo.SaleQuantityAccuracy, opt => opt.MapFrom(f => f.SymbolSaleQuantityAccuracy))
.ForPath(t => t.SymbolInfo.ExchangeId, opt => opt.MapFrom(f => f.ExchangeId));
.ForPath(t => t.ExchangeAPIKey.SecretKey, opt => opt.MapFrom(f => f.ExchangeSecretKey));
//.ForPath(t => t.SymbolInfo.Id, opt => opt.MapFrom(f => f.SymbolId))
//.ForPath(t => t.SymbolInfo.Symbol, opt => opt.MapFrom(f => f.Symbol))
//.ForPath(t => t.SymbolInfo.SaleQuantityAccuracy, opt => opt.MapFrom(f => f.SymbolSaleQuantityAccuracy))
//.ForPath(t => t.SymbolInfo.ExchangeId, opt => opt.MapFrom(f => f.ExchangeId));
CreateMap<Robot, D21PolicyRobotResponse>().IncludeBase<Robot, RobotResponse>()
.ForPath(t => t.D21Policy.Id, opt => opt.MapFrom(f => f.D21PolicyId))
.ForPath(t => t.D21Policy.RobotId, opt => opt.MapFrom(f => f.Id))

5
Binance.TradeRobot.Model/Binance.TradeRobot.Model.xml

@ -344,11 +344,6 @@
运行时长(s)
</summary>
</member>
<member name="P:Binance.TradeRobot.Model.Db.Robot.SymbolId">
<summary>
卖币精度
</summary>
</member>
<member name="P:Binance.TradeRobot.Model.Db.Robot.ClosePositionCount">
<summary>
平仓次数

2
Binance.TradeRobot.Model/Db/Exchange/SymbolInfo.cs

@ -15,7 +15,7 @@ namespace Binance.TradeRobot.Model.Db
[Column(DbType = "datetime")]
public DateTime? CreateTime { get; set; }
[Column(DbType = "int", MapType = typeof(int))]
[Column(MapType = typeof(int), DbType = "int")]
public Enums.Exchange ExchangeId { get; set; }
/// <summary>

20
Binance.TradeRobot.Model/Db/Robot/Robot.cs

@ -36,16 +36,16 @@ namespace Binance.TradeRobot.Model.Db
[Column(MapType = typeof(int), DbType = "int")]
public Enums.Exchange ExchangeId { get; set; }
#region Symbol Extension
/// <summary>
/// 卖币精度
/// </summary>
[Column(IsIgnore = true)]
public long SymbolId { get; set; }
[Column(IsIgnore = true)]
public int SymbolSaleQuantityAccuracy { get; set; }
#endregion
//#region Symbol Extension
//[Column(IsIgnore = true)]
//public long SymbolId { get; set; }
///// <summary>
///// 卖币精度
///// </summary>
//[Column(IsIgnore = true)]
//public int SymbolSaleQuantityAccuracy { get; set; }
//#endregion
#region RobotAccount Extension

25
SDKAdapter/APIClient/BaseAPIClient.cs

@ -67,5 +67,30 @@ namespace SDKAdapter.APIClient
{
throw new NotImplementedException();
}
/// <summary>
/// 逐仓杠杆下单接口
/// </summary>
/// <param name="symbol">交易对</param>
/// <param name="tradeDirection">交易方向</param>
/// <param name="orderType">订单类型</param>
/// <param name="quantity">基础币数量,卖单必传</param>
/// <param name="quoteAmount">报价币金额,市价买单必传</param>
/// <param name="price">下单价格,市价不传</param>
/// <param name="stopPrice">止损价格,与STOP_LOSS,STOP_LOSS_LIMIT一起使用</param>
/// <param name="newClientOrderId">客户端订单Id</param>
/// <returns>交易所订单Id</returns>
/// <exception cref="NotImplementedException"></exception>
public virtual long IsolatedMarginPlaceOrder(string symbol,
Enums.TradeDirection tradeDirection,
Enums.OrderType orderType,
decimal? quantity,
decimal? quoteAmount,
decimal? price,
decimal? stopPrice,
string newClientOrderId)
{
throw new NotImplementedException();
}
}
}

32
SDKAdapter/APIClient/BinanceAPIClient.cs

@ -1,5 +1,6 @@
using Binance.Net.Clients;
using Binance.Net.Objects;
using Binance.TradeRobot.Model.Base;
using CryptoExchange.Net.Authentication;
using SDKAdapter.Model;
using System;
@ -102,5 +103,36 @@ namespace SDKAdapter.APIClient
}
}
public override long IsolatedMarginPlaceOrder(string symbol,
Enums.TradeDirection tradeDirection,
Enums.OrderType orderType,
decimal? quantity,
decimal? quoteAmount,
decimal? price,
decimal? stopPrice,
string newClientOrderId)
{
var binanceOrderSite = (Binance.Net.Enums.OrderSide)(int)tradeDirection;
var binanceOrderType = (Binance.Net.Enums.SpotOrderType)(int)orderType;
Binance.Net.Enums.TimeInForce? timeInForce = null;
if (orderType == Enums.OrderType.STOP_LOSS_LIMIT)
timeInForce = Binance.Net.Enums.TimeInForce.GoodTillCanceled;
var r = binanceClient.SpotApi.Trading.PlaceMarginOrderAsync(symbol,
binanceOrderSite,
binanceOrderType,
quantity,
quoteAmount,
newClientOrderId,
price: price,
timeInForce: timeInForce,
stopPrice: stopPrice,
isIsolated: true,
orderResponseType: Binance.Net.Enums.OrderResponseType.Acknowledge).Result;
if (!r.Success)
throw new Exception($"下单失败 {orderType} {tradeDirection} {r.Error?.Message}");
return r.Data.Id;
}
}
}

43
SDKTestConsole/Program.cs

@ -55,7 +55,7 @@ namespace SDKTestConsole
//var r = binanceClient.SpotApi.Trading.PlaceMarginOrderAsync("ETHUSDT",
// Binance.Net.Enums.OrderSide.Buy,
// Binance.Net.Enums.SpotOrderType.Market,
// quoteQuantity: 20M, //报价币金额
// quoteQuantity: 30M, //报价币金额
// //quantity: 100M,
// //timeInForce: Binance.Net.Enums.TimeInForce.GoodTillCanceled,
// //stopPrice: 1899M,
@ -78,19 +78,34 @@ namespace SDKTestConsole
//止损卖币
//var r = binanceClient.SpotApi.Trading.PlaceMarginOrderAsync("ETHUSDT",
// Binance.Net.Enums.OrderSide.Sell,
// Binance.Net.Enums.SpotOrderType.StopLossLimit,
// quantity: 0.00008040M,
// price: 1899M,
// //quoteQuantity: 20M, //报价币金额
// //quantity: 100M,
// timeInForce: Binance.Net.Enums.TimeInForce.GoodTillCanceled,
// stopPrice: 1899M,
// isIsolated: true,
// orderResponseType: Binance.Net.Enums.OrderResponseType.Full).Result;
//var s = JsonConvert.SerializeObject(r);
//Console.WriteLine(s);
var r = binanceClient.SpotApi.Trading.PlaceMarginOrderAsync("ETHUSDT",
Binance.Net.Enums.OrderSide.Sell,
Binance.Net.Enums.SpotOrderType.StopLossLimit,
quantity: 0.0149M,
price: 1699M,
//quoteQuantity: 20M, //报价币金额
//quantity: 100M,
timeInForce: Binance.Net.Enums.TimeInForce.GoodTillCanceled,
stopPrice: 1699M,
isIsolated: true,
orderResponseType: Binance.Net.Enums.OrderResponseType.Full).Result;
var s = JsonConvert.SerializeObject(r);
Console.WriteLine(s);
var r1 = binanceClient.SpotApi.Trading.PlaceMarginOrderAsync("ETHUSDT",
Binance.Net.Enums.OrderSide.Sell,
Binance.Net.Enums.SpotOrderType.StopLossLimit,
quantity: 0.0149M,
price: 1699M,
//quoteQuantity: 20M, //报价币金额
//quantity: 100M,
timeInForce: Binance.Net.Enums.TimeInForce.GoodTillCanceled,
stopPrice: 1699M,
isIsolated: true,
orderResponseType: Binance.Net.Enums.OrderResponseType.Full).Result;
var s1 = JsonConvert.SerializeObject(r1);
Console.WriteLine(s1);
Console.ReadKey();
}
}

Loading…
Cancel
Save