PortfolioPerformanceTableHelper 1.2.0

dotnet add package PortfolioPerformanceTableHelper --version 1.2.0                
NuGet\Install-Package PortfolioPerformanceTableHelper -Version 1.2.0                
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="PortfolioPerformanceTableHelper" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PortfolioPerformanceTableHelper --version 1.2.0                
#r "nuget: PortfolioPerformanceTableHelper, 1.2.0"                
#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.
// Install PortfolioPerformanceTableHelper as a Cake Addin
#addin nuget:?package=PortfolioPerformanceTableHelper&version=1.2.0

// Install PortfolioPerformanceTableHelper as a Cake Tool
#tool nuget:?package=PortfolioPerformanceTableHelper&version=1.2.0                

PortfolioPerformance-TableHelper

PortfolioPerformance-TableHelper is a helper library for creating CSV entries compatible with Portfolio Performance (https://github.com/buchen/portfolio), an open-source tool for calculating the performance of your stocks and bonds. This library simplifies the generation of CSV files for account and portfolio transactions.

Contributions are welcomed! Feel free to submit pull requests or open issues.

Features

  • Generate account and portfolio transactions in a format readily consumable by Portfolio Performance.
  • Reference support for multiple securities and accounts.
  • Support for different types of transactions like deposit, interest, fee, tax, dividend, transfer, and withdrawal for account transactions.
  • Support for different types of transactions like market transactions and transfers for portfolio transactions.

Usage Example

The library provides methods to create account and portfolio transactions.
Please note that the Library splits columns with a ; so make sure to choose that as delimiting character in PortfolioPerformance.

Here are some examples:

Account Transactions

To generate account transactions, you first create an instance of AccountTransactionsTable and then use the methods provided by this instance to add various transactions. After you're done adding transactions, call the Save method to write these transactions to a CSV file.

[Fact]
public void TestAccountTransactions()
{
    // generate tables
    AccountTransactionsTable accountTable = new AccountTransactionsTable();
    // Generate reference security
    Security tsla = new Security("Tesla, Inc.", "USD");
    tsla.ISIN = "US88160R1014";
    tsla.WKN = "A1CX3T";
    tsla.TickerSymbol = "TSLA";
    // generate reference deposit account
    DepositAccount cashAccount = new DepositAccount("references", "USD");
    DepositAccount transferAccount = new DepositAccount("transfer", "USD");
    // deposit
    accountTable.AddDeposit(DateTime.Parse("01/01/2020"), cashAccount, 125.50, "this is a testnote");
    // interest
    accountTable.AddInterest(DateTime.Parse("12/31/2020"), cashAccount, 10, 2.5, "this is some high interest yield");
    accountTable.AddInterestCharge(DateTime.Parse("01/01/2021"), cashAccount, 7.5, "this is some high interest");
    // fee
    accountTable.AddFee(DateTime.Parse("01/02/2021"), cashAccount, 2.5, tsla, "this is some fee");
    accountTable.AddFeeRefund(DateTime.Parse("01/03/2021"), cashAccount, 2.5, tsla, "this is some fee refund");
    // tax
    accountTable.AddTax(DateTime.Parse("01/04/2021"), cashAccount, 2.5, tsla, "this is some tax");
    accountTable.AddTaxRefund(DateTime.Parse("01/05/2021"), cashAccount,  2.5, tsla, "this is some tax refund");
    // Dividend
    accountTable.AddDividend(DateTime.Parse("01/06/2021"), cashAccount, tsla, 2m,25m,1m,2m,"test dividend");
    // Transfer
    accountTable.AddTransfer(DateTime.Parse("01/07/2021"), cashAccount, transferAccount, 25m, "test dividend");
    accountTable.AddTransfer(DateTime.Parse("01/07/2021"), transferAccount, cashAccount, 25m, "test dividend");
    // withdraw
    accountTable.AddWithdraw(DateTime.Now, cashAccount,  125.50, "this is a removal testnote");
    accountTable.Save();
}

Portfolio Transactions

To generate portfolio transactions, you first create an instance of PortfolioTransactionsTable and then use the methods provided by this instance to add various transactions. After you're done adding transactions, call the Save method to write these transactions to a CSV file.

[Fact]
public void TestSecurityTransactions()
{
    PortfolioTransactionsTable portfolioTable = new PortfolioTransactionsTable();
    // Generate reference security
    Security tsla = new Security("Tesla, Inc.", "USD");
    tsla.ISIN = "US88160R1014";
    tsla.WKN = "A1CX3T";
    tsla.TickerSymbol = "TSLA";
    // generate reference deposit account
    DepositAccount cashAccount = new DepositAccount("references", "EUR");
    SecuritiesAccount securitiesAccount = new SecuritiesAccount("securities", cashAccount);
    SecuritiesAccount securitiesTransferAccount = new SecuritiesAccount("TestTransfer", cashAccount);
    // do transaction
    portfolioTable.AddMarketTransaction(
        DateTime.Parse("01/04/2021"), OrderType.Buy, tsla, cashAccount, securitiesAccount,
        113m*3, shares: 3, 2, 3, 
        "this is a transaction with a target value of 50usd and 10 eur");
    // do transfer
    portfolioTable.AddTransfer(DateTime.Parse("01/05/2021"), securitiesAccount, securitiesTransferAccount,
        tsla, 3.0, 0);
    portfolioTable.Save();
}

Contribution

To contribute to PortfolioPerformance-TableHelper, please make sure to follow these steps:

  1. Fork the repository.
  2. Create a new branch for your features / fixes.
  3. Push your changes to this branch.
  4. Submit a pull request detailing the changes made, why they were necessary, and how they work.

Please note that your code should adhere to a basic coding standard.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
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.2.0 181 8/8/2023
1.1.4 191 8/8/2023
1.1.3.1 191 7/31/2023
1.1.3 156 7/31/2023
1.1.2.1 183 7/28/2023
1.1.2 186 7/21/2023
1.1.1 168 7/19/2023
1.1.0 153 7/19/2023
1.0.0 154 7/18/2023

1.2.0
added capability to keep table sorted. Tis option defaults to false as it is mainly optional. Portfolio Performance will read tables which are unsiorted.
- note 1: this option likely comes with big performance implications
- note 2: might cause issues on existing, unsorted tables,
- note 3: might cause issues when reversing tables and adding entries on reversed table
- note 4: might cause issues when modifying the underlying table manually and not regarding sorting

1.1.5
- final documentation cleanups
- cleanup of compiler suggestions

1.1.4
- Improved documentation on DateTimeHelper
- Added merge function for DateTimeHelper to allow back conversion
- Path naming correction
- Added functionality to PortFolioTaransactions to fetch the closest SpotPrice of a currency in relation to a requested TimeSpos
- fixed GetNewestEntryTime()
- fixed GetOldestEntryTime()


1.1.3.1
- fixed directory path issue

1.1.3
- added fix for loading table
- fixed infinite recursive function
- added fix for wrong portfolio transactions table header
- added a default parameter for portfolio transaction value


1.1.2.1
- added Symbol package to provide xml documentations

1.1.2:
- added capability to retrieve the oldest and newest entry date
- fixed a crasn with GetNewestTable() and GetOldestTable when no table was written to disk yet.

1.1.1:
- added capability to store histories into monthly split files in order to conserve memory requirements

1.1.0:
- bugfix in add fee
- added capability to split output files by month
- documentation improvement
- improved project maintainability