|
|
@ -200,67 +200,77 @@ namespace Binance.TradeRobot.Business |
|
|
|
/// <summary>
|
|
|
|
/// 获取动2.1策略机器人列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="robotId"></param>
|
|
|
|
/// <param name="robotState">机器人状态</param>
|
|
|
|
/// <param name="signalPeriod">信号周期</param>
|
|
|
|
/// <param name="symbol">交易对</param>
|
|
|
|
/// <param name="isLoadRecentTradeProfit">是否加载近期交易利润,默认true</param>
|
|
|
|
/// <param name="isLoadAPIKey">是否加载机器人绑定的APIKey,默认false</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public IList<D21PolicyRobotResponse> GetD21PolicyRobotList(Enums.RobotState? robotState = null, |
|
|
|
public IList<D21PolicyRobotResponse> GetD21PolicyRobotList(long? robotId, |
|
|
|
Enums.RobotState? robotState = null, |
|
|
|
Enums.SignalPeriod? signalPeriod = null, |
|
|
|
string symbol = "", |
|
|
|
bool isLoadRecentTradeProfit = true, |
|
|
|
bool isLoadAPIKey = false) |
|
|
|
{ |
|
|
|
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, |
|
|
|
var select = 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); |
|
|
|
if (robotId != null) |
|
|
|
{ |
|
|
|
select = select.Where((r, ra, d, e) => r.Id == robotId); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
select = select.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); |
|
|
|
} |
|
|
|
|
|
|
|
var robotList = select.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, |
|
|
|
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>>(); |
|
|
|
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) |
|
|
|