CKN.Sdk.Financial 0.0.0-alpha.0.55

This is a prerelease version of CKN.Sdk.Financial.
dotnet add package CKN.Sdk.Financial --version 0.0.0-alpha.0.55
                    
NuGet\Install-Package CKN.Sdk.Financial -Version 0.0.0-alpha.0.55
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CKN.Sdk.Financial" Version="0.0.0-alpha.0.55" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CKN.Sdk.Financial" Version="0.0.0-alpha.0.55" />
                    
Directory.Packages.props
<PackageReference Include="CKN.Sdk.Financial" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CKN.Sdk.Financial --version 0.0.0-alpha.0.55
                    
#r "nuget: CKN.Sdk.Financial, 0.0.0-alpha.0.55"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CKN.Sdk.Financial@0.0.0-alpha.0.55
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CKN.Sdk.Financial&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CKN.Sdk.Financial&version=0.0.0-alpha.0.55&prerelease
                    
Install as a Cake Tool

CKN.Sdk.Financial

CKN.Sdk.Financial, CKN.SDK ekosisteminin sıfır 3. taraf bağımlılık (Zero-Dependency) felsefesiyle yazılmış finansal araçlar ve hesaplamalar kütüphanesidir. Native AOT uyumlu, yüksek performanslı ve %100 Unit Test kapsamına sahip bir araç setidir.

Özellikler

  • Piyasa Takvimi (Market Calendar): BIST, NYSE, NASDAQ ve Kripto piyasaları için tatil ve seans saatleri hesaplaması.
  • OHLC Agregatörü: O(1) bellek kullanarak finansal tick verilerinden Open-High-Low-Close barları üretme.
  • Portföy Matematiği: WAC (Ağırlıklı Ortalama Maliyet), Gerçekleşen/Gerçekleşmeyen PnL ve ROI hesaplamaları.

Hızlı Başlangıç

1. DI Konfigürasyonu

Projenize dahil etmek için AddCknFinancial metodunu kullanın:

builder.Services.AddCknFinancial(opt =>
{
    // BIST için özel resmi tatil ekleme (Örn: Ekstra ilan edilen resmi tatiller)
    opt.AdditionalHolidays[MarketExchange.BIST] = new[] { new DateOnly(2027, 3, 15) };
});

2. Piyasa Takvimi Kullanımı (Market Calendar)

Seansın açık olup olmadığını kontrol edebilir, bir sonraki açılış zamanını alabilirsiniz:

public class TradingService(IMarketCalendar _calendar)
{
    public void ExecuteTrade()
    {
        var now = DateTimeOffset.UtcNow;
        
        if (_calendar.IsOpen(MarketExchange.BIST, now))
        {
            Console.WriteLine("BIST şu an açık, işlem yapılabilir.");
        }
        else
        {
            var nextOpen = _calendar.GetNextOpen(MarketExchange.BIST, now);
            Console.WriteLine($"BIST kapalı. Bir sonraki açılış: {nextOpen.ToLocalTime()}");
        }
    }
}

3. Ağırlıklı Ortalama Maliyet (WAC) ve PnL Hesaplama

Gerçek portföy verileriyle maliyet analizi:

var trades = new List<Trade>
{
    new Trade("THYAO", 100, 250.5m, TradeSide.Buy, DateTimeOffset.UtcNow.AddDays(-5)),
    new Trade("THYAO", 50, 260.0m, TradeSide.Buy, DateTimeOffset.UtcNow.AddDays(-2)),
    new Trade("THYAO", 75, 275.0m, TradeSide.Sell, DateTimeOffset.UtcNow.AddDays(-1))
};

// Kalan Miktar: 75 lot. 
// SPK Uyumlu Ağırlıklı Ortalama Maliyet hesabı:
var currentPrice = 280.0m;
PortfolioPnl pnl = PortfolioMath.CalculatePnl(trades, currentPrice);

Console.WriteLine($"Kalan Miktar: {pnl.PositionQuantity}");
Console.WriteLine($"WAC (Ort Maliyet): {pnl.WeightedAverageCost:C2}");
Console.WriteLine($"Gerçekleşen Kar/Zarar: {pnl.RealizedPnl:C2}");
Console.WriteLine($"ROI: % {pnl.RoiPercent:F2}");

4. OHLC Bar Agregasyonu

Gelen tick verilerinden mum (bar) üretimi. Milyonlarca tick verisini O(1) bellek ile işler:

IEnumerable<OhlcBar> ticks = FetchMarketTicks(); 
// Dakikalık barlara çevirme
var minuteBars = OhlcAggregator.Aggregate(ticks, OhlcTimeframe.Minute1);

foreach (var bar in minuteBars)
{
    Console.WriteLine($"Time: {bar.Timestamp} | O: {bar.Open} | H: {bar.High} | L: {bar.Low} | C: {bar.Close} | Vol: {bar.Volume}");
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.0-alpha.0.55 66 9/28/2026