@@ -10,6 +10,10 @@ using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Api.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Controller for handling data-related operations such as retrieving tickers, spotlight data, and candles.
|
||||
/// Requires authorization for access.
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("[controller]")]
|
||||
@@ -21,6 +25,14 @@ public class DataController : ControllerBase
|
||||
private readonly IStatisticService _statisticService;
|
||||
private readonly IHubContext<CandleHub> _hubContext;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataController"/> class.
|
||||
/// </summary>
|
||||
/// <param name="exchangeService">Service for interacting with exchanges.</param>
|
||||
/// <param name="accountService">Service for account management.</param>
|
||||
/// <param name="cacheService">Service for caching data.</param>
|
||||
/// <param name="statisticService">Service for statistical analysis.</param>
|
||||
/// <param name="hubContext">SignalR hub context for real-time communication.</param>
|
||||
public DataController(
|
||||
IExchangeService exchangeService,
|
||||
IAccountService accountService,
|
||||
@@ -35,6 +47,12 @@ public class DataController : ControllerBase
|
||||
_hubContext = hubContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves tickers for a given account and timeframe, utilizing caching to improve performance.
|
||||
/// </summary>
|
||||
/// <param name="accountName">The name of the account to retrieve tickers for.</param>
|
||||
/// <param name="timeframe">The timeframe for which to retrieve tickers.</param>
|
||||
/// <returns>An array of tickers.</returns>
|
||||
[HttpPost("GetTickers")]
|
||||
public async Task<ActionResult<Ticker[]>> GetTickers(string accountName, Timeframe timeframe)
|
||||
{
|
||||
@@ -48,6 +66,10 @@ public class DataController : ControllerBase
|
||||
return Ok(tickers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the latest spotlight overview, using caching to enhance response times.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="SpotlightOverview"/> object containing spotlight data.</returns>
|
||||
[HttpGet("Spotlight")]
|
||||
public ActionResult<SpotlightOverview> GetSpotlight()
|
||||
{
|
||||
@@ -64,10 +86,17 @@ public class DataController : ControllerBase
|
||||
return Ok(overview);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves candle data for a given exchange, ticker, start date, and timeframe.
|
||||
/// </summary>
|
||||
/// <param name="exchange">The exchange to retrieve candles from.</param>
|
||||
/// <param name="ticker">The ticker symbol to retrieve candles for.</param>
|
||||
/// <param name="startDate">The start date for the candle data.</param>
|
||||
/// <param name="timeframe">The timeframe for the candle data.</param>
|
||||
/// <returns>A list of <see cref="Candle"/> objects.</returns>
|
||||
[HttpGet("GetCandles")]
|
||||
public async Task<ActionResult<List<Candle>>> GetCandles(TradingExchanges exchange, Ticker ticker, DateTime startDate, Timeframe timeframe)
|
||||
{
|
||||
return Ok(await _exchangeService.GetCandlesInflux(exchange, ticker, startDate, timeframe));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user