feat(qe-m3-01): implement GetBarsAsOf with lookahead bias prevention and complete unit tests
Validators (Pushes and Pull Requests) / validate-core (push) Failing after 9s
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 16s

This commit is contained in:
2026-07-12 21:46:38 +09:00
parent 5589a0432b
commit b0c9776601
7 changed files with 363 additions and 7 deletions
@@ -0,0 +1,52 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dapper;
using QuantEngine.Core.Interfaces;
using QuantEngine.Infrastructure.Data;
namespace QuantEngine.Infrastructure.Repositories;
public class PriceHistoryReader : IPriceHistoryReader
{
private readonly IDbConnectionFactory _connectionFactory;
public PriceHistoryReader(IDbConnectionFactory connectionFactory)
{
_connectionFactory = connectionFactory;
}
public async Task<List<PriceHistoryDailyRecord>> GetBarsAsOf(string ticker, DateOnly asOfDate, int lookback)
{
using var conn = _connectionFactory.CreateConnection();
var rows = await conn.QueryAsync<PriceHistoryDailyRecordRow>(@"
SELECT ticker, trade_date, open, high, low, close, volume, source, provenance
FROM quantengine.price_history_daily
WHERE ticker = @Ticker AND trade_date <= @AsOfDate
ORDER BY trade_date DESC
LIMIT @Lookback",
new { Ticker = ticker, AsOfDate = asOfDate, Lookback = lookback });
return rows.Select(r => new PriceHistoryDailyRecord(
r.Ticker,
r.TradeDate,
r.Open,
r.High,
r.Low,
r.Close,
r.Volume,
r.Source,
r.Provenance)).ToList();
}
private record PriceHistoryDailyRecordRow(
string Ticker,
DateOnly TradeDate,
decimal Open,
decimal High,
decimal Low,
decimal Close,
long Volume,
string Source,
string? Provenance);
}