Fix json serialization + preloaded candle
This commit is contained in:
@@ -568,26 +568,12 @@ public class DataController : ControllerBase
|
|||||||
/// <param name="endDate">Optional end date for the balance history (defaults to current time)</param>
|
/// <param name="endDate">Optional end date for the balance history (defaults to current time)</param>
|
||||||
/// <returns>A list of agent balances within the specified date range</returns>
|
/// <returns>A list of agent balances within the specified date range</returns>
|
||||||
[HttpGet("GetAgentBalances")]
|
[HttpGet("GetAgentBalances")]
|
||||||
public async Task<ActionResult<IList<AgentBalance>>> GetAgentBalances(
|
public async Task<ActionResult<AgentBalanceHistory>> GetAgentBalances(
|
||||||
string agentName,
|
string agentName,
|
||||||
DateTime startDate,
|
DateTime startDate,
|
||||||
DateTime? endDate = null)
|
DateTime? endDate = null)
|
||||||
{
|
{
|
||||||
string cacheKey = $"AgentBalances_{agentName}_{startDate:yyyyMMdd}_{endDate?.ToString("yyyyMMdd") ?? "now"}";
|
|
||||||
|
|
||||||
// Check if the balances are already cached
|
|
||||||
var cachedBalances = _cacheService.GetValue<IList<AgentBalance>>(cacheKey);
|
|
||||||
|
|
||||||
if (cachedBalances != null)
|
|
||||||
{
|
|
||||||
return Ok(cachedBalances);
|
|
||||||
}
|
|
||||||
|
|
||||||
var balances = await _statisticService.GetAgentBalances(agentName, startDate, endDate);
|
var balances = await _statisticService.GetAgentBalances(agentName, startDate, endDate);
|
||||||
|
|
||||||
// Cache the results for 5 minutes
|
|
||||||
_cacheService.SaveValue(cacheKey, balances, TimeSpan.FromMinutes(5));
|
|
||||||
|
|
||||||
return Ok(balances);
|
return Ok(balances);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,5 +30,7 @@
|
|||||||
"Sentry": {
|
"Sentry": {
|
||||||
"Dsn": "https://698e00d7cb404b049aff3881e5a47f6b@bugcenter.apps.managing.live/1"
|
"Dsn": "https://698e00d7cb404b049aff3881e5a47f6b@bugcenter.apps.managing.live/1"
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"WorkerBotManager": true,
|
||||||
|
"WorkerBalancesTracking": true
|
||||||
}
|
}
|
||||||
@@ -25,5 +25,6 @@
|
|||||||
"Uri": "http://elasticsearch:9200"
|
"Uri": "http://elasticsearch:9200"
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"EnableBotManager": true
|
"WorkerBotManager": true,
|
||||||
|
"WorkerBalancesTracking": false
|
||||||
}
|
}
|
||||||
@@ -217,6 +217,12 @@ public class TradingBot : Bot, ITradingBot
|
|||||||
if (OptimizedCandles.Any())
|
if (OptimizedCandles.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var haveSignal = Signals.Any();
|
||||||
|
if (haveSignal)
|
||||||
|
{
|
||||||
|
PreloadSince = Signals.First().Date;
|
||||||
|
}
|
||||||
|
|
||||||
var candles =
|
var candles =
|
||||||
await ExchangeService.GetCandlesInflux(Account.Exchange, Config.Ticker, PreloadSince, Config.Timeframe);
|
await ExchangeService.GetCandlesInflux(Account.Exchange, Config.Ticker, PreloadSince, Config.Timeframe);
|
||||||
|
|
||||||
@@ -226,7 +232,11 @@ public class TradingBot : Bot, ITradingBot
|
|||||||
{
|
{
|
||||||
OptimizedCandles.Enqueue(candle);
|
OptimizedCandles.Enqueue(candle);
|
||||||
Candles.Add(candle);
|
Candles.Add(candle);
|
||||||
await UpdateSignals(OptimizedCandles);
|
|
||||||
|
if (!haveSignal)
|
||||||
|
{
|
||||||
|
await UpdateSignals(OptimizedCandles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ public class AgentBalanceHistory
|
|||||||
{
|
{
|
||||||
public string AgentName { get; set; }
|
public string AgentName { get; set; }
|
||||||
|
|
||||||
public IList<AgentBalance> AgentBalances { get; set; }
|
public List<AgentBalance> AgentBalances { get; set; }
|
||||||
}
|
}
|
||||||
@@ -9,8 +9,8 @@ test('GMX Position Closing', async (t) => {
|
|||||||
|
|
||||||
const result = await closeGmxPositionImpl(
|
const result = await closeGmxPositionImpl(
|
||||||
sdk,
|
sdk,
|
||||||
'BNB',
|
'BTC',
|
||||||
TradeDirection.Long
|
TradeDirection.Short
|
||||||
)
|
)
|
||||||
console.log('Position closing result:', result)
|
console.log('Position closing result:', result)
|
||||||
assert.ok(result, 'Position closing result should be defined')
|
assert.ok(result, 'Position closing result should be defined')
|
||||||
|
|||||||
Reference in New Issue
Block a user