{"id":15038500,"url":"https://github.com/open-portfolio/allocdata","last_synced_at":"2026-02-10T01:01:29.253Z","repository":{"id":46349463,"uuid":"383310995","full_name":"open-portfolio/AllocData","owner":"open-portfolio","description":"Data Model for Investing Applications","archived":false,"fork":false,"pushed_at":"2023-05-22T04:54:18.000Z","size":354,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-12T06:37:37.520Z","etag":null,"topics":["allocation","csv","data-model","finance","financial-data","investing","investment-analysis","net-worth","portfolio-management","swift-lang","swift-language","swift-library","tabular-data"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-portfolio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-07-06T02:00:43.000Z","updated_at":"2025-05-05T18:06:41.000Z","dependencies_parsed_at":"2023-12-27T03:17:50.993Z","dependency_job_id":null,"html_url":"https://github.com/open-portfolio/AllocData","commit_stats":{"total_commits":107,"total_committers":3,"mean_commits":"35.666666666666664","dds":0.09345794392523366,"last_synced_commit":"0158ea3f20e15f1ffd082d85f0aba4ef83a8dc91"},"previous_names":["openalloc/allocdata"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/open-portfolio/AllocData","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-portfolio%2FAllocData","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-portfolio%2FAllocData/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-portfolio%2FAllocData/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-portfolio%2FAllocData/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-portfolio","download_url":"https://codeload.github.com/open-portfolio/AllocData/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-portfolio%2FAllocData/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267604329,"owners_count":24114522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["allocation","csv","data-model","finance","financial-data","investing","investment-analysis","net-worth","portfolio-management","swift-lang","swift-language","swift-library","tabular-data"],"created_at":"2024-09-24T20:38:42.957Z","updated_at":"2026-02-10T01:01:26.683Z","avatar_url":"https://github.com/open-portfolio.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AllocData\n\n\u003cimg align=\"right\" src=\"https://github.com/openalloc/AllocData/blob/main/Images/logo.png\" width=\"100\" height=\"100\"/\u003eAn open data model for financial applications, typically those used by the do-it-yourself investor.\n\nAvailable as an open source Swift library to be incorporated in other apps.\n\n_AllocData_ is part of the [OpenAlloc](https://github.com/openalloc) family of open source Swift software tools.\n\n## Entities\n\nThe following entities are defined in the _AllocData_ data model.\n\n### MAccount\n\nThis is the `openalloc/account` schema.\n\nEach row of the Accounts table describes a unique account.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| accountID | string | true | true | The account number of the account. |\n| title | string | false | false | The title of the account. |\n| isTaxable | bool | false | false | Is the account taxable? (default: false) |\n| canTrade | bool | false | false | Can you trade securities in the account? (default: false) |\n| accountStrategyID | string | false | false | The strategy associated with this account, if any. |\n\n### MAllocation\n\nThis is the `openalloc/allocation` schema.\n\nEach row of the Allocations table describes a ‘slice’ of a strategy’s\nallocation pie.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| allocationStrategyID | string | true | true | The strategy associated with this allocation. |\n| allocationAssetID | string | true | true | The asset of the allocation. |\n| targetPct | double | false | false | The fraction of the asset in the strategy. |\n| isLocked | bool | false | false | Whether the targetPct is locked (or floating). |\n\n### MAsset\n\nThis is the `openalloc/asset` schema.\n\nEach row of the Assets table describes a unique asset class.\n\nIt also establishes relations between assets.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| assetID | string | true | true | The identifier of the asset. (e.g., 'Bond') |\n| title | string | false | false | The title of the asset. |\n| colorCode | int | false | false | The code for the asset's color palette. |\n| parentAssetID | string | false | false | The id of the parent of the asset. |\n\n### MCap\n\nThis is the `openalloc/cap` schema.\n\nThis table describes limits on allocation for an asset class within an\naccount.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| capAccountID | string | true | true | The account in which the limit will be imposed. |\n| capAssetID | string | true | true | The asset in which the limit will be imposed. |\n| limitPct | double | false | false | Allocate no more than this fraction of the account's capacity to the asset. |\n\n### MHolding\n\nThis is the `openalloc/holding` schema.\n\nA table where each row describes an individual position, with account,\nticker, share count, share basis, etc.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| holdingAccountID | string | true | true | The account hosting the position. |\n| holdingSecurityID | string | true | true | The security of the position. |\n| holdingLotID | string | true | true | The lot of the position, if any. |\n| shareCount | double | false | true | The number of shares held in the position. |\n| shareBasis | double | false | true | The price paid per share of the security. |\n| acquiredAt | date | false | true | The date of the acquisition. |\n\n### MSecurity\n\nThis is the `openalloc/security` schema.\n\nTable where each row describes a unique security, with its ticker, asset\nclass and latest price.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| securityID | string | true | true | The symbol/securityID of the security. |\n| securityAssetID | string | false | false | The asset class of the security. |\n| sharePrice | double | false | false | The reported price of one share of the security. |\n| updatedAt | date | false | false | The timestamp of the the reported price. |\n| securityTrackerID | string | false | false | The index the security is tracking. |\n\n### MStrategy\n\nThis is the `openalloc/strategy` schema.\n\nEach row of the Strategies table describes a single allocation strategy.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| strategyID | string | true | true | The identifier of the strategy. |\n| title | string | false | false | The title of the strategy. |\n\n### MTracker\n\nThis is the `openalloc/tracker` schema.\n\nEach row of the Tracker table describes a many-to-many\nrelationship between Securities.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| trackerID | string | true | true | The identifier of the tracking index. |\n| title | string | false | false | The title of the tracking index. |\n\n### MTransaction\n\nThis is the `openalloc/transaction` schema.\n\nA table of recent transaction history, including purchases, sales, and other actions.\n\nNOTE: this replaces the deprecated 'MHistory' entity.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| txnAction | string | true | true | The code of the type of transaction (see below). |\n| txnTransactedAt | date | true | true | The date of the transaction. |\n| txnAccountID | string | true | true | The account in which the transaction occurred. |\n| txnSecurityID | string | true | true | The security involved in the transaction. |\n| txnLotID | string | true | true | The lot of the position involved in the transaction (blank if none). |\n| txnShareCount | double | true | true | The number of shares transacted. |\n| txnSharePrice | double | false | false | The price at which the share(s) transacted. (0 if none provided). |\n| realizedGainShort | double | false | false | The total short-term realized gain (or loss) from a sale. |\n| realizedGainLong | double | false | false | The total long-term realized gain (or loss) from a sale. |\n\nNote that brokerage exports may omit share price on security transfers.\n\nThe action types:\n\n| Type | ShareCount | SharePrice | SecurityID | Descript |\n| ---- | ---------- | ---------- | ---------- | -------- |\n| buysell | \\\u003c0 if sale; \\\u003e0 if purchase | \\\u003e0, price/share | required | Purchase/sale of security to/from cash. | \n| income | amount of income | 1.0 (cash) | if dividend | Income from interest, or the dividend of a stock/ETF/etc.. | \n| transfer | \\\u003c0 is outgoing; \\\u003e0 is incoming | 1.0 if cash; \\\u003e0 for security; nil if none provided | if not cash | Transfer of security/cash to/from external source. | \n| miscflow | \\\u003c0 is outgoing; \\\u003e0 is incoming | 1.0 (cash) | ignored | Neutral (non-income) cashflow to/from account. | \n\n### MRebalanceAllocation\n\nThis is the `openalloc/rebalance/allocation` schema.\n\nEach row of the RebalanceAllocation table describes an allocation that drives a rebalance.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| allocationAccountID | string | true | true | The account to which the asset is allocated. |\n| allocationAssetID | string | true | true | The asset class of the allocation. |\n| amount | double | true | false | The amount in dollars allocated. |\n\n### MRebalancePurchase\n\nThis is the `openalloc/rebalance/purchase` schema.\n\nEach row of the RebalancePurchase table describes an acquisition of a position to satisfy a rebalance.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| purchaseAccountID | string | true | true | The account to host the position. |\n| purchaseAssetID | string | true | true | The asset class of the position to acquire. |\n| amount | double | true | false | The amount in dollars to acquire. |\n\n### MRebalanceSale\n\nThis is the `openalloc/rebalance/sale` schema.\n\nEach row of the RebalanceSale table describes a liquidation of a position to satisfy a rebalance.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| saleAccountID | string | true | true | The account hosting the position. |\n| saleSecurityID | string | true | true | The security of the position. |\n| saleLotID | string | true | true | The lot of the position, if any. |\n| amount | double | true | false | The amount in dollars to liquidate from this position. |\n| shareCount | double | false | false | Estimated number of shares to liquidate from this position. |\n| liquidateAll | bool | false | false | If true, the entire position can be liquidated. |\n\n### MValuationSnapshot\n\nThis is the `openalloc/valuation/snapshot` schema.\n\nEach row of the ValuationSnapshot table describes a valuation captured at a particular time.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| valuationSnapshotID | string | true | true | The unique valuation snapshot identifier. |\n| capturedAt | date | true | false | The timestamp when the snapshot was created. |\n\n### MValuationPosition\n\nThis is the `openalloc/valuation/position` schema.\n\nEach row of the valuation position table describes a position captured at a particular time for a valuation snapshot. It can represent multiple holdings of an account for an asset class.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| valuationPositionSnapshotID | string | true | true | The valuation snapshot ID for the position. |\n| valuationPositionAccountID | string | true | true | The account hosting the position. |\n| valuationPositionAssetID | string | true | true | The asset class of the position. |\n| totalBasis | double | true | false | The price paid to establish position. |\n| marketValue | double | true | false | The market value of the position. |\n\n### MValuationCashflow\n\nThis is the `openalloc/valuation/cashflow` schema.\n\nEach row of the valuation cashflow table describes a cash flow at a particular time. It is not explicitly bound to any valuation snapshot. Typically, multiple history items are rolled up into a cash flow item.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| valuationCashflowTransactedAt | date | true | true | The timestamp when this flow occurred. |\n| valuationCashflowAccountID | string | true | true | The account in which the flow occurred. |\n| valuationCashflowAssetID | string | true | true | The asset class flowed. |\n| amount | double | true | false | The amount of the flow (-outgoing, +incoming). |\n\n### MSourceMeta\n\nThis is the `openalloc/meta/source` schema.\n\nEach row of the SourceMeta table describes an import or transformation of source data. It can also include extracted data, such as the published export date found within.\n\n| Name | Type | IsRequired | IsKey | Descript |\n| ---- | ---- | ---------- | ----- | -------- |\n| sourceMetaID | string | true | true | The unique ID of the source meta record. |\n| url | string | false | false | The source URL, if any. |\n| importerID | string | false | false | The id of the importer/transformer, if any. |\n| exportedAt | date | false | false | The published export date of the source data, if any. |\n\n## Data Formats\n\n### Dates\n\nIn delimited text files, the dates should be in the ISO 8601 / RFC 3339 format (e.g., \"2012-12-31T19:00:00Z\").\n\n## API\n\nEntities in the data model all conform to the following protocols:\n\n### Base\n\nBase functionality for all entities. Currently just a schema identifier.\n\n```swift\npublic protocol AllocBase {\n    static var schema: AllocSchema { get }\n}\n```\n\n### Keyed\n\nUsed to retrieve and generate the entity's primary key.\n\nThis new struct-based implementation replaces the old string-based one.\n\nThe `emptyKey` property can be used for picker tag values, as an example.\n\n```swift\npublic protocol AllocKeyed: Hashable {\n    associatedtype Key: Hashable, Codable\n\n    var primaryKey: Key { get }\n    static var emptyKey: Key { get }\n}\n```\n\nThe entities also conform to the `Identifiable` protocol where the id is the primary key.\n\n### Rowed\n\nUsed to parse (decode) and generate (encode) delimited data for the entities.\n\n```swift\npublic protocol AllocRowed: AllocKeyed {\n    // pre-decoded row, without strong typing\n    typealias RawRow = [String: String]\n\n    // decoded row, with stronger typing\n    typealias DecodedRow = [String: AnyHashable]\n\n    // create object from row\n    init(from row: DecodedRow) throws\n\n    static func decode(_ rawRows: [RawRow], rejectedRows: inout [RawRow]) throws -\u003e [DecodedRow]\n\n    // additive update from row\n    mutating func update(from row: DecodedRow) throws\n\n    static func getPrimaryKey(_ row: DecodedRow) throws -\u003e Key\n}\n```\n\n### Attributable\n\nUsed to fetch a description of the entity's attributes.\n\n```swift\npublic protocol AllocAttributable {\n    static var attributes: [AllocAttribute] { get }\n}\n```\n\n## See Also\n\nSwift open-source libraries (by the same author):\n\nThis app is a member of the _Open Portfolio Project_.\n\n* [_Open Portfolio_](https://open-portfolio.github.io/) - _Open Portfolio_ product website\n* [_Open Portfolio_ Project](https://github.com/open-portfolio/) - Github site for the development project, including full source code\n## License\n\nCopyright 2021, 2022 OpenAlloc LLC\n\nLicensed 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\n\n[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nUnless 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.\n\n## Contributing\n\nContributions are welcome. You are encouraged to submit pull requests to fix bugs, improve documentation, or offer new features. \n\nThe 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.\n\nContributions should ultimately have adequate test coverage. See tests for current entities to see what coverage is expected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-portfolio%2Fallocdata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-portfolio%2Fallocdata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-portfolio%2Fallocdata/lists"}