Kursabfrage nimmt das Instrument statt nur das Symbol
Ohne Waehrung wird jeder Kontrakt als USD gesucht: ein Wert, der nur in EUR notiert, ist dann "nicht aufloesbar", und die Ursache steht nirgends. Beim Order-Nachweis gegen MIGA:EUR genau so aufgetreten - die Kontraktaufloesung fuer die ORDER war bereits waehrungsfaehig, die fuer den KURS nicht, und damit brach die Kette eine Stufe vorher ab. Dieselbe Aenderung ist die Voraussetzung fuer Optionskurse (#299): ohne Kontraktangaben laesst sich eine Option ueberhaupt nicht abfragen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,7 +60,7 @@ public sealed class ExecutionService : IExecutionService
|
||||
}
|
||||
|
||||
// 2. Kurs
|
||||
var quote = await _broker.GetQuoteAsync(signal.Symbol, ct);
|
||||
var quote = await _broker.GetQuoteAsync(signal.Instrument, ct);
|
||||
if (quote is null || quote.Last <= 0)
|
||||
{
|
||||
Journal(signal, TradeDecision.Skipped, DecisionReason.NoQuote, $"Kein Kurs für {signal.Symbol} verfügbar.");
|
||||
|
||||
@@ -6,8 +6,14 @@ namespace IBKRTrader.Core.Trading;
|
||||
/// </summary>
|
||||
public interface IBrokerClient
|
||||
{
|
||||
/// <summary>Aktuelle Kurs-Momentaufnahme oder null, wenn nicht verfügbar.</summary>
|
||||
Task<Quote?> GetQuoteAsync(string symbol, CancellationToken ct = default);
|
||||
/// <summary>
|
||||
/// Aktuelle Kurs-Momentaufnahme oder <c>null</c>, wenn nicht verfügbar.
|
||||
///
|
||||
/// <para>Nimmt das <b>Instrument</b> und nicht nur das Symbol: ohne Währung wird jeder Kontrakt
|
||||
/// als USD gesucht, und ein Wert, der nur in EUR notiert, ist dann schlicht "nicht auflösbar".
|
||||
/// Ohne Kontraktangaben gälte dasselbe für jede Option.</para>
|
||||
/// </summary>
|
||||
Task<Quote?> GetQuoteAsync(InstrumentRef instrument, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Kontostand-Momentaufnahme.</summary>
|
||||
Task<AccountState> GetAccountStateAsync(CancellationToken ct = default);
|
||||
|
||||
@@ -53,14 +53,14 @@ public sealed class IbkrBrokerClient : IBrokerClient, IBrokerPortfolioReader, ID
|
||||
$"TWS-Broker aktiv: {ibkr.Host}:{ibkr.Port} (Client {ibkr.ClientId}), Modus {mode}.");
|
||||
}
|
||||
|
||||
public async Task<Quote?> GetQuoteAsync(string symbol, CancellationToken ct = default)
|
||||
public async Task<Quote?> GetQuoteAsync(InstrumentRef instrument, CancellationToken ct = default)
|
||||
{
|
||||
if (!await IsReadyAsync(ct).ConfigureAwait(false)) return null;
|
||||
|
||||
var contract = await _connection!.ResolveContractAsync(InstrumentRef.ForStock(symbol), _requestTimeout, ct).ConfigureAwait(false);
|
||||
var contract = await _connection!.ResolveContractAsync(instrument, _requestTimeout, ct).ConfigureAwait(false);
|
||||
if (contract is null) return null;
|
||||
|
||||
return await _connection.RequestQuoteAsync(contract, symbol, _requestTimeout, ct).ConfigureAwait(false);
|
||||
return await _connection.RequestQuoteAsync(contract, instrument.Symbol, _requestTimeout, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<AccountState> GetAccountStateAsync(CancellationToken ct = default)
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed class NullBrokerClient : IBrokerClient, IBrokerPortfolioReader
|
||||
public Task<IReadOnlyList<BrokerExecution>> GetExecutionsAsync(DateTime? since = null, CancellationToken ct = default)
|
||||
=> Task.FromResult<IReadOnlyList<BrokerExecution>>(Array.Empty<BrokerExecution>());
|
||||
|
||||
public Task<Quote?> GetQuoteAsync(string symbol, CancellationToken ct = default)
|
||||
public Task<Quote?> GetQuoteAsync(InstrumentRef instrument, CancellationToken ct = default)
|
||||
=> Task.FromResult<Quote?>(null);
|
||||
|
||||
public Task<AccountState> GetAccountStateAsync(CancellationToken ct = default)
|
||||
|
||||
Reference in New Issue
Block a user