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)
|
||||
.Handle(command);
|
||||
|
||||
|
||||
if (position != null)
|
||||
{
|
||||
if (position.Open.Status != TradeStatus.Cancelled)
|
||||
{
|
||||
position.SignalIdentifier = signal.Identifier;
|
||||
Positions.Add(position);
|
||||
|
||||
if (position.Open.Status != TradeStatus.Cancelled)
|
||||
{
|
||||
SetSignalStatus(signal.Identifier, SignalStatus.PositionOpen);
|
||||
|
||||
if (!IsForBacktest)
|
||||
@@ -534,8 +536,11 @@ public class TradingBot : Bot, ITradingBot
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Keep signal open for debug purpose
|
||||
//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
|
||||
: exchangeService.GetPrice(account, request.Ticker, DateTime.Now);
|
||||
var quantity = balanceAtRisk / price;
|
||||
var fee = request.IsForPaperTrading
|
||||
? request.Fee.GetValueOrDefault()
|
||||
: tradingService.GetFee(account, request.IsForPaperTrading);
|
||||
|
||||
var expectedStatus = GetExpectedStatus(request);
|
||||
// var expectedStatus = GetExpectedStatus(request);
|
||||
// position.Open = TradingPolicies.OpenPosition(expectedStatus).Execute(async () => { });
|
||||
|
||||
var openPrice = request.IsForPaperTrading || request.Price.HasValue
|
||||
@@ -70,7 +66,7 @@ namespace Managing.Application.Trading
|
||||
stopLossPrice: stopLossPrice, // Pass determined SL 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;
|
||||
|
||||
var closeDirection = request.Direction == TradeDirection.Long
|
||||
@@ -88,8 +84,8 @@ namespace Managing.Application.Trading
|
||||
request.Date,
|
||||
TradeStatus.Requested);
|
||||
|
||||
position.StopLoss.Fee = TradingHelpers.GetFeeAmount(fee,
|
||||
position.StopLoss.Price * position.StopLoss.Quantity, account.Exchange);
|
||||
// position.StopLoss.Fee = TradingHelpers.GetFeeAmount(fee,
|
||||
// position.StopLoss.Price * position.StopLoss.Quantity, account.Exchange);
|
||||
|
||||
// Take profit - Use the determined price
|
||||
position.TakeProfit1 = exchangeService.BuildEmptyTrade(
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Managing.Infrastructure.Evm.Services
|
||||
endpoint = $"/{endpoint}";
|
||||
}
|
||||
|
||||
var url = $"{_settings.BaseUrl}gmx{endpoint}";
|
||||
var url = $"{_settings.BaseUrl}/api/gmx{endpoint}";
|
||||
|
||||
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": {
|
||||
"version": "4.10.0",
|
||||
"devOptional": true,
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"resolve-pkg-maps": "^1.0.0"
|
||||
@@ -6598,7 +6598,7 @@
|
||||
},
|
||||
"node_modules/resolve-pkg-maps": {
|
||||
"version": "1.0.0",
|
||||
"devOptional": true,
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
|
||||
@@ -7526,7 +7526,7 @@
|
||||
},
|
||||
"node_modules/tsx": {
|
||||
"version": "4.19.3",
|
||||
"devOptional": true,
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "~0.25.0",
|
||||
@@ -7646,7 +7646,7 @@
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.8.2",
|
||||
"devOptional": true,
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
|
||||
Reference in New Issue
Block a user