diff --git a/.gitattributes b/.gitattributes index 1ff0c42..5b65514 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,7 @@ # Set default behavior to automatically normalize line endings. ############################################################################### * text=auto +*.yml text eol=lf ############################################################################### # Set default behavior for command prompt diff. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3fee52f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - name: Setup .NET + uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5 + with: + dotnet-version: 8.0.x + - name: Restore + run: | + dotnet restore Stocks.Data.Model/Stocks.Data.Model.csproj + dotnet restore Stocks.Data.Common/Stocks.Data.Common.csproj + dotnet restore Stocks.Data.Infrastructure/Stocks.Data.Infrastructure.csproj + dotnet restore Stocks.Data.Ef/Stocks.Data.Ef.csproj + dotnet restore Stocks.Data.Ado/Stocks.Data.Ado.csproj + dotnet restore Stocks.Data.UnitTests.Model/Stocks.Data.UnitTests.Model.csproj + dotnet restore Stocks.Data.UnitTests.Infrastructure/Stocks.Data.UnitTests.Common.csproj + dotnet restore Stocks.Data.UnitTests.Ef/Stocks.Data.UnitTests.Ef.csproj + - name: Build + run: | + dotnet build Stocks.Data.UnitTests.Model/Stocks.Data.UnitTests.Model.csproj --no-restore + dotnet build Stocks.Data.UnitTests.Infrastructure/Stocks.Data.UnitTests.Common.csproj --no-restore + dotnet build Stocks.Data.UnitTests.Ef/Stocks.Data.UnitTests.Ef.csproj --no-restore + - name: Test + run: | + dotnet test Stocks.Data.UnitTests.Model/Stocks.Data.UnitTests.Model.csproj --no-build --verbosity normal + dotnet test Stocks.Data.UnitTests.Infrastructure/Stocks.Data.UnitTests.Common.csproj --no-build --verbosity normal + dotnet test Stocks.Data.UnitTests.Ef/Stocks.Data.UnitTests.Ef.csproj --no-build --verbosity normal diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..f08d6d0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,42 @@ +name: Publish + +on: + push: + tags: + - 'v*' + +permissions: + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + - name: Setup .NET + uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5 + with: + dotnet-version: 8.0.x + - name: Restore and Build + run: | + dotnet restore Stocks.Data.Model/Stocks.Data.Model.csproj + dotnet restore Stocks.Data.Infrastructure/Stocks.Data.Infrastructure.csproj + dotnet restore Stocks.Data.Ef/Stocks.Data.Ef.csproj + dotnet restore Stocks.Data.Ado/Stocks.Data.Ado.csproj + dotnet build Stocks.Data.Model/Stocks.Data.Model.csproj --no-restore -c Release + dotnet build Stocks.Data.Infrastructure/Stocks.Data.Infrastructure.csproj --no-restore -c Release + dotnet build Stocks.Data.Ef/Stocks.Data.Ef.csproj --no-restore -c Release + dotnet build Stocks.Data.Ado/Stocks.Data.Ado.csproj --no-restore -c Release + - name: Pack + run: | + dotnet pack Stocks.Data.Model/Stocks.Data.Model.csproj --no-build -c Release -o nupkgs + dotnet pack Stocks.Data.Infrastructure/Stocks.Data.Infrastructure.csproj --no-build -c Release -o nupkgs + dotnet pack Stocks.Data.Ef/Stocks.Data.Ef.csproj --no-build -c Release -o nupkgs + dotnet pack Stocks.Data.Ado/Stocks.Data.Ado.csproj --no-build -c Release -o nupkgs + - name: Login to NuGet + uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1 + with: + usernameVar: NUGET_USER + tokenVar: NUGET_TOKEN + - name: Push to NuGet + run: dotnet nuget push nupkgs/*.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml new file mode 100644 index 0000000..ac86802 --- /dev/null +++ b/.github/workflows/sonar.yml @@ -0,0 +1,58 @@ +name: SonarCloud + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + sonar: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + with: + fetch-depth: 0 + - name: Setup .NET + uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5 + with: + dotnet-version: 8.0.x + - name: Setup Java (required by SonarScanner) + uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4 + with: + distribution: temurin + java-version: 21 + - name: Cache SonarCloud packages + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + - name: Install dotnet-sonarscanner + run: dotnet tool install --global dotnet-sonarscanner + - name: Install dotnet-coverage + run: dotnet tool install --global dotnet-coverage + - name: SonarCloud begin + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + dotnet sonarscanner begin \ + /k:"PFalkowski_StocksData" \ + /o:"pfalkowski" \ + /d:sonar.token="$SONAR_TOKEN" \ + /d:sonar.host.url="https://sonarcloud.io" \ + /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml + - name: Build + run: | + dotnet build Stocks.Data.Model/Stocks.Data.Model.csproj --no-incremental + dotnet build Stocks.Data.Infrastructure/Stocks.Data.Infrastructure.csproj --no-incremental + dotnet build Stocks.Data.Ef/Stocks.Data.Ef.csproj --no-incremental + dotnet build Stocks.Data.Ado/Stocks.Data.Ado.csproj --no-incremental + - name: Collect coverage + run: | + dotnet-coverage collect "dotnet test Stocks.Data.UnitTests.Model/Stocks.Data.UnitTests.Model.csproj --no-build" -f xml -o coverage_model.xml + dotnet-coverage collect "dotnet test Stocks.Data.UnitTests.Ef/Stocks.Data.UnitTests.Ef.csproj --no-build" -f xml -o coverage_ef.xml + dotnet-coverage merge coverage_model.xml coverage_ef.xml -f xml -o coverage.xml + - name: SonarCloud end + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN" diff --git a/README.md b/README.md index 4a49f3c..d1d0ceb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,33 @@ -# Stocks.Data.TradingSimulator +# StocksData -A .NET Standard 2.1 library for simulating stock trading strategies using historical market data. +[![CI](https://github.com/PFalkowski/StocksData/actions/workflows/ci.yml/badge.svg)](https://github.com/PFalkowski/StocksData/actions/workflows/ci.yml) +[![NuGet (Model)](https://img.shields.io/nuget/v/Stocks.Data.Model.svg?label=Model)](https://www.nuget.org/packages/Stocks.Data.Model/) +[![NuGet (Infrastructure)](https://img.shields.io/nuget/v/Stocks.Data.Infrastructure.svg?label=Infrastructure)](https://www.nuget.org/packages/Stocks.Data.Infrastructure/) +[![NuGet (Ef)](https://img.shields.io/nuget/v/Stocks.Data.Ef.svg?label=Ef)](https://www.nuget.org/packages/Stocks.Data.Ef/) +[![NuGet (Ado)](https://img.shields.io/nuget/v/Stocks.Data.Ado.svg?label=Ado)](https://www.nuget.org/packages/Stocks.Data.Ado/) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=PFalkowski_StocksData&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=PFalkowski_StocksData) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://choosealicense.com/licenses/mit/) +[![Buy Me a Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-support-yellow.svg)](https://www.buymeacoffee.com/piotrfalkowski) + +A collection of .NET 8 libraries for working with stock market data (OHLCV format). + +## Install + +```bash +dotnet add package Stocks.Data.Model +dotnet add package Stocks.Data.Infrastructure +dotnet add package Stocks.Data.Ef +dotnet add package Stocks.Data.Ado +``` + +## Packages + +| Package | Description | +|---------|-------------| +| `Stocks.Data.Model` | Domain model: `StockQuote`, `Company`, `TradingSimulationResult` | +| `Stocks.Data.Infrastructure` | CSV import helpers, OnTheFlyStats aggregation | +| `Stocks.Data.Ef` | EF Core repositories and Unit of Work for stock data | +| `Stocks.Data.Ado` | SQL Server bulk-insert via `SqlBulkCopy` | ## Features diff --git a/Stocks.Data.Ado/Stocks.Data.Ado.csproj b/Stocks.Data.Ado/Stocks.Data.Ado.csproj index c59e4a7..f3bc653 100644 --- a/Stocks.Data.Ado/Stocks.Data.Ado.csproj +++ b/Stocks.Data.Ado/Stocks.Data.Ado.csproj @@ -1,41 +1,39 @@ - + - netstandard2.1 - Debug;Release;Pack + net8.0 + latest Piotr Falkowski - - Piotr Falkowski © 2020 - - 2.0.0 + Bulk insert using SqlBulkCopy for StockQuotes in daily format. + Piotr Falkowski © 2026 + MIT https://github.com/PFalkowski/StocksData https://github.com/PFalkowski/StocksData git bulk-insert, stock-quote - initial release - bulk insert using SqlBulkCopy for StockQuotes in daily format. - true - MIT + 2.1.0 + true + $(NoWarn);CS1591 + README.md + true + true + true + snupkg - - true - - - + - - - - + - - - + + + + + diff --git a/Stocks.Data.Common/Stocks.Data.Common.csproj b/Stocks.Data.Common/Stocks.Data.Common.csproj index 0e1bf77..a9fb460 100644 --- a/Stocks.Data.Common/Stocks.Data.Common.csproj +++ b/Stocks.Data.Common/Stocks.Data.Common.csproj @@ -1,13 +1,14 @@ - netstandard2.1 + net8.0 + latest - - + + diff --git a/Stocks.Data.Ef/Stocks.Data.Ef.csproj b/Stocks.Data.Ef/Stocks.Data.Ef.csproj index e280b65..4e3a678 100644 --- a/Stocks.Data.Ef/Stocks.Data.Ef.csproj +++ b/Stocks.Data.Ef/Stocks.Data.Ef.csproj @@ -1,37 +1,39 @@ - + - netstandard2.1 - true - Piotr Falkowski © 2020 - + net8.0 + latest + Piotr Falkowski + Persistence layer for stocks using Entity Framework Core. + Piotr Falkowski © 2026 + MIT https://github.com/PFalkowski/StocksData https://github.com/PFalkowski/StocksData git Stock, Data, EntityFrameworkCore, UnitOfWork, Repository - Persistance layer for stocks using Entity Framework Core. .NET Standard 2.0 - Change namespaces - Piotr Falkowski - 3.0.0 - Debug;Release;Pack - MIT - - - - true + 3.1.0 + true + $(NoWarn);CS1591 + README.md + true + true + true + snupkg - + - - + - - + + + + + diff --git a/Stocks.Data.Infrastructure/Stocks.Data.Infrastructure.csproj b/Stocks.Data.Infrastructure/Stocks.Data.Infrastructure.csproj index c8dca89..5e9a25e 100644 --- a/Stocks.Data.Infrastructure/Stocks.Data.Infrastructure.csproj +++ b/Stocks.Data.Infrastructure/Stocks.Data.Infrastructure.csproj @@ -1,38 +1,40 @@ - + - netstandard2.1 - true - Infrastracture for persistance of stock quotes in daily format (open, high, low, close) and import from CSV files in .NET Standard 2.1 + net8.0 + latest + Piotr Falkowski + Infrastructure for persistence of stock quotes in daily format (open, high, low, close) and import from CSV files. + Piotr Falkowski © 2026 + MIT https://github.com/PFalkowski/StocksData https://github.com/PFalkowski/StocksData - Piotr Falkowski © 2020 - - Stock, Data, Csv - fix bugs git - Piotr Falkowski - 3.0.0 - Debug;Release;Pack - MIT - - - - true + Stock, Data, Csv + 3.1.0 + true + $(NoWarn);CS1591 + README.md + true + true + true + snupkg - + - - + + + + + - - + diff --git a/Stocks.Data.Model/Stocks.Data.Model.csproj b/Stocks.Data.Model/Stocks.Data.Model.csproj index 256eacd..0414d8a 100644 --- a/Stocks.Data.Model/Stocks.Data.Model.csproj +++ b/Stocks.Data.Model/Stocks.Data.Model.csproj @@ -1,29 +1,34 @@ - + - netstandard2.1 - true - Model for persistance of stock quotes in daily format (open, high, low, close) .NET Standard 2.0 - Piotr Falkowski © 2020 - + net8.0 + latest + Piotr Falkowski + Model for persistence of stock quotes in daily format (open, high, low, close). + Piotr Falkowski © 2026 + MIT https://github.com/PFalkowski/StocksData https://github.com/PFalkowski/StocksData git Stocks, Data, Model, EntityFrameworkCore - fix bugs - Piotr Falkowski - Debug;Release;Pack - 3.0.0 - MIT + 3.1.0 + true + $(NoWarn);CS1591 + README.md + true + true + true + snupkg - - true - + + + + + - - + diff --git a/Stocks.Data.UnitTests.Ef/StockContextTest.cs b/Stocks.Data.UnitTests.Ef/StockContextTest.cs index 8d1632b..c377e8b 100644 --- a/Stocks.Data.UnitTests.Ef/StockContextTest.cs +++ b/Stocks.Data.UnitTests.Ef/StockContextTest.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollector.InProcDataCollector; using Stocks.Data.UnitTests.Ef.Test.TestData; using Stocks.Data.Model; using Xunit; diff --git a/Stocks.Data.UnitTests.Ef/Stocks.Data.UnitTests.Ef.csproj b/Stocks.Data.UnitTests.Ef/Stocks.Data.UnitTests.Ef.csproj index df3263b..54c0e83 100644 --- a/Stocks.Data.UnitTests.Ef/Stocks.Data.UnitTests.Ef.csproj +++ b/Stocks.Data.UnitTests.Ef/Stocks.Data.UnitTests.Ef.csproj @@ -1,29 +1,27 @@ - netcoreapp3.1 - + net8.0 false - Stocks.Data.UnitTests.Ef.Test - Stocks.Data.UnitTests.Ef.Test - - Debug;Release;Pack - - - + + + - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + all - runtime; build; native; contentfiles; analyzers + runtime; build; native; contentfiles; analyzers; buildtransitive - @@ -31,12 +29,6 @@ - - - System - - - True @@ -52,6 +44,4 @@ - - diff --git a/Stocks.Data.UnitTests.Infrastructure/Stocks.Data.UnitTests.Common.csproj b/Stocks.Data.UnitTests.Infrastructure/Stocks.Data.UnitTests.Common.csproj index c1f17f5..445f0a2 100644 --- a/Stocks.Data.UnitTests.Infrastructure/Stocks.Data.UnitTests.Common.csproj +++ b/Stocks.Data.UnitTests.Infrastructure/Stocks.Data.UnitTests.Common.csproj @@ -1,24 +1,23 @@ - netcoreapp3.1 - + net8.0 false - Stocks.Data.Common.Test - - Debug;Release;Pack - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + all - runtime; build; native; contentfiles; analyzers + runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/Stocks.Data.UnitTests.Model/Stocks.Data.UnitTests.Model.csproj b/Stocks.Data.UnitTests.Model/Stocks.Data.UnitTests.Model.csproj index 7aa73c0..bf9ab96 100644 --- a/Stocks.Data.UnitTests.Model/Stocks.Data.UnitTests.Model.csproj +++ b/Stocks.Data.UnitTests.Model/Stocks.Data.UnitTests.Model.csproj @@ -1,25 +1,23 @@ - netcoreapp3.1 - + net8.0 false - Stocks.Data.UnitTests.Model - Stocks.Data.UnitTests.Model - - Debug;Release;Pack - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + all - runtime; build; native; contentfiles; analyzers + runtime; build; native; contentfiles; analyzers; buildtransitive -