Swiftpack.co - Nef10/SwiftBeanCountWealthsimpleMapper as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Nef10.
Nef10/SwiftBeanCountWealthsimpleMapper v1.5.0
Swift library to convert download Wealthsimple data to the SwiftBeanCount model
⭐️ 0
🕓 38 weeks ago
.package(url: "https://github.com/Nef10/SwiftBeanCountWealthsimpleMapper.git", from: "v1.5.0")

SwiftBeanCountWealthsimpleMapper

CI Status Documentation percentage License: MIT Latest version platforms supported: linux | macOS | iOS | watchOS | tvOS SPM compatible

This project is part for SwiftBeanCount, please check out the main documentation here.

What

This is a small library to convert downloaded data from Wealthsimple (via WealthsimpleDownloader) to the Beancount format (via SwiftBeanCountModel).

Beancount meta data

The library relies heavily on meta data in your Beancount file to find accounts and commodities. Please add these to your Beancount file:

Commodities

If the commodity in your ledger differs from the symbol used by Wealthsimple, simply add wealthsimple-symbol as meta data:

2011-10-18 commodity ACWVETF
  wealthsimple-symbol: "ACWV"

Accounts

For Wealthsimple accounts themselves, you need to add this metadata: importer-type: "wealthsimple" and number: "XXX". If the account can hold more than one commodity (all accounts except chequing and saving), it needs to follow this structure: Assets:X:Y:Z:CashAccountName, Assets:X:Y:Z:CommodityName, Assets:X:Y:Z:OtherCommodityName. The name of the cash account does not matter, but all other account must end with the commodity symbol (see above). Add the importer-type and number only to the cash account.

For accounts used in transactions to and from your Wealthsimple accounts you need to provide meta data as well. These is in the form of wealthsimple-key: "accountNumber1 accountNumber2". The account number is the same as above, and you can specify one or multiple per key. As keys use these values:

  • For dividend income accounts wealthsimple-dividend-COMMODITYSYMBOL, e.g. wealthsimple-dividend-XGRO
  • For the assset account you are using to contribute to registered accounts from, use wealthsimple-contribution
  • For the assset account you are using to deposit to non-registered accounts from, use wealthsimple-deposit
  • Use wealthsimple-fee on an expense account to track the wealthsimple fees
  • Use wealthsimple-non-resident-withholding-tax on an expense account for non resident withholding tax
  • In case some transaction does not balance within your ledger, an expense account with wealthsimple-rounding will get the difference
  • If you want to track contribution room, use wealthsimple-contribution-room on an asset and expense account (optional, if not set it will not create postings for the contribution room)
  • Other values for transaction types you might incur are:
    • wealthsimple-reimbursement
    • wealthsimple-interest
    • wealthsimple-withdrawal
    • wealthsimple-payment-transfer-in
    • wealthsimple-payment-transfer-out
    • wealthsimple-transfer-in
    • wealthsimple-transfer-out
    • wealthsimple-referral-bonus
    • wealthsimple-giveaway-bonus
    • wealthsimple-refund
    • wealthsimple-payment-spend (optional, will use fallback account if not provided)
Full Example
2020-07-31 open Assets:Checking:Wealthsimple CAD
  importer-type: "wealthsimple"
  number: "A001"

2020-07-31 open Assets:Investment:Wealthsimple:TFSA:Parking CAD
  importer-type: "wealthsimple"
  number: "B002"
2020-07-31 open Assets:Investment:Wealthsimple:TFSA:ACWV ACWV
2020-07-31 open Assets:Investment:Wealthsimple:TFSA:XGRO XGRO

2020-07-31 open Income:Capital:Dividend:ACWV USD
  wealthsimple-dividend-ACWV: "A001 B002"

2020-07-31 open Assets:Checking:Bank CAD
  wealthsimple-contribution: "A001 B002"

2020-07-31 open Expenses:FinancialInstitutions:Investment:NonRegistered:Fees
  wealthsimple-fee: "A001"

2020-07-31 open Expenses:FinancialInstitutions:Investment:Registered:Fees
  wealthsimple-fee: "B002"

2020-07-31 open Expenses:Tax:NRWT
  wealthsimple-non-resident-withholding-tax: "A001 B002"

2020-07-31 open Assets:TFSAContributionRoom TFSA.ROOM
  wealthsimple-contribution-room: "B002"

2020-07-31 open Expenses:TFSAContributionRoom TFSA.ROOM
  wealthsimple-contribution-room: "B002"

How

  1. First create an instance of the mapper via WealthsimpleLedgerMapper(ledger:), passing the ledger which contains the meta data discussed above.
  2. Assign the downloaded wealthsimple accounts to the accounts property on the mapper.
  3. Call mapPositionsToPriceAndBalance or mapTransactionsToPriceAndTransactions to map your downloaded positions / transactions to SwiftBeanCountModel Prices and Balances / Prices and Transactions.

Please also check out the complete documentation here. Additionally, you can have a look at the SwiftBeanCountDownloaderApp which uses this library.

Usage

The library supports the Swift Package Manger, so simply add a dependency in your Package.swift:

.package(url: "https://github.com/Nef10/SwiftBeanCountWealthsimpleMapper.git", .upToNextMajor(from: "X.Y.Z")),

Limitations

Please note that I developed this library for my own needs and there may be bugs. It currently has some limitations:

  • Sell Gains are not calculated
  • In case a transactions does not balance it will not add a rounding posting because SwiftBeanCountModel does not yet fully supporting Beancount rounding

Pull requests to extend the scope or remove limitations are very welcome.

GitHub

link
Stars: 0
Last commit: 5 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1.5.0 Stock Splits
38 weeks ago

Changes

🚀 Features

  • Support stock splits @Nef10 (#131)

🧰 Maintenance

  • Bump release-drafter from 5.18.1 to 5.19.0 @file-sync-app (#130)
  • Bump actions/checkout from 2 to 3 @file-sync-app (#128)
  • Bump fwal/setup-swift to 1.13.1 @file-sync-app (#126)
  • Bump setup-swift from 1.11.0 to 1.12.0 @file-sync-app (#124)
  • Bump actions/github-script from 5.1.0 to 6.0.0 @file-sync-app (#123)
  • Bump release-drafter from 5.18.0 to 5.18.1 @file-sync-app (#122)
  • Bump very_good_coverage from 1.2.0 to 1.2.1 @file-sync-app (#121)
  • Bump release-drafter from 5.17.6 to 5.18.0 @file-sync-app (#116)
  • Update SwiftLint config for 0.46.1 @file-sync-app (#114)
  • Bump release-drafter from 5.16.2 to 5.17.6 @file-sync-app (#113)
  • Bump release-drafter from 5.15.0 to 5.16.2 @file-sync-app (#111)
  • Bump actions/github-script from 5.0.0 to 5.1.0 @file-sync-app (#109)
  • Bump fwal/setup-swift from 1.10.0 to 1.11.0 @file-sync-app (#108)
  • Bump tibdex/github-app-token from 1.5.0 to 1.5.1 @file-sync-app (#107)
  • Update SwiftLint config for 0.45.1 @file-sync-app (#106)
  • Bump fwal/setup-swift from 1.9.0 to 1.10.0 @file-sync-app (#105)
  • Bump fwal/setup-swift to 1.9.0 @file-sync-app (#103)
  • Update SwiftLint config for 0.45.0 @file-sync-app (#98)
  • Bump tibdex/github-app-token from 1.4.0 to 1.5.0 @Nef10 (#102)

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics