feat(quant): WBS-FE-BE-100 complete Vue3 Vite8 SPA & .NET10 FastEndpoints refactoring
This commit is contained in:
@@ -6,6 +6,10 @@ using QuantEngine.Core.Interfaces;
|
||||
|
||||
namespace QuantEngine.Infrastructure.Repositories
|
||||
{
|
||||
/// <summary>
|
||||
/// PostgreSQL Dapper Repository implementation for History-First Operating Model.
|
||||
/// Manages 3NF Data Integrity, Waterfall Auditing, and Shadow Ledger persistence.
|
||||
/// </summary>
|
||||
public class PostgresqlHistoryStore : IPostgresqlHistoryStore
|
||||
{
|
||||
private readonly IDbConnectionFactory _connectionFactory;
|
||||
@@ -68,5 +72,35 @@ namespace QuantEngine.Infrastructure.Repositories
|
||||
var rows = await conn.QueryAsync(sql, new { Limit = limit });
|
||||
return rows.Select(row => (IDictionary<string, object?>)row).ToList();
|
||||
}
|
||||
|
||||
public async Task<long> RecordWaterfallExecutionAsync(string runId, string ticker, int rank, string stage, string action, int targetQty, decimal? targetPrice, decimal? bidAskSpreadBps, decimal? slippageBps, string status, string rationale)
|
||||
{
|
||||
using var conn = _connectionFactory.CreateConnection();
|
||||
conn.Open();
|
||||
|
||||
const string sql = @"
|
||||
INSERT INTO quantengine.order_waterfall_execution_history
|
||||
(run_id, ticker, sell_priority_rank, waterfall_stage, action, target_qty, target_price, bid_ask_spread_bps, slippage_bps, status, rationale)
|
||||
VALUES
|
||||
(@runId, @ticker, @rank, @stage, @action, @targetQty, @targetPrice, @bidAskSpreadBps, @slippageBps, @status, @rationale)
|
||||
RETURNING id;";
|
||||
|
||||
return await conn.ExecuteScalarAsync<long>(sql, new { runId, ticker, rank, stage, action, targetQty, targetPrice, bidAskSpreadBps, slippageBps, status, rationale });
|
||||
}
|
||||
|
||||
public async Task<long> RecordShadowLedgerAsync(string runId, string ticker, string blockedGate, string blockedReason, decimal shadowPrice, int shadowQty, decimal? shadowTpPrice, decimal? shadowSlPrice)
|
||||
{
|
||||
using var conn = _connectionFactory.CreateConnection();
|
||||
conn.Open();
|
||||
|
||||
const string sql = @"
|
||||
INSERT INTO quantengine.shadow_ledger_history
|
||||
(run_id, ticker, blocked_gate, blocked_reason, shadow_price, shadow_qty, shadow_tp_price, shadow_sl_price)
|
||||
VALUES
|
||||
(@runId, @ticker, @blockedGate, @blockedReason, @shadowPrice, @shadowQty, @shadowTpPrice, @shadowSlPrice)
|
||||
RETURNING id;";
|
||||
|
||||
return await conn.ExecuteScalarAsync<long>(sql, new { runId, ticker, blockedGate, blockedReason, shadowPrice, shadowQty, shadowTpPrice, shadowSlPrice });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user