VOOZH about

URL: https://www.nuget.org/packages/StocksCoreApiSharp.SQLite/

⇱ NuGet Gallery | StocksCoreApiSharp.SQLite 1.0.3




StocksCoreApiSharp.SQLite 1.0.3

dotnet add package StocksCoreApiSharp.SQLite --version 1.0.3
 
 
NuGet\Install-Package StocksCoreApiSharp.SQLite -Version 1.0.3
 
 
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="StocksCoreApiSharp.SQLite" Version="1.0.3" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StocksCoreApiSharp.SQLite" Version="1.0.3" />
 
Directory.Packages.props
<PackageReference Include="StocksCoreApiSharp.SQLite" />
 
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 StocksCoreApiSharp.SQLite --version 1.0.3
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: StocksCoreApiSharp.SQLite, 1.0.3"
 
 
#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 StocksCoreApiSharp.SQLite@1.0.3
 
 
#: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=StocksCoreApiSharp.SQLite&version=1.0.3
 
Install as a Cake Addin
#tool nuget:?package=StocksCoreApiSharp.SQLite&version=1.0.3
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

StocksCoreApiSharp

This is the core C# library to manage stocks for our StocksWatch application built with .NET MAUI.

Nuget

👁 NuGet
👁 NuGet

Usage

Depots & Watchlists

Depot and WatchList objects can hold Stock items.

// Create a new depot
Depot myDepot = new("My depot")
{
 DateOfCreation = DateTime.Now,
 IsPrimaryDepot = true,
};
myDepot.Stocks.Add(new Stock("Daimler AG"));
// Create a new watchlist
WatchList myList = new("My watchlist")
{
 DateOfCreation = DateTime.Now,
};
myList.Stocks.Add(new Stock("Daimler AG"));

Stocks

The Stock object holds all necessary informaton about a stock or ETF.

// Create a new Stock item
Stock basf = new()
{
 Name = "BASF",
 ISIN = "DE000BASF111",
 CurrentRate = 41.05,
};

// Add transactions to it
basf.Transactions.Add(new()
{
 StockId = basf.Id,
 DateOfCreation = DateTime.Now,
 Amount = 100,
 Price = 64.10,
 Type = TransactionType.Buy,
});
basf.Transactions.Add(new()
{
 StockId = basf.Id,
 DateOfCreation = DateTime.Now,
 Amount = 25,
 Price = 60.10,
 Type = TransactionType.Sell,
});

// Add dividends to it
basf.Dividends.Add(new()
{
 StockId = basf.Id,
 DateOfDividend = DateTime.Now,
 AmountOfDividend = 3400.00,
 Quantity = 100,
 Tax = 300,
});
basf.Dividends.Add(new()
{
 StockId = basf.Id,
 DateOfDividend = DateTime.Now.AddYears(-1),
 AmountOfDividend = 3400.00,
 Quantity = 100,
 Tax = 300,
});

Based on the Transaction and Dividend items, the Stock class will automatically calculate the amount of stocks hold, the total worth and growth.

Database

The library supports SQLite by default. You either can create your own DatabaseHandler or use the provided one.

try
{
 string databasePath = "testdatabase.db";
 // Start with a clear database
 if (File.Exists(databasePath))
 {
 File.Delete(databasePath);
 }
 DatabaseHandler.Instance = new DatabaseHandler(databasePath);
 if (DatabaseHandler.Instance.IsInitialized)
 {
 await DatabaseHandler.Instance.InitTablesAsync();
 Depot myDepot = new("My depot")
 {
 DateOfCreation = DateTime.Now,
 };

 Stock basf = new()
 {
 DepotId = myDepot.Id,
 Name = "BASF",
 ISIN = "DE000BASF111",
 CurrentRate = 41.05,
 };
 basf.Transactions.Add(new()
 {
 StockId = basf.Id,
 DateOfCreation = DateTime.Now,
 Amount = 100,
 Price = 64.10,
 Type = TransactionType.Buy,
 });
 basf.Transactions.Add(new()
 {
 StockId = basf.Id,
 DateOfCreation = DateTime.Now,
 Amount = 25,
 Price = 60.10,
 Type = TransactionType.Sell,
 });
 basf.Dividends.Add(new()
 {
 StockId = basf.Id,
 DateOfDividend = DateTime.Now,
 AmountOfDividend = 3400.00,
 Quantity = 100,
 Tax = 300,
 });
 basf.Dividends.Add(new()
 {
 StockId = basf.Id,
 DateOfDividend = DateTime.Now.AddYears(-1),
 AmountOfDividend = 3400.00,
 Quantity = 100,
 Tax = 300,
 });

 var total = basf.TotalCosts;
 var entryPrice = basf.EntrancePrice;
 var dividend = basf.TotalDividends;
 var growth = basf.Growth;

 myDepot.Stocks.Add(basf);

 Stock daimler = new()
 {
 DepotId = myDepot.Id,
 Name = "Mercedes Benz AG",
 ISIN = "DE0007100000",
 CurrentRate = 55.60,
 };
 daimler.Transactions.Add(new()
 {
 StockId = daimler.Id,
 DateOfCreation = DateTime.Now,
 Amount = 100,
 Price = 58.10,
 Type = TransactionType.Buy,
 });
 daimler.Transactions.Add(new()
 {
 StockId = daimler.Id,
 DateOfCreation = DateTime.Now,
 Amount = 30,
 Price = 38.10,
 Type = TransactionType.Buy,
 });
 daimler.Dividends.Add(new()
 {
 StockId = daimler.Id,
 DateOfDividend = DateTime.Now,
 AmountOfDividend = 5000,
 Quantity = 100,
 Tax = 1200,
 });

 myDepot.Stocks.Add(daimler);
 var totalDepotWorth = myDepot.TotalWorth;
 var overallDividends = myDepot.OverallDividends;

 await DatabaseHandler.Instance.SetStocksWithChildrenAsync(myDepot.Stocks.ToList(), true);
 await DatabaseHandler.Instance.SetDepotWithChildrenAsync(myDepot);

 Depot? dbDepot = await DatabaseHandler.Instance.GetDepotWithChildrenAsync(myDepot.Id);
 Assert.IsNotNull(dbDepot);
 string jsonOriginal = JsonConvert.SerializeObject(myDepot, Formatting.Indented);
 string jsonDatabase = JsonConvert.SerializeObject(dbDepot, Formatting.Indented);

 //Assert.IsTrue(myDepot == dbDepot);
 // Test WatchList
 WatchList watchList = new("My Watchlist")
 {
 DateOfCreation = DateTime.Now,
 };
 basf.WatchListId = watchList.Id;
 watchList.Stocks.Add(basf);

 daimler.WatchListId = watchList.Id;
 watchList.Stocks.Add(daimler);

 await DatabaseHandler.Instance.SetStocksWithChildrenAsync(watchList.Stocks.ToList(), true);
 await DatabaseHandler.Instance.SetWatchListWithChildrenAsync(watchList);
 var loadedWatchLists = await DatabaseHandler.Instance.GetWatchListsWithChildrenAsync();
 Assert.IsTrue(loadedWatchLists?.Count > 0);
 WatchList list = loadedWatchLists?.FirstOrDefault(l => l.Id == watchList.Id);
 Assert.IsNotNull(list);
 Assert.IsTrue(list.Stocks?.Count == 2);

 // Check if the updating works
 var stocks = await DatabaseHandler.Instance.GetStocksWithChildrenAsync();
 Assert.IsTrue(stocks?.Count == 2);

 await DatabaseHandler.Instance.CloseDatabaseAsync();
 }
}
catch (Exception exc)
{
 Assert.Fail(exc.Message);
}
Product Versions Compatible and additional computed target framework versions.
.NET net7.0 net7.0 is compatible.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows 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
1.0.3 351 8/5/2023

Check GitHub releases for changelog.