Swiftpack.co - openalloc/FINporter as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by openalloc.
openalloc/FINporter 1.1.11
An open source data transformation tool for investing data
⭐️ 0
🕓 2 weeks ago
macOS
.package(url: "https://github.com/openalloc/FINporter.git", from: "1.1.11")

FINporter

A utility for transforming financial data.

Available both as a finport command line executable and as an open source Swift library to be incorporated in other apps.

FINporter is part of the OpenAlloc family of open source Swift software tools.

Used by investing apps like FlowAllocator and FlowWorth.

Disclaimer

The developers of this project (presently FlowAllocator LLC) are not financial advisers and do not offer tax or investing advice.

Where explicit support is provided for the transformation of data format associated with a service (brokerage, etc.), it is not a recommendation or endorsement of that service.

Software will have defects. Input data can have errors or become outdated. Carefully examine the output from FINporter for accuracy to ensure it is consistent with your investment goals.

For additional disclaiming, read the LICENSE, which is Apache 2.0.

Supported Schema

At present FINporter supports the schemas of the OpenAlloc project, documented at openalloc/AllocData. Applications which support those schemas can make use of FINporter's importers to ingest the specialized formats it supports.

Supported Data Formats

NOTE: support of a data format for a service is not an endorsement or recommendation of that service.

Applications which have integrated FINporter will typically support imports through a menu item or drag-and-drop. The examples below show how the command-line tool, finport, may be used to transform input files to delimited files of standardized schema.

As support for services expands, more examples will be listed below.

Tabular

To detect a supported schema of a delimited file:

$ finport detect mystery.txt
=> openalloc/account: text/csv

Fido (Fidelity) Positions

To transform the "Portfolio_Positions_Mmm-dd-yyyy.csv" export requires four separate commands, as there are four outputs: accounts, account holdings, securities, and 'source meta':

$ finport transform Portfolio_Positions_Jun-30-2021.csv --output-schema openalloc/account
$ finport transform Portfolio_Positions_Jun-30-2021.csv --output-schema openalloc/holding
$ finport transform Portfolio_Positions_Jun-30-2021.csv --output-schema openalloc/security
$ finport transform Portfolio_Positions_Jun-30-2021.csv --output-schema openalloc/meta/source

The 'source meta' can extract the export date from the content, if present, as well as other details.

Each command above will produce comma-separated value data in the following schemas, respectively.

Output schemas:

Fido (Fidelity) Transaction History

To transform the "Accounts_History.csv" export, which contains a record of recent sales, purchases, and other transactions:

$ finport transform Accounts_History.csv

The command above will produce comma-separated value data in the following schema.

NOTE: output changed to the new MTransaction from the deprecated MHistory.

Output schema: openalloc/transaction

Fido (Fidelity) Transaction Sales

To transform the "Realized_Gain_Loss_Account_00000000.csv" export, available in the 'Closed Positions' view of taxable accounts:

$ finport transform Realized_Gain_Loss_Account_00000000.csv

The command above will produce comma-separated value data in the following schema.

NOTE: output changed to the new MTransaction from the deprecated MHistory.

Output schema:

Chuck (Schwab) Positions

There are actually two importers to handle Schwab positions. One for 'All' accounts, and a second for 'Individual' accounts. The files are named differently:

  • All-Accounts-Positions-YYYY-MM-DD-000000.CSV
  • Individual-Positions-YYYY-MM-DD-000000.CSV

To transform either export requires four separate commands, as there are four outputs: accounts, account holdings, securities, and 'source meta':

$ finport transform SOMETHING-Positions-2021-06-30-012345.CSV --output-schema openalloc/account
$ finport transform SOMETHING-Positions-2021-06-30-012345.CSV --output-schema openalloc/holding
$ finport transform SOMETHING-Positions-2021-06-30-012345.CSV --output-schema openalloc/security
$ finport transform SOMETHING-Positions-2021-06-30-012345.CSV --output-schema openalloc/meta/source

Each command above will produce comma-separated value data in the following schemas, respectively.

NOTE: "Cash & Cash Investments" holdings will be assigned a SecurityID of "CORE".

The 'source meta' can extract the export date from the content, if present, as well as other details.

Output schemas:

Chuck (Schwab) Transaction History

To transform the "XXXX1234_Transactions_YYYYMMDD-HHMMSS.CSV" export, which contains a record of recent sales, purchases, and other transactions:

$ finport transform XXXX1234_Transactions_YYYYMMDD-HHMMSS.CSV

The command above will produce comma-separated value data in the following schema.

Output schema: openalloc/transaction

NOTE 1: Schwab's transaction export does not contain realized gains and losses of sales, and so they are not in the imported transaction.

NOTE 2: Security transfers may only specify shares transferred, with no cash valuation specified.

Chuck (Schwab) Transaction Sales BETA

To transform the "XXXX1234_GainLoss_Realized_YYYYMMDD-HHMMSS.CSV" export, available in the 'Closed Positions' view of taxable accounts:

$ finport transform XXXX1234_GainLoss_Realized_YYYYMMDD-HHMMSS.CSV

The command above will produce comma-separated value data in the following schema.

Output schema:

AllocSmart (Allocate Smartly) Export

To transform an export from this service:

$ finport transform "Allocate Smartly Model Portfolio.csv"

The command above will produce comma-separated value data in the following schema.

Output schema:

Command Line

FINporter features finport, a powerful command-line tool to detect and transform financial data, such as exports from your brokerage account.

$ swift build
$ .build/debug/finport

OVERVIEW: A utility for transforming financial data.

USAGE: finport <subcommand>

OPTIONS:
  --version               Show the version.
  -h, --help              Show help information.

SUBCOMMANDS:
  list                    List things available.
  schema                  Describe schema details.
  detect                  Detect schema of file.
  transform               Transform data in file.

  See 'finport help <subcommand>' for detailed help.

If your favorite product (e.g., FlowAllocator) hasn't yet incorporated the latest FINporter library supporting your service, you can still transform exports using finport. See examples above.

See Also

Swift open-source libraries (by the same author):

  • AllocData - standardized data formats for investing-focused apps and tools
  • SwiftCompactor - formatters for the concise display of Numbers, Currency, and Time Intervals
  • SwiftModifiedDietz - A tool for calculating portfolio performance using the Modified Dietz method
  • SwiftNiceScale - generate 'nice' numbers for label ticks over a range, such as for y-axis on a chart
  • SwiftRegressor - a linear regression tool that’s flexible and easy to use
  • SwiftSeriesResampler - transform a series of coordinate values into a new series with uniform intervals
  • SwiftSimpleTree - a nested data structure that’s flexible and easy to use

And commercial apps using this library (by the same author):

  • FlowAllocator - portfolio rebalancing tool for macOS
  • FlowWorth - a new portfolio performance and valuation tracking tool for macOS

License

Copyright 2021 FlowAllocator LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributing

Contributions are welcome. You are encouraged to submit pull requests to fix bugs, improve documentation, or offer new features.

The pull request need not be a production-ready feature or fix. It can be a draft of proposed changes, or simply a test to show that expected behavior is buggy. Discussion on the pull request can proceed from there.

Contributions should ultimately have adequate test coverage and command-line support. See tests for current importers to see what coverage is expected.

GitHub

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

Release Notes

Additional reworking of the history importers to reduce the number of rejected rows
2 weeks ago

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