Initial commit: IBKRTrader

.NET WinForms-Anwendung (Core, Modules/CongressTrading, UI).
Enthaelt .gitignore und settings.example.json als Konfigurationsvorlage.
Echte settings.json mit Zugangsdaten ist bewusst ausgeschlossen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Richard
2026-07-26 18:19:47 +02:00
co-authored by Claude Opus 4.8
commit ebeb035e92
47 changed files with 4527 additions and 0 deletions
+336
View File
@@ -0,0 +1,336 @@
using System.Text.Json.Serialization;
namespace IBKRTrader.Core.IBKR;
// ─── DB Entities ─────────────────────────────────────────────────────────────
/// <summary>
/// Repräsentiert ein IBKR-Instrument in core_ibkr_instruments.
/// ibkr_conid ist der zentrale, eindeutige IBKR-Schlüssel.
/// </summary>
public class IBKRInstrument
{
public long Id { get; set; }
public long IbkrConid { get; set; }
public string Symbol { get; set; } = "";
public string SecType { get; set; } = "STK";
public string Exchange { get; set; } = "SMART";
public string? PrimaryExchange { get; set; }
public string Currency { get; set; } = "USD";
public string? CompanyName { get; set; }
public string? Isin { get; set; }
public string? Sector { get; set; }
public string? Industry { get; set; }
public string? Description { get; set; }
public bool Active { get; set; } = true;
public DateTime? LastFetched { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
/// <summary>
/// Repräsentiert einen OHLCV-Balken in core_ibkr_market_data.
/// </summary>
public class IBKRMarketBar
{
public long InstrumentId { get; set; }
public string BarSize { get; set; } = "daily";
public DateTime Timestamp { get; set; }
public decimal Open { get; set; }
public decimal High { get; set; }
public decimal Low { get; set; }
public decimal Close { get; set; }
public long Volume { get; set; }
public decimal? Wap { get; set; }
public int? BarCount { get; set; }
}
/// <summary>
/// Externes Ticker-Mapping in core_ibkr_external_identifiers.
/// </summary>
public class IBKRExternalIdentifier
{
public long Id { get; set; }
public long InstrumentId { get; set; }
public string Source { get; set; } = "";
public string Ticker { get; set; } = "";
}
// ─── API Response DTOs ───────────────────────────────────────────────────────
/// <summary>
/// Response von GET /iserver/auth/status
/// </summary>
public class IBKRAuthStatus
{
[JsonPropertyName("authenticated")]
public bool Authenticated { get; set; }
[JsonPropertyName("competing")]
public bool Competing { get; set; }
[JsonPropertyName("connected")]
public bool Connected { get; set; }
[JsonPropertyName("message")]
public string? Message { get; set; }
[JsonPropertyName("fail")]
public string? Fail { get; set; }
}
/// <summary>
/// Einzelnes Ergebnis der Contract-Suche (POST /iserver/secdef/search).
/// </summary>
public class IBKRContractSearchResult
{
[JsonPropertyName("conid")]
public long ConId { get; set; }
[JsonPropertyName("companyHeader")]
public string? CompanyHeader { get; set; }
[JsonPropertyName("companyName")]
public string? CompanyName { get; set; }
[JsonPropertyName("symbol")]
public string? Symbol { get; set; }
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonPropertyName("restricted")]
public string? Restricted { get; set; }
[JsonPropertyName("fop")]
public string? Fop { get; set; }
[JsonPropertyName("opt")]
public string? Opt { get; set; }
[JsonPropertyName("war")]
public string? War { get; set; }
[JsonPropertyName("sections")]
public List<IBKRContractSection>? Sections { get; set; }
}
/// <summary>
/// Sections innerhalb eines Contract-Suchergebnisses.
/// </summary>
public class IBKRContractSection
{
[JsonPropertyName("secType")]
public string? SecType { get; set; }
[JsonPropertyName("months")]
public string? Months { get; set; }
[JsonPropertyName("symbol")]
public string? Symbol { get; set; }
[JsonPropertyName("exchange")]
public string? Exchange { get; set; }
[JsonPropertyName("legStr")]
public string? LegStr { get; set; }
}
/// <summary>
/// Response von GET /iserver/contract/{conid}/info
/// </summary>
public class IBKRContractInfo
{
[JsonPropertyName("cfi_code")]
public string? CfiCode { get; set; }
[JsonPropertyName("symbol")]
public string? Symbol { get; set; }
[JsonPropertyName("cusip")]
public string? Cusip { get; set; }
[JsonPropertyName("expiry_full")]
public string? ExpiryFull { get; set; }
[JsonPropertyName("con_id")]
public long ConId { get; set; }
[JsonPropertyName("maturity_date")]
public string? MaturityDate { get; set; }
[JsonPropertyName("industry")]
public string? Industry { get; set; }
[JsonPropertyName("instrument_type")]
public string? InstrumentType { get; set; }
[JsonPropertyName("trading_class")]
public string? TradingClass { get; set; }
[JsonPropertyName("valid_exchanges")]
public string? ValidExchanges { get; set; }
[JsonPropertyName("allow_sell_long")]
public bool? AllowSellLong { get; set; }
[JsonPropertyName("is_zero_commission_security")]
public bool? IsZeroCommissionSecurity { get; set; }
[JsonPropertyName("local_symbol")]
public string? LocalSymbol { get; set; }
[JsonPropertyName("classifier")]
public string? Classifier { get; set; }
[JsonPropertyName("currency")]
public string? Currency { get; set; }
[JsonPropertyName("text")]
public string? Text { get; set; }
[JsonPropertyName("underlying_con_id")]
public long? UnderlyingConId { get; set; }
[JsonPropertyName("r_t_h")]
public bool? Rth { get; set; }
[JsonPropertyName("company_name")]
public string? CompanyName { get; set; }
[JsonPropertyName("smart_available")]
public bool? SmartAvailable { get; set; }
[JsonPropertyName("exchange")]
public string? Exchange { get; set; }
[JsonPropertyName("listing_exchange")]
public string? ListingExchange { get; set; }
[JsonPropertyName("category")]
public string? Category { get; set; }
[JsonPropertyName("sector")]
public string? Sector { get; set; }
}
/// <summary>
/// Response von GET /iserver/marketdata/history
/// </summary>
public class IBKRHistoricalDataResponse
{
[JsonPropertyName("symbol")]
public string? Symbol { get; set; }
[JsonPropertyName("text")]
public string? Text { get; set; }
[JsonPropertyName("priceFactor")]
public int? PriceFactor { get; set; }
[JsonPropertyName("startTime")]
public string? StartTime { get; set; }
[JsonPropertyName("high")]
public string? High { get; set; }
[JsonPropertyName("low")]
public string? Low { get; set; }
[JsonPropertyName("timePeriod")]
public string? TimePeriod { get; set; }
[JsonPropertyName("barLength")]
public int? BarLength { get; set; }
[JsonPropertyName("mdAvailability")]
public string? MdAvailability { get; set; }
[JsonPropertyName("mktDataDelay")]
public int? MktDataDelay { get; set; }
[JsonPropertyName("outsideRth")]
public bool? OutsideRth { get; set; }
[JsonPropertyName("tradingDayDuration")]
public int? TradingDayDuration { get; set; }
[JsonPropertyName("volumeFactor")]
public int? VolumeFactor { get; set; }
[JsonPropertyName("priceDisplayRule")]
public int? PriceDisplayRule { get; set; }
[JsonPropertyName("priceDisplayValue")]
public string? PriceDisplayValue { get; set; }
[JsonPropertyName("negativeCapable")]
public bool? NegativeCapable { get; set; }
[JsonPropertyName("messageVersion")]
public int? MessageVersion { get; set; }
[JsonPropertyName("data")]
public List<IBKRHistoricalBar>? Data { get; set; }
[JsonPropertyName("points")]
public int? Points { get; set; }
[JsonPropertyName("travelTime")]
public int? TravelTime { get; set; }
}
/// <summary>
/// Einzelner OHLCV-Balken aus der IBKR Historical Data Response.
/// </summary>
public class IBKRHistoricalBar
{
[JsonPropertyName("o")]
public decimal Open { get; set; }
[JsonPropertyName("c")]
public decimal Close { get; set; }
[JsonPropertyName("h")]
public decimal High { get; set; }
[JsonPropertyName("l")]
public decimal Low { get; set; }
[JsonPropertyName("v")]
public long Volume { get; set; }
[JsonPropertyName("t")]
public long Timestamp { get; set; } // Unix timestamp in ms
}
/// <summary>
/// Response von GET /trsrv/stocks?symbols=...
/// Die API gibt ein Dictionary zurück: { "AAPL": [{ ... }] }
/// </summary>
public class IBKRStockContract
{
[JsonPropertyName("name")]
public string? Name { get; set; }
[JsonPropertyName("chineseName")]
public string? ChineseName { get; set; }
[JsonPropertyName("assetClass")]
public string? AssetClass { get; set; }
[JsonPropertyName("contracts")]
public List<IBKRStockContractEntry>? Contracts { get; set; }
}
public class IBKRStockContractEntry
{
[JsonPropertyName("conid")]
public long ConId { get; set; }
[JsonPropertyName("exchange")]
public string? Exchange { get; set; }
[JsonPropertyName("isUS")]
public bool? IsUS { get; set; }
}