|
|
@ -56,7 +56,7 @@ namespace Binance.TradeRobot.Business |
|
|
|
|
|
|
|
//监听K线和订单
|
|
|
|
globalContext.SubscribeKLine(robot); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void StopRobot(long robotId) |
|
|
|
{ |
|
|
@ -199,52 +199,56 @@ namespace Binance.TradeRobot.Business |
|
|
|
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 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, |
|
|
|
|
|
|
|
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) |
|
|
|
{ |
|
|
|
//统计近期订单利润
|
|
|
|