Fix a bit bots
This commit is contained in:
@@ -510,12 +510,14 @@ public class TradingBot : Bot, ITradingBot
|
|||||||
var position = await new OpenPositionCommandHandler(ExchangeService, AccountService, TradingService)
|
var position = await new OpenPositionCommandHandler(ExchangeService, AccountService, TradingService)
|
||||||
.Handle(command);
|
.Handle(command);
|
||||||
|
|
||||||
|
|
||||||
if (position != null)
|
if (position != null)
|
||||||
{
|
{
|
||||||
|
position.SignalIdentifier = signal.Identifier;
|
||||||
|
Positions.Add(position);
|
||||||
|
|
||||||
if (position.Open.Status != TradeStatus.Cancelled)
|
if (position.Open.Status != TradeStatus.Cancelled)
|
||||||
{
|
{
|
||||||
position.SignalIdentifier = signal.Identifier;
|
|
||||||
Positions.Add(position);
|
|
||||||
SetSignalStatus(signal.Identifier, SignalStatus.PositionOpen);
|
SetSignalStatus(signal.Identifier, SignalStatus.PositionOpen);
|
||||||
|
|
||||||
if (!IsForBacktest)
|
if (!IsForBacktest)
|
||||||
@@ -534,8 +536,11 @@ public class TradingBot : Bot, ITradingBot
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
// Keep signal open for debug purpose
|
||||||
|
//SetSignalStatus(signal.Identifier, SignalStatus.Expired);
|
||||||
SetSignalStatus(signal.Identifier, SignalStatus.Expired);
|
SetSignalStatus(signal.Identifier, SignalStatus.Expired);
|
||||||
await LogWarning($"Cannot open trade : {ex.Message}");
|
|
||||||
|
await LogWarning($"Cannot open trade : {ex.Message}, stackTrace : {ex.StackTrace}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,11 +42,7 @@ namespace Managing.Application.Trading
|
|||||||
? request.Price.Value
|
? request.Price.Value
|
||||||
: exchangeService.GetPrice(account, request.Ticker, DateTime.Now);
|
: exchangeService.GetPrice(account, request.Ticker, DateTime.Now);
|
||||||
var quantity = balanceAtRisk / price;
|
var quantity = balanceAtRisk / price;
|
||||||
var fee = request.IsForPaperTrading
|
// var expectedStatus = GetExpectedStatus(request);
|
||||||
? request.Fee.GetValueOrDefault()
|
|
||||||
: tradingService.GetFee(account, request.IsForPaperTrading);
|
|
||||||
|
|
||||||
var expectedStatus = GetExpectedStatus(request);
|
|
||||||
// position.Open = TradingPolicies.OpenPosition(expectedStatus).Execute(async () => { });
|
// position.Open = TradingPolicies.OpenPosition(expectedStatus).Execute(async () => { });
|
||||||
|
|
||||||
var openPrice = request.IsForPaperTrading || request.Price.HasValue
|
var openPrice = request.IsForPaperTrading || request.Price.HasValue
|
||||||
@@ -70,7 +66,7 @@ namespace Managing.Application.Trading
|
|||||||
stopLossPrice: stopLossPrice, // Pass determined SL price
|
stopLossPrice: stopLossPrice, // Pass determined SL price
|
||||||
takeProfitPrice: takeProfitPrice); // Pass determined TP price
|
takeProfitPrice: takeProfitPrice); // Pass determined TP price
|
||||||
|
|
||||||
trade.Fee = TradingHelpers.GetFeeAmount(fee, openPrice * quantity, account.Exchange);
|
//trade.Fee = TradingHelpers.GetFeeAmount(fee, openPrice * quantity, account.Exchange);
|
||||||
position.Open = trade;
|
position.Open = trade;
|
||||||
|
|
||||||
var closeDirection = request.Direction == TradeDirection.Long
|
var closeDirection = request.Direction == TradeDirection.Long
|
||||||
@@ -88,8 +84,8 @@ namespace Managing.Application.Trading
|
|||||||
request.Date,
|
request.Date,
|
||||||
TradeStatus.Requested);
|
TradeStatus.Requested);
|
||||||
|
|
||||||
position.StopLoss.Fee = TradingHelpers.GetFeeAmount(fee,
|
// position.StopLoss.Fee = TradingHelpers.GetFeeAmount(fee,
|
||||||
position.StopLoss.Price * position.StopLoss.Quantity, account.Exchange);
|
// position.StopLoss.Price * position.StopLoss.Quantity, account.Exchange);
|
||||||
|
|
||||||
// Take profit - Use the determined price
|
// Take profit - Use the determined price
|
||||||
position.TakeProfit1 = exchangeService.BuildEmptyTrade(
|
position.TakeProfit1 = exchangeService.BuildEmptyTrade(
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace Managing.Infrastructure.Evm.Services
|
|||||||
endpoint = $"/{endpoint}";
|
endpoint = $"/{endpoint}";
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = $"{_settings.BaseUrl}gmx{endpoint}";
|
var url = $"{_settings.BaseUrl}/api/gmx{endpoint}";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
8
src/Managing.Web3Proxy/package-lock.json
generated
8
src/Managing.Web3Proxy/package-lock.json
generated
@@ -4340,7 +4340,7 @@
|
|||||||
},
|
},
|
||||||
"node_modules/get-tsconfig": {
|
"node_modules/get-tsconfig": {
|
||||||
"version": "4.10.0",
|
"version": "4.10.0",
|
||||||
"devOptional": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"resolve-pkg-maps": "^1.0.0"
|
"resolve-pkg-maps": "^1.0.0"
|
||||||
@@ -6598,7 +6598,7 @@
|
|||||||
},
|
},
|
||||||
"node_modules/resolve-pkg-maps": {
|
"node_modules/resolve-pkg-maps": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"devOptional": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
|
"url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
|
||||||
@@ -7526,7 +7526,7 @@
|
|||||||
},
|
},
|
||||||
"node_modules/tsx": {
|
"node_modules/tsx": {
|
||||||
"version": "4.19.3",
|
"version": "4.19.3",
|
||||||
"devOptional": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "~0.25.0",
|
"esbuild": "~0.25.0",
|
||||||
@@ -7646,7 +7646,7 @@
|
|||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.8.2",
|
"version": "5.8.2",
|
||||||
"devOptional": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
|
|||||||
Reference in New Issue
Block a user