Add Interactive Brokers Provider (#1722)

* Display multi-currency holdings correctly

* Implement IBKR provider

* Fix: Use historical exchange rate for historical prices

* Add brokerage exchange rate for trades

* Sync historical balances from IBKR

* Add logos in activity history

* Fix privacy mode blur in account view

* Improve IBKR XML Flex report parser errors
This commit is contained in:
Gian-Reto Tarnutzer
2026-05-12 23:45:19 +02:00
committed by GitHub
parent 3c4c32584a
commit ce5d7dd736
81 changed files with 3838 additions and 59 deletions
@@ -0,0 +1,41 @@
class CreateIbkrItemsAndAccounts < ActiveRecord::Migration[7.2]
def change
create_table :ibkr_items, id: :uuid do |t|
t.references :family, null: false, foreign_key: true, type: :uuid
t.string :name
t.string :status, default: "good", null: false
t.boolean :scheduled_for_deletion, default: false, null: false
t.boolean :pending_account_setup, default: false, null: false
t.jsonb :raw_payload
t.string :query_id
t.string :token
t.timestamps
end
add_index :ibkr_items, :status
create_table :ibkr_accounts, id: :uuid do |t|
t.references :ibkr_item, null: false, foreign_key: true, type: :uuid
t.string :name
t.string :ibkr_account_id
t.string :currency
t.decimal :current_balance, precision: 19, scale: 4
t.decimal :cash_balance, precision: 19, scale: 4
t.jsonb :institution_metadata
t.jsonb :raw_holdings_payload, default: [], null: false
t.jsonb :raw_activities_payload, default: {}, null: false
t.jsonb :raw_cash_report_payload, default: [], null: false
t.date :report_date
t.datetime :last_holdings_sync
t.datetime :last_activities_sync
t.timestamps
end
add_index :ibkr_accounts, [ :ibkr_item_id, :ibkr_account_id ],
unique: true,
where: "(ibkr_account_id IS NOT NULL)",
name: "index_ibkr_accounts_on_item_and_ibkr_account_id"
end
end
@@ -0,0 +1,6 @@
class AddExtraToTrades < ActiveRecord::Migration[7.2]
def change
add_column :trades, :extra, :jsonb, default: {}, null: false
add_index :trades, :extra, using: :gin
end
end
@@ -0,0 +1,5 @@
class AddRawEquitySummaryPayloadToIbkrAccounts < ActiveRecord::Migration[7.2]
def change
add_column :ibkr_accounts, :raw_equity_summary_payload, :jsonb, default: [], null: false
end
end
Generated
+42 -2
View File
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2026_05_11_090000) do
ActiveRecord::Schema[7.2].define(version: 2026_05_12_211200) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
@@ -659,6 +659,42 @@ ActiveRecord::Schema[7.2].define(version: 2026_05_11_090000) do
t.index ["security_id"], name: "index_holdings_on_security_id"
end
create_table "ibkr_accounts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "ibkr_item_id", null: false
t.string "name"
t.string "ibkr_account_id"
t.string "currency"
t.decimal "current_balance", precision: 19, scale: 4
t.decimal "cash_balance", precision: 19, scale: 4
t.jsonb "institution_metadata"
t.jsonb "raw_holdings_payload", default: []
t.jsonb "raw_activities_payload", default: {}
t.jsonb "raw_cash_report_payload", default: []
t.date "report_date"
t.datetime "last_holdings_sync"
t.datetime "last_activities_sync"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.jsonb "raw_equity_summary_payload", default: [], null: false
t.index ["ibkr_item_id", "ibkr_account_id"], name: "index_ibkr_accounts_on_item_and_ibkr_account_id", unique: true, where: "(ibkr_account_id IS NOT NULL)"
t.index ["ibkr_item_id"], name: "index_ibkr_accounts_on_ibkr_item_id"
end
create_table "ibkr_items", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "family_id", null: false
t.string "name"
t.string "status", default: "good"
t.boolean "scheduled_for_deletion", default: false
t.boolean "pending_account_setup", default: false, null: false
t.jsonb "raw_payload"
t.string "query_id"
t.string "token"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["family_id"], name: "index_ibkr_items_on_family_id"
t.index ["status"], name: "index_ibkr_items_on_status"
end
create_table "impersonation_session_logs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "impersonation_session_id", null: false
t.string "controller"
@@ -1603,6 +1639,8 @@ ActiveRecord::Schema[7.2].define(version: 2026_05_11_090000) do
t.jsonb "locked_attributes", default: {}
t.string "investment_activity_label"
t.decimal "fee", precision: 19, scale: 4, default: "0.0", null: false
t.jsonb "extra", default: {}, null: false
t.index ["extra"], name: "index_trades_on_extra", using: :gin
t.index ["investment_activity_label"], name: "index_trades_on_investment_activity_label"
t.index ["security_id"], name: "index_trades_on_security_id"
end
@@ -1709,9 +1747,9 @@ ActiveRecord::Schema[7.2].define(version: 2026_05_11_090000) do
t.datetime "last_used_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.check_constraint "sign_count >= 0", name: "chk_webauthn_credentials_sign_count_non_negative"
t.index ["credential_id"], name: "index_webauthn_credentials_on_credential_id", unique: true
t.index ["user_id"], name: "index_webauthn_credentials_on_user_id"
t.check_constraint "sign_count >= 0", name: "chk_webauthn_credentials_sign_count_non_negative"
end
add_foreign_key "account_providers", "accounts", on_delete: :cascade
@@ -1754,6 +1792,8 @@ ActiveRecord::Schema[7.2].define(version: 2026_05_11_090000) do
add_foreign_key "holdings", "accounts", on_delete: :cascade
add_foreign_key "holdings", "securities"
add_foreign_key "holdings", "securities", column: "provider_security_id"
add_foreign_key "ibkr_accounts", "ibkr_items"
add_foreign_key "ibkr_items", "families"
add_foreign_key "impersonation_session_logs", "impersonation_sessions"
add_foreign_key "impersonation_sessions", "users", column: "impersonated_id"
add_foreign_key "impersonation_sessions", "users", column: "impersonator_id"