wbportfolio 2.2.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of wbportfolio might be problematic. Click here for more details.
- wbportfolio/__init__.py +1 -0
- wbportfolio/admin/__init__.py +12 -0
- wbportfolio/admin/asset.py +47 -0
- wbportfolio/admin/custodians.py +9 -0
- wbportfolio/admin/portfolio.py +127 -0
- wbportfolio/admin/portfolio_relationships.py +22 -0
- wbportfolio/admin/product_groups.py +42 -0
- wbportfolio/admin/products.py +80 -0
- wbportfolio/admin/reconciliations.py +14 -0
- wbportfolio/admin/registers.py +17 -0
- wbportfolio/admin/roles.py +19 -0
- wbportfolio/admin/synchronization/__init__.py +2 -0
- wbportfolio/admin/synchronization/admin.py +114 -0
- wbportfolio/admin/synchronization/portfolio_synchronization.py +18 -0
- wbportfolio/admin/synchronization/price_computation.py +21 -0
- wbportfolio/admin/transactions/__init__.py +5 -0
- wbportfolio/admin/transactions/claim.py +16 -0
- wbportfolio/admin/transactions/dividends.py +14 -0
- wbportfolio/admin/transactions/fees.py +35 -0
- wbportfolio/admin/transactions/trades.py +49 -0
- wbportfolio/admin/transactions/transactions.py +37 -0
- wbportfolio/analysis/__init__.py +0 -0
- wbportfolio/analysis/claims.py +235 -0
- wbportfolio/apps.py +5 -0
- wbportfolio/contrib/__init__.py +0 -0
- wbportfolio/contrib/company_portfolio/__init__.py +0 -0
- wbportfolio/contrib/company_portfolio/admin.py +28 -0
- wbportfolio/contrib/company_portfolio/apps.py +29 -0
- wbportfolio/contrib/company_portfolio/configs/__init__.py +3 -0
- wbportfolio/contrib/company_portfolio/configs/display.py +182 -0
- wbportfolio/contrib/company_portfolio/configs/endpoints.py +34 -0
- wbportfolio/contrib/company_portfolio/configs/previews.py +37 -0
- wbportfolio/contrib/company_portfolio/constants.py +1 -0
- wbportfolio/contrib/company_portfolio/dynamic_preferences_registry.py +87 -0
- wbportfolio/contrib/company_portfolio/factories.py +32 -0
- wbportfolio/contrib/company_portfolio/filters.py +127 -0
- wbportfolio/contrib/company_portfolio/management.py +19 -0
- wbportfolio/contrib/company_portfolio/migrations/0001_initial.py +214 -0
- wbportfolio/contrib/company_portfolio/migrations/__init__.py +0 -0
- wbportfolio/contrib/company_portfolio/models.py +334 -0
- wbportfolio/contrib/company_portfolio/scripts.py +76 -0
- wbportfolio/contrib/company_portfolio/serializers.py +303 -0
- wbportfolio/contrib/company_portfolio/tasks.py +19 -0
- wbportfolio/contrib/company_portfolio/tests/__init__.py +0 -0
- wbportfolio/contrib/company_portfolio/tests/conftest.py +161 -0
- wbportfolio/contrib/company_portfolio/tests/test_models.py +161 -0
- wbportfolio/contrib/company_portfolio/urls.py +29 -0
- wbportfolio/contrib/company_portfolio/viewsets.py +195 -0
- wbportfolio/defaults/__init__.py +0 -0
- wbportfolio/defaults/fees/__init__.py +0 -0
- wbportfolio/defaults/fees/default.py +92 -0
- wbportfolio/defaults/portfolio/__init__.py +0 -0
- wbportfolio/defaults/portfolio/default_rebalancing.py +45 -0
- wbportfolio/dynamic_preferences_registry.py +58 -0
- wbportfolio/factories/__init__.py +35 -0
- wbportfolio/factories/adjustments.py +17 -0
- wbportfolio/factories/assets.py +75 -0
- wbportfolio/factories/claim.py +39 -0
- wbportfolio/factories/custodians.py +11 -0
- wbportfolio/factories/dividends.py +14 -0
- wbportfolio/factories/fees.py +15 -0
- wbportfolio/factories/indexes.py +17 -0
- wbportfolio/factories/portfolio_cash_flow.py +20 -0
- wbportfolio/factories/portfolio_cash_targets.py +15 -0
- wbportfolio/factories/portfolio_swing_pricings.py +15 -0
- wbportfolio/factories/portfolios.py +59 -0
- wbportfolio/factories/product_groups.py +28 -0
- wbportfolio/factories/products.py +56 -0
- wbportfolio/factories/pytest_utils.py +121 -0
- wbportfolio/factories/reconciliations.py +23 -0
- wbportfolio/factories/roles.py +20 -0
- wbportfolio/factories/synchronization.py +40 -0
- wbportfolio/factories/trades.py +35 -0
- wbportfolio/factories/transactions.py +21 -0
- wbportfolio/fdm/__init__.py +0 -0
- wbportfolio/fdm/tasks.py +12 -0
- wbportfolio/filters/__init__.py +32 -0
- wbportfolio/filters/assets.py +485 -0
- wbportfolio/filters/assets_and_net_new_money_progression.py +42 -0
- wbportfolio/filters/custodians.py +10 -0
- wbportfolio/filters/esg.py +22 -0
- wbportfolio/filters/performances.py +171 -0
- wbportfolio/filters/portfolios.py +24 -0
- wbportfolio/filters/positions.py +178 -0
- wbportfolio/filters/products.py +157 -0
- wbportfolio/filters/roles.py +26 -0
- wbportfolio/filters/signals.py +92 -0
- wbportfolio/filters/transactions/__init__.py +20 -0
- wbportfolio/filters/transactions/claim.py +394 -0
- wbportfolio/filters/transactions/fees.py +66 -0
- wbportfolio/filters/transactions/trades.py +224 -0
- wbportfolio/filters/transactions/transactions.py +98 -0
- wbportfolio/import_export/__init__.py +0 -0
- wbportfolio/import_export/backends/__init__.py +2 -0
- wbportfolio/import_export/backends/ubs/__init__.py +3 -0
- wbportfolio/import_export/backends/ubs/asset_position.py +45 -0
- wbportfolio/import_export/backends/ubs/fees.py +63 -0
- wbportfolio/import_export/backends/ubs/instrument_price.py +44 -0
- wbportfolio/import_export/backends/ubs/mixin.py +15 -0
- wbportfolio/import_export/backends/utils.py +58 -0
- wbportfolio/import_export/backends/wbfdm/__init__.py +2 -0
- wbportfolio/import_export/backends/wbfdm/adjustment.py +50 -0
- wbportfolio/import_export/backends/wbfdm/dividend.py +16 -0
- wbportfolio/import_export/backends/wbfdm/mixin.py +15 -0
- wbportfolio/import_export/handlers/__init__.py +0 -0
- wbportfolio/import_export/handlers/adjustment.py +39 -0
- wbportfolio/import_export/handlers/asset_position.py +167 -0
- wbportfolio/import_export/handlers/dividend.py +80 -0
- wbportfolio/import_export/handlers/fees.py +58 -0
- wbportfolio/import_export/handlers/portfolio_cash_flow.py +57 -0
- wbportfolio/import_export/handlers/register.py +43 -0
- wbportfolio/import_export/handlers/trade.py +191 -0
- wbportfolio/import_export/parsers/__init__.py +0 -0
- wbportfolio/import_export/parsers/default_mapping.py +30 -0
- wbportfolio/import_export/parsers/jpmorgan/__init__.py +0 -0
- wbportfolio/import_export/parsers/jpmorgan/customer_trade.py +63 -0
- wbportfolio/import_export/parsers/jpmorgan/fees.py +64 -0
- wbportfolio/import_export/parsers/jpmorgan/strategy.py +116 -0
- wbportfolio/import_export/parsers/jpmorgan/valuation.py +41 -0
- wbportfolio/import_export/parsers/leonteq/__init__.py +0 -0
- wbportfolio/import_export/parsers/leonteq/customer_trade.py +47 -0
- wbportfolio/import_export/parsers/leonteq/equity.py +81 -0
- wbportfolio/import_export/parsers/leonteq/fees.py +70 -0
- wbportfolio/import_export/parsers/leonteq/trade.py +94 -0
- wbportfolio/import_export/parsers/leonteq/valuation.py +39 -0
- wbportfolio/import_export/parsers/natixis/__init__.py +0 -0
- wbportfolio/import_export/parsers/natixis/customer_trade.py +62 -0
- wbportfolio/import_export/parsers/natixis/d1_customer_trade.py +66 -0
- wbportfolio/import_export/parsers/natixis/d1_equity.py +80 -0
- wbportfolio/import_export/parsers/natixis/d1_fees.py +58 -0
- wbportfolio/import_export/parsers/natixis/d1_trade.py +70 -0
- wbportfolio/import_export/parsers/natixis/d1_valuation.py +41 -0
- wbportfolio/import_export/parsers/natixis/dividend.py +53 -0
- wbportfolio/import_export/parsers/natixis/equity.py +60 -0
- wbportfolio/import_export/parsers/natixis/fees.py +53 -0
- wbportfolio/import_export/parsers/natixis/trade.py +63 -0
- wbportfolio/import_export/parsers/natixis/utils.py +76 -0
- wbportfolio/import_export/parsers/natixis/valuation.py +46 -0
- wbportfolio/import_export/parsers/refinitiv/__init__.py +0 -0
- wbportfolio/import_export/parsers/refinitiv/adjustment.py +24 -0
- wbportfolio/import_export/parsers/sg_lux/__init__.py +0 -0
- wbportfolio/import_export/parsers/sg_lux/custodian_positions.py +70 -0
- wbportfolio/import_export/parsers/sg_lux/customer_trade.py +75 -0
- wbportfolio/import_export/parsers/sg_lux/customer_trade_pending_slk.py +140 -0
- wbportfolio/import_export/parsers/sg_lux/customer_trade_slk.py +80 -0
- wbportfolio/import_export/parsers/sg_lux/customer_trade_without_pw.py +57 -0
- wbportfolio/import_export/parsers/sg_lux/equity.py +137 -0
- wbportfolio/import_export/parsers/sg_lux/fees.py +56 -0
- wbportfolio/import_export/parsers/sg_lux/perf_fees.py +51 -0
- wbportfolio/import_export/parsers/sg_lux/portfolio_cash_flow.py +29 -0
- wbportfolio/import_export/parsers/sg_lux/portfolio_future_cash_flow.py +36 -0
- wbportfolio/import_export/parsers/sg_lux/registers.py +210 -0
- wbportfolio/import_export/parsers/sg_lux/sylk.py +248 -0
- wbportfolio/import_export/parsers/sg_lux/utils.py +36 -0
- wbportfolio/import_export/parsers/sg_lux/valuation.py +53 -0
- wbportfolio/import_export/parsers/societe_generale/__init__.py +0 -0
- wbportfolio/import_export/parsers/societe_generale/customer_trade.py +54 -0
- wbportfolio/import_export/parsers/societe_generale/strategy.py +94 -0
- wbportfolio/import_export/parsers/societe_generale/valuation.py +37 -0
- wbportfolio/import_export/parsers/tellco/__init__.py +0 -0
- wbportfolio/import_export/parsers/tellco/customer_trade.py +64 -0
- wbportfolio/import_export/parsers/tellco/equity.py +86 -0
- wbportfolio/import_export/parsers/tellco/valuation.py +52 -0
- wbportfolio/import_export/parsers/ubs/__init__.py +0 -0
- wbportfolio/import_export/parsers/ubs/api/__init__.py +0 -0
- wbportfolio/import_export/parsers/ubs/api/asset_position.py +106 -0
- wbportfolio/import_export/parsers/ubs/api/fees.py +31 -0
- wbportfolio/import_export/parsers/ubs/api/instrument_price.py +20 -0
- wbportfolio/import_export/parsers/ubs/api/utils.py +0 -0
- wbportfolio/import_export/parsers/ubs/customer_trade.py +60 -0
- wbportfolio/import_export/parsers/ubs/equity.py +97 -0
- wbportfolio/import_export/parsers/ubs/historical_customer_trade.py +67 -0
- wbportfolio/import_export/parsers/ubs/valuation.py +52 -0
- wbportfolio/import_export/parsers/vontobel/__init__.py +0 -0
- wbportfolio/import_export/parsers/vontobel/asset_position.py +97 -0
- wbportfolio/import_export/parsers/vontobel/customer_trade.py +54 -0
- wbportfolio/import_export/parsers/vontobel/historical_customer_trade.py +40 -0
- wbportfolio/import_export/parsers/vontobel/instrument.py +34 -0
- wbportfolio/import_export/parsers/vontobel/management_fees.py +86 -0
- wbportfolio/import_export/parsers/vontobel/performance_fees.py +35 -0
- wbportfolio/import_export/parsers/vontobel/trade.py +38 -0
- wbportfolio/import_export/parsers/vontobel/utils.py +17 -0
- wbportfolio/import_export/parsers/vontobel/valuation.py +29 -0
- wbportfolio/import_export/resources/__init__.py +0 -0
- wbportfolio/import_export/resources/assets.py +68 -0
- wbportfolio/import_export/resources/trades.py +41 -0
- wbportfolio/import_export/utils.py +42 -0
- wbportfolio/metric/__init__.py +0 -0
- wbportfolio/metric/backends/__init__.py +2 -0
- wbportfolio/metric/backends/base.py +86 -0
- wbportfolio/metric/backends/constants.py +222 -0
- wbportfolio/metric/backends/portfolio_base.py +255 -0
- wbportfolio/metric/backends/portfolio_esg.py +66 -0
- wbportfolio/metric/tests/__init__.py +0 -0
- wbportfolio/metric/tests/conftest.py +4 -0
- wbportfolio/metric/tests/test_portfolio_base.py +135 -0
- wbportfolio/metric/tests/test_portfolio_esg.py +69 -0
- wbportfolio/migrations/0001_initial_squashed.py +13848 -0
- wbportfolio/migrations/0002_product_default_sub_account_squashed_0039_alter_assetallocation_company_and_more.py +3836 -0
- wbportfolio/migrations/0040_instrument_financial_instrument.py +26 -0
- wbportfolio/migrations/0041_remove_listresearch_research_ptr_and_more.py +129 -0
- wbportfolio/migrations/0042_instrumentlist_instrumentlistthroughmodel_and_more.py +71 -0
- wbportfolio/migrations/0043_alter_instrumentlistthroughmodel_options_and_more.py +238 -0
- wbportfolio/migrations/0044_alter_instrumentlist_identifier.py +35 -0
- wbportfolio/migrations/0045_alter_instrument_financial_instrument.py +26 -0
- wbportfolio/migrations/0046_add_product_default_account.py +166 -0
- wbportfolio/migrations/0047_remove_product_default_sub_account.py +14 -0
- wbportfolio/migrations/0048_alter_trade_status.py +29 -0
- wbportfolio/migrations/0049_trade_claimed_shares.py +25 -0
- wbportfolio/migrations/0050_fees_fee_date_fees_wbportfolio_transac_1f7a29_idx.py +44 -0
- wbportfolio/migrations/0051_delete_macroreview.py +11 -0
- wbportfolio/migrations/0052_remove_cash_instrument_ptr_and_more.py +888 -0
- wbportfolio/migrations/0053_remove_product_group.py +132 -0
- wbportfolio/migrations/0054_portfolioinstrumentpreferredclassificationthroughmodel_and_more.py +270 -0
- wbportfolio/migrations/0055_remove_product__custom_management_rebates_and_more.py +139 -0
- wbportfolio/migrations/0056_remove_companyportfoliodata_assets_under_management_currency_and_more.py +56 -0
- wbportfolio/migrations/0057_alter_portfolio_preferred_instrument_classifications_and_more.py +36 -0
- wbportfolio/migrations/0058_pmsinstrument.py +23 -0
- wbportfolio/migrations/0059_fees_unique_fees.py +51 -0
- wbportfolio/migrations/0060_alter_portfolioportfoliothroughmodel_type.py +21 -0
- wbportfolio/migrations/0061_portfolio_bank_accounts_product_bank_account_and_more.py +175 -0
- wbportfolio/migrations/0062_alter_dailyportfoliocashflow_options.py +20 -0
- wbportfolio/migrations/0063_accountreconciliation_accountreconciliationline_and_more.py +133 -0
- wbportfolio/migrations/0064_alter_portfolio_managers_portfolio_is_tracked_and_more.py +40 -0
- wbportfolio/migrations/0065_alter_portfolio_managers_claim_as_shares_and_more.py +73 -0
- wbportfolio/migrations/0066_assetposition_initial_shares_at_custodian_and_more.py +108 -0
- wbportfolio/migrations/0067_assetposition_unique_asset_position.py +77 -0
- wbportfolio/migrations/0068_trade_internal_trade_trade_marked_as_internal_and_more.py +59 -0
- wbportfolio/migrations/0069_remove_portfolio_is_invested_and_more.py +56 -0
- wbportfolio/migrations/0070_remove_assetposition_unique_asset_position_and_more.py +82 -0
- wbportfolio/migrations/0071_alter_trade_options_alter_trade_order.py +22 -0
- wbportfolio/migrations/__init__.py +0 -0
- wbportfolio/models/__init__.py +26 -0
- wbportfolio/models/adjustments.py +246 -0
- wbportfolio/models/asset.py +869 -0
- wbportfolio/models/custodians.py +101 -0
- wbportfolio/models/indexes.py +33 -0
- wbportfolio/models/mixins/__init__.py +0 -0
- wbportfolio/models/mixins/instruments.py +127 -0
- wbportfolio/models/mixins/liquidity_stress_test.py +1307 -0
- wbportfolio/models/portfolio.py +1039 -0
- wbportfolio/models/portfolio_cash_flow.py +167 -0
- wbportfolio/models/portfolio_cash_targets.py +46 -0
- wbportfolio/models/portfolio_relationship.py +135 -0
- wbportfolio/models/portfolio_swing_pricings.py +51 -0
- wbportfolio/models/product_groups.py +230 -0
- wbportfolio/models/products.py +569 -0
- wbportfolio/models/reconciliations/__init__.py +2 -0
- wbportfolio/models/reconciliations/account_reconciliation_lines.py +192 -0
- wbportfolio/models/reconciliations/account_reconciliations.py +102 -0
- wbportfolio/models/reconciliations/reconciliations.py +25 -0
- wbportfolio/models/registers.py +132 -0
- wbportfolio/models/roles.py +208 -0
- wbportfolio/models/synchronization/__init__.py +3 -0
- wbportfolio/models/synchronization/portfolio_synchronization.py +292 -0
- wbportfolio/models/synchronization/price_computation.py +200 -0
- wbportfolio/models/synchronization/synchronization.py +188 -0
- wbportfolio/models/transactions/__init__.py +7 -0
- wbportfolio/models/transactions/claim.py +634 -0
- wbportfolio/models/transactions/dividends.py +31 -0
- wbportfolio/models/transactions/expiry.py +7 -0
- wbportfolio/models/transactions/fees.py +153 -0
- wbportfolio/models/transactions/trade_proposals.py +502 -0
- wbportfolio/models/transactions/trades.py +704 -0
- wbportfolio/models/transactions/transactions.py +211 -0
- wbportfolio/models/utils.py +12 -0
- wbportfolio/permissions.py +13 -0
- wbportfolio/pms/__init__.py +0 -0
- wbportfolio/pms/statistics/__init__.py +0 -0
- wbportfolio/pms/trading/__init__.py +1 -0
- wbportfolio/pms/trading/handler.py +164 -0
- wbportfolio/pms/typing.py +194 -0
- wbportfolio/preferences.py +6 -0
- wbportfolio/reports/__init__.py +0 -0
- wbportfolio/reports/monthly_position_report.py +74 -0
- wbportfolio/risk_management/__init__.py +0 -0
- wbportfolio/risk_management/backends/__init__.py +11 -0
- wbportfolio/risk_management/backends/accounts.py +166 -0
- wbportfolio/risk_management/backends/controversy_portfolio.py +63 -0
- wbportfolio/risk_management/backends/exposure_portfolio.py +203 -0
- wbportfolio/risk_management/backends/instrument_list_portfolio.py +89 -0
- wbportfolio/risk_management/backends/liquidity_risk.py +86 -0
- wbportfolio/risk_management/backends/liquidity_stress_instrument.py +86 -0
- wbportfolio/risk_management/backends/mixins.py +220 -0
- wbportfolio/risk_management/backends/product_integrity.py +111 -0
- wbportfolio/risk_management/backends/stop_loss_instrument.py +24 -0
- wbportfolio/risk_management/backends/stop_loss_portfolio.py +36 -0
- wbportfolio/risk_management/backends/ucits_portfolio.py +63 -0
- wbportfolio/risk_management/tests/__init__.py +0 -0
- wbportfolio/risk_management/tests/conftest.py +15 -0
- wbportfolio/risk_management/tests/test_accounts.py +98 -0
- wbportfolio/risk_management/tests/test_controversy_portfolio.py +33 -0
- wbportfolio/risk_management/tests/test_exposure_portfolio.py +94 -0
- wbportfolio/risk_management/tests/test_instrument_list_portfolio.py +60 -0
- wbportfolio/risk_management/tests/test_liquidity_risk.py +47 -0
- wbportfolio/risk_management/tests/test_product_integrity.py +55 -0
- wbportfolio/risk_management/tests/test_stop_loss_instrument.py +110 -0
- wbportfolio/risk_management/tests/test_stop_loss_portfolio.py +119 -0
- wbportfolio/risk_management/tests/test_ucits_portfolio.py +39 -0
- wbportfolio/serializers/__init__.py +42 -0
- wbportfolio/serializers/adjustments.py +24 -0
- wbportfolio/serializers/assets.py +166 -0
- wbportfolio/serializers/custodians.py +26 -0
- wbportfolio/serializers/portfolio_cash_flow.py +48 -0
- wbportfolio/serializers/portfolio_cash_targets.py +20 -0
- wbportfolio/serializers/portfolio_relationship.py +53 -0
- wbportfolio/serializers/portfolio_swing_pricing.py +20 -0
- wbportfolio/serializers/portfolios.py +143 -0
- wbportfolio/serializers/positions.py +76 -0
- wbportfolio/serializers/product_group.py +88 -0
- wbportfolio/serializers/products.py +331 -0
- wbportfolio/serializers/reconciliations.py +171 -0
- wbportfolio/serializers/registers.py +72 -0
- wbportfolio/serializers/roles.py +60 -0
- wbportfolio/serializers/signals.py +157 -0
- wbportfolio/serializers/synchronization.py +18 -0
- wbportfolio/serializers/transactions/__init__.py +24 -0
- wbportfolio/serializers/transactions/claim.py +310 -0
- wbportfolio/serializers/transactions/dividends.py +18 -0
- wbportfolio/serializers/transactions/expiry.py +18 -0
- wbportfolio/serializers/transactions/fees.py +32 -0
- wbportfolio/serializers/transactions/trades.py +315 -0
- wbportfolio/serializers/transactions/transactions.py +84 -0
- wbportfolio/tasks.py +125 -0
- wbportfolio/tests/__init__.py +0 -0
- wbportfolio/tests/conftest.py +164 -0
- wbportfolio/tests/models/__init__.py +0 -0
- wbportfolio/tests/models/test_account_reconciliation.py +191 -0
- wbportfolio/tests/models/test_assets.py +193 -0
- wbportfolio/tests/models/test_custodians.py +12 -0
- wbportfolio/tests/models/test_customer_trades.py +113 -0
- wbportfolio/tests/models/test_dividends.py +7 -0
- wbportfolio/tests/models/test_imports.py +192 -0
- wbportfolio/tests/models/test_instrument_mixins.py +48 -0
- wbportfolio/tests/models/test_merge.py +133 -0
- wbportfolio/tests/models/test_portfolio_cash_flow.py +112 -0
- wbportfolio/tests/models/test_portfolio_cash_targets.py +27 -0
- wbportfolio/tests/models/test_portfolio_swing_pricings.py +42 -0
- wbportfolio/tests/models/test_portfolios.py +676 -0
- wbportfolio/tests/models/test_product_groups.py +80 -0
- wbportfolio/tests/models/test_products.py +187 -0
- wbportfolio/tests/models/test_roles.py +82 -0
- wbportfolio/tests/models/test_splits.py +233 -0
- wbportfolio/tests/models/test_synchronization.py +617 -0
- wbportfolio/tests/models/transactions/__init__.py +0 -0
- wbportfolio/tests/models/transactions/test_claim.py +129 -0
- wbportfolio/tests/models/transactions/test_fees.py +65 -0
- wbportfolio/tests/models/transactions/test_trades.py +204 -0
- wbportfolio/tests/models/utils.py +13 -0
- wbportfolio/tests/serializers/__init__.py +0 -0
- wbportfolio/tests/serializers/test_claims.py +21 -0
- wbportfolio/tests/signals.py +151 -0
- wbportfolio/tests/tests.py +31 -0
- wbportfolio/tests/viewsets/__init__.py +0 -0
- wbportfolio/tests/viewsets/test_assets.py +67 -0
- wbportfolio/tests/viewsets/test_performances.py +72 -0
- wbportfolio/tests/viewsets/test_products.py +92 -0
- wbportfolio/tests/viewsets/transactions/__init__.py +0 -0
- wbportfolio/tests/viewsets/transactions/test_claims.py +146 -0
- wbportfolio/urls.py +247 -0
- wbportfolio/utils.py +30 -0
- wbportfolio/viewsets/__init__.py +57 -0
- wbportfolio/viewsets/adjustments.py +46 -0
- wbportfolio/viewsets/assets.py +562 -0
- wbportfolio/viewsets/assets_and_net_new_money_progression.py +117 -0
- wbportfolio/viewsets/charts/__init__.py +1 -0
- wbportfolio/viewsets/charts/assets.py +247 -0
- wbportfolio/viewsets/configs/__init__.py +6 -0
- wbportfolio/viewsets/configs/buttons/__init__.py +23 -0
- wbportfolio/viewsets/configs/buttons/adjustments.py +13 -0
- wbportfolio/viewsets/configs/buttons/assets.py +145 -0
- wbportfolio/viewsets/configs/buttons/claims.py +83 -0
- wbportfolio/viewsets/configs/buttons/custodians.py +76 -0
- wbportfolio/viewsets/configs/buttons/fees.py +14 -0
- wbportfolio/viewsets/configs/buttons/mixins.py +88 -0
- wbportfolio/viewsets/configs/buttons/portfolios.py +115 -0
- wbportfolio/viewsets/configs/buttons/products.py +41 -0
- wbportfolio/viewsets/configs/buttons/reconciliations.py +65 -0
- wbportfolio/viewsets/configs/buttons/registers.py +11 -0
- wbportfolio/viewsets/configs/buttons/signals.py +68 -0
- wbportfolio/viewsets/configs/buttons/trade_proposals.py +25 -0
- wbportfolio/viewsets/configs/buttons/trades.py +144 -0
- wbportfolio/viewsets/configs/display/__init__.py +61 -0
- wbportfolio/viewsets/configs/display/adjustments.py +81 -0
- wbportfolio/viewsets/configs/display/assets.py +265 -0
- wbportfolio/viewsets/configs/display/claim.py +299 -0
- wbportfolio/viewsets/configs/display/custodians.py +24 -0
- wbportfolio/viewsets/configs/display/esg.py +88 -0
- wbportfolio/viewsets/configs/display/fees.py +133 -0
- wbportfolio/viewsets/configs/display/portfolio_cash_flow.py +103 -0
- wbportfolio/viewsets/configs/display/portfolio_relationship.py +38 -0
- wbportfolio/viewsets/configs/display/portfolios.py +125 -0
- wbportfolio/viewsets/configs/display/positions.py +75 -0
- wbportfolio/viewsets/configs/display/product_groups.py +54 -0
- wbportfolio/viewsets/configs/display/product_performance.py +241 -0
- wbportfolio/viewsets/configs/display/products.py +249 -0
- wbportfolio/viewsets/configs/display/reconciliations.py +151 -0
- wbportfolio/viewsets/configs/display/registers.py +71 -0
- wbportfolio/viewsets/configs/display/roles.py +49 -0
- wbportfolio/viewsets/configs/display/trade_proposals.py +97 -0
- wbportfolio/viewsets/configs/display/trades.py +359 -0
- wbportfolio/viewsets/configs/display/transactions.py +55 -0
- wbportfolio/viewsets/configs/endpoints/__init__.py +75 -0
- wbportfolio/viewsets/configs/endpoints/adjustments.py +17 -0
- wbportfolio/viewsets/configs/endpoints/assets.py +115 -0
- wbportfolio/viewsets/configs/endpoints/claim.py +106 -0
- wbportfolio/viewsets/configs/endpoints/custodians.py +6 -0
- wbportfolio/viewsets/configs/endpoints/esg.py +14 -0
- wbportfolio/viewsets/configs/endpoints/fees.py +26 -0
- wbportfolio/viewsets/configs/endpoints/portfolio_relationship.py +23 -0
- wbportfolio/viewsets/configs/endpoints/portfolios.py +43 -0
- wbportfolio/viewsets/configs/endpoints/positions.py +18 -0
- wbportfolio/viewsets/configs/endpoints/product_groups.py +11 -0
- wbportfolio/viewsets/configs/endpoints/product_performance.py +29 -0
- wbportfolio/viewsets/configs/endpoints/products.py +37 -0
- wbportfolio/viewsets/configs/endpoints/reconciliations.py +31 -0
- wbportfolio/viewsets/configs/endpoints/roles.py +9 -0
- wbportfolio/viewsets/configs/endpoints/trade_proposals.py +17 -0
- wbportfolio/viewsets/configs/endpoints/trades.py +82 -0
- wbportfolio/viewsets/configs/endpoints/transactions.py +17 -0
- wbportfolio/viewsets/configs/menu/__init__.py +30 -0
- wbportfolio/viewsets/configs/menu/adjustments.py +8 -0
- wbportfolio/viewsets/configs/menu/assets.py +8 -0
- wbportfolio/viewsets/configs/menu/claim.py +41 -0
- wbportfolio/viewsets/configs/menu/custodians.py +11 -0
- wbportfolio/viewsets/configs/menu/fees.py +13 -0
- wbportfolio/viewsets/configs/menu/instrument_prices.py +10 -0
- wbportfolio/viewsets/configs/menu/portfolio_cash_flow.py +8 -0
- wbportfolio/viewsets/configs/menu/portfolios.py +15 -0
- wbportfolio/viewsets/configs/menu/positions.py +14 -0
- wbportfolio/viewsets/configs/menu/product_groups.py +10 -0
- wbportfolio/viewsets/configs/menu/product_performance.py +25 -0
- wbportfolio/viewsets/configs/menu/products.py +15 -0
- wbportfolio/viewsets/configs/menu/reconciliations.py +7 -0
- wbportfolio/viewsets/configs/menu/registers.py +10 -0
- wbportfolio/viewsets/configs/menu/roles.py +16 -0
- wbportfolio/viewsets/configs/menu/trades.py +18 -0
- wbportfolio/viewsets/configs/menu/transactions.py +8 -0
- wbportfolio/viewsets/configs/previews/__init__.py +1 -0
- wbportfolio/viewsets/configs/previews/portfolios.py +21 -0
- wbportfolio/viewsets/configs/titles/__init__.py +65 -0
- wbportfolio/viewsets/configs/titles/adjustments.py +19 -0
- wbportfolio/viewsets/configs/titles/assets.py +57 -0
- wbportfolio/viewsets/configs/titles/assets_and_net_new_money_progression.py +6 -0
- wbportfolio/viewsets/configs/titles/claim.py +81 -0
- wbportfolio/viewsets/configs/titles/custodians.py +12 -0
- wbportfolio/viewsets/configs/titles/esg.py +10 -0
- wbportfolio/viewsets/configs/titles/fees.py +25 -0
- wbportfolio/viewsets/configs/titles/instrument_prices.py +20 -0
- wbportfolio/viewsets/configs/titles/portfolios.py +32 -0
- wbportfolio/viewsets/configs/titles/positions.py +11 -0
- wbportfolio/viewsets/configs/titles/product_groups.py +12 -0
- wbportfolio/viewsets/configs/titles/product_performance.py +16 -0
- wbportfolio/viewsets/configs/titles/products.py +6 -0
- wbportfolio/viewsets/configs/titles/registers.py +12 -0
- wbportfolio/viewsets/configs/titles/roles.py +23 -0
- wbportfolio/viewsets/configs/titles/trades.py +51 -0
- wbportfolio/viewsets/configs/titles/transactions.py +8 -0
- wbportfolio/viewsets/custodians.py +66 -0
- wbportfolio/viewsets/esg.py +165 -0
- wbportfolio/viewsets/mixins.py +48 -0
- wbportfolio/viewsets/portfolio_cash_flow.py +31 -0
- wbportfolio/viewsets/portfolio_cash_targets.py +8 -0
- wbportfolio/viewsets/portfolio_relationship.py +46 -0
- wbportfolio/viewsets/portfolio_swing_pricing.py +8 -0
- wbportfolio/viewsets/portfolios.py +154 -0
- wbportfolio/viewsets/positions.py +292 -0
- wbportfolio/viewsets/product_groups.py +84 -0
- wbportfolio/viewsets/product_performance.py +646 -0
- wbportfolio/viewsets/products.py +529 -0
- wbportfolio/viewsets/reconciliations.py +160 -0
- wbportfolio/viewsets/registers.py +75 -0
- wbportfolio/viewsets/roles.py +44 -0
- wbportfolio/viewsets/signals.py +42 -0
- wbportfolio/viewsets/synchronization.py +25 -0
- wbportfolio/viewsets/transactions/__init__.py +40 -0
- wbportfolio/viewsets/transactions/claim.py +933 -0
- wbportfolio/viewsets/transactions/fees.py +190 -0
- wbportfolio/viewsets/transactions/mixins.py +19 -0
- wbportfolio/viewsets/transactions/trade_proposals.py +93 -0
- wbportfolio/viewsets/transactions/trades.py +395 -0
- wbportfolio/viewsets/transactions/transactions.py +123 -0
- wbportfolio-2.2.1.dist-info/METADATA +21 -0
- wbportfolio-2.2.1.dist-info/RECORD +486 -0
- wbportfolio-2.2.1.dist-info/WHEEL +5 -0
- wbportfolio-2.2.1.dist-info/licenses/LICENSE +4 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from faker import Faker
|
|
3
|
+
from pandas.tseries.offsets import BDay
|
|
4
|
+
from rest_framework.test import APIRequestFactory
|
|
5
|
+
from wbportfolio.viewsets.positions import AggregatedAssetPositionLiquidityPandasView
|
|
6
|
+
|
|
7
|
+
fake = Faker()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.mark.django_db
|
|
11
|
+
class TestPandasViewSet:
|
|
12
|
+
def test_get_dataframe(self, instrument_price_factory, asset_position_factory, equity, portfolio, weekday):
|
|
13
|
+
request = APIRequestFactory().get("")
|
|
14
|
+
request.query_params = dict()
|
|
15
|
+
# Make instances of AP, instrument prices.
|
|
16
|
+
i1 = instrument_price_factory.create(
|
|
17
|
+
instrument=equity,
|
|
18
|
+
date=weekday,
|
|
19
|
+
volume_50d=1000,
|
|
20
|
+
net_value=10,
|
|
21
|
+
instrument__currency__key="USD",
|
|
22
|
+
)
|
|
23
|
+
i2 = instrument_price_factory.create(
|
|
24
|
+
instrument=equity,
|
|
25
|
+
date=(i1.date - BDay(1)).date(),
|
|
26
|
+
volume_50d=1100,
|
|
27
|
+
net_value=11,
|
|
28
|
+
instrument__currency__key="USD",
|
|
29
|
+
)
|
|
30
|
+
a1 = asset_position_factory.create(
|
|
31
|
+
portfolio=portfolio,
|
|
32
|
+
portfolio__currency__key="USD",
|
|
33
|
+
underlying_instrument=i1.instrument,
|
|
34
|
+
date=i1.date,
|
|
35
|
+
initial_shares=1000,
|
|
36
|
+
)
|
|
37
|
+
a2 = asset_position_factory.create(
|
|
38
|
+
portfolio=portfolio,
|
|
39
|
+
portfolio__currency__key="USD",
|
|
40
|
+
underlying_instrument=i1.instrument,
|
|
41
|
+
date=i2.date,
|
|
42
|
+
initial_shares=1000,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Make an empty df
|
|
46
|
+
request.GET = request.GET.copy()
|
|
47
|
+
request.GET.update(
|
|
48
|
+
{
|
|
49
|
+
"historic_date": (i1.date - BDay(2)).date().strftime("%Y-%m-%d"),
|
|
50
|
+
"compared_date": (i1.date - BDay(3)).date().strftime("%Y-%m-%d"),
|
|
51
|
+
"bigger_than_x": 1,
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
df_empty = AggregatedAssetPositionLiquidityPandasView(request=request)._get_dataframe()
|
|
55
|
+
|
|
56
|
+
# Run the function with existing second_date in asset_position
|
|
57
|
+
request.GET["compared_date"] = i2.date.strftime("%Y-%m-%d")
|
|
58
|
+
|
|
59
|
+
# Run with 2 existing dates.
|
|
60
|
+
request.GET["historic_date"] = i1.date.strftime("%Y-%m-%d")
|
|
61
|
+
df = AggregatedAssetPositionLiquidityPandasView(request=request)._get_dataframe()
|
|
62
|
+
# Coverage:
|
|
63
|
+
assert df_empty.empty # df is empty
|
|
64
|
+
# Unit tests:
|
|
65
|
+
s_i1 = df.set_index("id").loc[i1.instrument.id]
|
|
66
|
+
assert s_i1.at["liquidity_first_date"] == round(a1.initial_shares / (i1.volume_50d * 0.33), 2)
|
|
67
|
+
assert s_i1.at["liquidity_second_date"] == round(a2.initial_shares / (i2.volume_50d * 0.33), 2)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from django.test.client import RequestFactory
|
|
5
|
+
from faker import Faker
|
|
6
|
+
from pandas.tseries.offsets import BDay, BMonthEnd, BYearEnd
|
|
7
|
+
from rest_framework.reverse import reverse
|
|
8
|
+
from rest_framework.test import force_authenticate
|
|
9
|
+
from wbportfolio.factories import InstrumentPriceFactory, ProductFactory
|
|
10
|
+
from wbportfolio.viewsets.product_performance import PerformanceComparisonPandasView
|
|
11
|
+
|
|
12
|
+
fake = Faker()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.mark.django_db
|
|
16
|
+
class TestPerformanceComparisonPandasView:
|
|
17
|
+
@classmethod
|
|
18
|
+
def populated_product_and_get_prices(cls):
|
|
19
|
+
product = ProductFactory.create()
|
|
20
|
+
last_date = (fake.date_object() - BDay(0)).date()
|
|
21
|
+
date_t1 = (last_date - BDay(1)).date() # t-1 date
|
|
22
|
+
date_m1 = (last_date - BMonthEnd(1)).date() # last month latest date
|
|
23
|
+
date_y1 = (last_date - BYearEnd(1)).date() # last year latest date
|
|
24
|
+
date_inception = (last_date - BYearEnd(2)).date() # some random date to represent inception
|
|
25
|
+
|
|
26
|
+
last_price = InstrumentPriceFactory.create(instrument=product, date=last_date, calculated=False)
|
|
27
|
+
t1 = InstrumentPriceFactory.create(instrument=product, date=date_t1, calculated=False)
|
|
28
|
+
InstrumentPriceFactory.create(instrument=product, date=date_t1, calculated=True) # Create noise
|
|
29
|
+
|
|
30
|
+
m1 = InstrumentPriceFactory.create(instrument=product, date=date_m1, calculated=False)
|
|
31
|
+
InstrumentPriceFactory.create(instrument=product, date=date_m1, calculated=True) # Create noise
|
|
32
|
+
InstrumentPriceFactory.create(
|
|
33
|
+
instrument=product, date=(fake.date_between(date_m1, date_t1) - BDay(0)).date(), calculated=False
|
|
34
|
+
) # Create noise
|
|
35
|
+
|
|
36
|
+
y1 = InstrumentPriceFactory.create(instrument=product, date=date_y1, calculated=False)
|
|
37
|
+
InstrumentPriceFactory.create(instrument=product, date=date_y1, calculated=True) # Create noise
|
|
38
|
+
InstrumentPriceFactory.create(
|
|
39
|
+
instrument=product, date=(fake.date_between(date_y1, date_m1) - BDay(0)).date(), calculated=False
|
|
40
|
+
) # Create noise
|
|
41
|
+
|
|
42
|
+
inception = InstrumentPriceFactory.create(instrument=product, date=date_inception, calculated=False)
|
|
43
|
+
InstrumentPriceFactory.create(instrument=product, date=date_inception, calculated=True) # Create noise
|
|
44
|
+
InstrumentPriceFactory.create(
|
|
45
|
+
instrument=product, date=(fake.date_between(date_inception, date_y1) - BDay(0)).date(), calculated=False
|
|
46
|
+
) # Create noise
|
|
47
|
+
|
|
48
|
+
product.last_valuation_date = last_date
|
|
49
|
+
product.inception_date = date_inception
|
|
50
|
+
product.save()
|
|
51
|
+
last_price.refresh_from_db()
|
|
52
|
+
m1.refresh_from_db()
|
|
53
|
+
|
|
54
|
+
return last_price.net_value, t1.net_value, m1.net_value, y1.net_value, inception.net_value
|
|
55
|
+
|
|
56
|
+
def test_simple_performance(self, superuser):
|
|
57
|
+
"""
|
|
58
|
+
Basic test to check that the given performance are correct
|
|
59
|
+
"""
|
|
60
|
+
last_price, t1, m1, y1, inception = self.populated_product_and_get_prices()
|
|
61
|
+
|
|
62
|
+
url = reverse("wbportfolio:productperformancecomparison-list")
|
|
63
|
+
request = RequestFactory().get(url)
|
|
64
|
+
force_authenticate(request, user=superuser)
|
|
65
|
+
view = PerformanceComparisonPandasView.as_view({"get": "list"})
|
|
66
|
+
response = view(request)
|
|
67
|
+
res = response.data["results"][0]
|
|
68
|
+
assert pytest.approx(Decimal(res["instrument_last_valuation_price"]), rel=Decimal(1e-4)) == last_price
|
|
69
|
+
assert pytest.approx(Decimal(res["perf_last_day"]), rel=Decimal(1e-4)) == last_price / t1 - Decimal(1)
|
|
70
|
+
assert pytest.approx(Decimal(res["perf_month_to_date"]), rel=Decimal(1e-4)) == last_price / m1 - Decimal(1)
|
|
71
|
+
assert pytest.approx(Decimal(res["perf_year_to_date"]), rel=Decimal(1e-4)) == last_price / y1 - Decimal(1)
|
|
72
|
+
assert pytest.approx(Decimal(res["perf_inception"]), rel=Decimal(1e-4)) == last_price / inception - Decimal(1)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from datetime import date
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from django.contrib.auth.models import Permission
|
|
5
|
+
from django.db import models
|
|
6
|
+
from django.test.client import RequestFactory
|
|
7
|
+
from faker import Faker
|
|
8
|
+
from psycopg.types.range import DateRange
|
|
9
|
+
from rest_framework.reverse import reverse
|
|
10
|
+
from rest_framework.test import force_authenticate
|
|
11
|
+
from wbfdm.models import InstrumentPrice
|
|
12
|
+
from wbportfolio.models import InstrumentPortfolioThroughModel, Product
|
|
13
|
+
from wbportfolio.viewsets import ProductModelViewSet
|
|
14
|
+
|
|
15
|
+
fake = Faker()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.mark.django_db
|
|
19
|
+
class TestProductModelViewSet:
|
|
20
|
+
def create_queryset(self, portfolio_factory, product_factory, instrument_price_factory, customer_trade_factory):
|
|
21
|
+
for portfolio, product in zip(
|
|
22
|
+
portfolio_factory.create_batch(4, invested_timespan=DateRange(date.min, date.max))
|
|
23
|
+
+ portfolio_factory.create_batch(2, invested_timespan=DateRange(date.min, date.max)),
|
|
24
|
+
product_factory.create_batch(6),
|
|
25
|
+
):
|
|
26
|
+
InstrumentPortfolioThroughModel.objects.update_or_create(
|
|
27
|
+
instrument=product, defaults={"portfolio": portfolio}
|
|
28
|
+
)
|
|
29
|
+
prices = instrument_price_factory.create_batch(10, instrument=product, calculated=False)
|
|
30
|
+
for price in prices:
|
|
31
|
+
trade = customer_trade_factory.create(
|
|
32
|
+
transaction_date=price.date, underlying_instrument=product, portfolio=product.primary_portfolio
|
|
33
|
+
)
|
|
34
|
+
price.outstanding_shares = trade.shares
|
|
35
|
+
price.save()
|
|
36
|
+
|
|
37
|
+
def test_list(self, superuser):
|
|
38
|
+
url = reverse("wbportfolio:product-list")
|
|
39
|
+
request = RequestFactory().get(url)
|
|
40
|
+
force_authenticate(request, user=superuser)
|
|
41
|
+
view = ProductModelViewSet.as_view({"get": "list"})
|
|
42
|
+
response = view(request)
|
|
43
|
+
assert response.status_code == 200
|
|
44
|
+
|
|
45
|
+
def test_get_aggregates(
|
|
46
|
+
self, superuser, portfolio_factory, product_factory, instrument_price_factory, customer_trade_factory
|
|
47
|
+
):
|
|
48
|
+
url = reverse("wbportfolio:product-list")
|
|
49
|
+
self.create_queryset(portfolio_factory, product_factory, instrument_price_factory, customer_trade_factory)
|
|
50
|
+
|
|
51
|
+
request = RequestFactory().get(f'{url}?price_date={InstrumentPrice.objects.latest("date").date}')
|
|
52
|
+
request.user = superuser
|
|
53
|
+
force_authenticate(request, user=superuser)
|
|
54
|
+
|
|
55
|
+
view = ProductModelViewSet(request=request)
|
|
56
|
+
view.request = request
|
|
57
|
+
queryset = view.get_queryset()
|
|
58
|
+
agg = view.get_aggregates(queryset, queryset)
|
|
59
|
+
aum = float(
|
|
60
|
+
queryset.filter(is_invested=True).aggregate(s=models.Sum("assets_under_management_usd"))["s"] or 0.0
|
|
61
|
+
)
|
|
62
|
+
assert float(list(agg["assets_under_management_usd"].values())[0]) == pytest.approx(aum, rel=1e-4)
|
|
63
|
+
|
|
64
|
+
def test_queryset_superuser(self, superuser, product_factory):
|
|
65
|
+
url = reverse("wbportfolio:product-list")
|
|
66
|
+
request = RequestFactory().get(url)
|
|
67
|
+
force_authenticate(request, user=superuser)
|
|
68
|
+
view = ProductModelViewSet.as_view({"get": "list"})
|
|
69
|
+
product_factory.create_batch(5)
|
|
70
|
+
response = view(request)
|
|
71
|
+
assert response.status_code == 200
|
|
72
|
+
ids = [r["id"] for r in response.data["results"]]
|
|
73
|
+
assert set(ids) == set(list(Product.objects.values_list("id", flat=True)))
|
|
74
|
+
|
|
75
|
+
def test_queryset_normaluser(self, user, product_factory, person_factory):
|
|
76
|
+
url = reverse("wbportfolio:product-list")
|
|
77
|
+
request = RequestFactory().get(url)
|
|
78
|
+
permission = Permission.objects.get(codename="view_product", content_type__app_label="wbportfolio")
|
|
79
|
+
user.user_permissions.add(permission)
|
|
80
|
+
force_authenticate(request, user=user)
|
|
81
|
+
view = ProductModelViewSet.as_view({"get": "list"})
|
|
82
|
+
public_product = product_factory.create()
|
|
83
|
+
white_label_product = product_factory.create()
|
|
84
|
+
white_label_product.white_label_customers.add(user.profile)
|
|
85
|
+
|
|
86
|
+
other_client_product = product_factory.create()
|
|
87
|
+
other_client_product.white_label_customers.add(person_factory.create())
|
|
88
|
+
|
|
89
|
+
response = view(request)
|
|
90
|
+
assert response.status_code == 200
|
|
91
|
+
ids = [r["id"] for r in response.data["results"]]
|
|
92
|
+
assert set(ids) == set([public_product.id, white_label_product.id])
|
|
File without changes
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from faker import Faker
|
|
3
|
+
from rest_framework.reverse import reverse
|
|
4
|
+
from rest_framework.test import APIClient, APIRequestFactory
|
|
5
|
+
from wbcore.contrib.authentication.factories.users import UserFactory
|
|
6
|
+
from wbcore.contrib.directory.factories import EntryFactory
|
|
7
|
+
from wbcore.contrib.directory.models import Entry
|
|
8
|
+
from wbcore.utils.strings import format_number
|
|
9
|
+
from wbcrm.factories.accounts import AccountFactory, AccountRoleFactory
|
|
10
|
+
from wbcrm.models import Account
|
|
11
|
+
from wbportfolio.factories.claim import ClaimFactory
|
|
12
|
+
from wbportfolio.models.transactions.claim import Claim
|
|
13
|
+
from wbportfolio.viewsets.transactions.claim import (
|
|
14
|
+
ClaimAccountModelViewSet,
|
|
15
|
+
ClaimAPIModelViewSet,
|
|
16
|
+
ClaimEntryModelViewSet,
|
|
17
|
+
ClaimModelViewSet,
|
|
18
|
+
ClaimProductModelViewSet,
|
|
19
|
+
ClaimRepresentationViewSet,
|
|
20
|
+
ClaimTradeModelViewSet,
|
|
21
|
+
ConsolidatedTradeSummaryDistributionChart,
|
|
22
|
+
ConsolidatedTradeSummaryTableView,
|
|
23
|
+
CumulativeNNMChartView,
|
|
24
|
+
NegativeTermimalAccountPerProductModelViewSet,
|
|
25
|
+
ProfitAndLossPandasView,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
fake = Faker()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.django_db
|
|
32
|
+
class TestClaimModelViewSet:
|
|
33
|
+
def test_aggregate(self, claim):
|
|
34
|
+
view = ClaimModelViewSet()
|
|
35
|
+
queryset = Claim.objects.all()
|
|
36
|
+
agg = view.get_aggregates(queryset, paginated_queryset=queryset)
|
|
37
|
+
assert agg["shares"]["Σ"] == format_number(claim.shares, decimal=4)
|
|
38
|
+
|
|
39
|
+
@pytest.fixture
|
|
40
|
+
def account_user(self):
|
|
41
|
+
# True, we create a superuser
|
|
42
|
+
|
|
43
|
+
# if fake.pybool():
|
|
44
|
+
# user = UserFactory.create(is_superuser=True)
|
|
45
|
+
# else:
|
|
46
|
+
user = UserFactory.create(is_superuser=False)
|
|
47
|
+
entry = Entry.objects.get(id=user.profile.id)
|
|
48
|
+
|
|
49
|
+
# Create a bunch of account and roles
|
|
50
|
+
public_account = AccountFactory.create(is_public=True, owner=EntryFactory.create())
|
|
51
|
+
child_public_account = AccountFactory.create(parent=public_account, owner=EntryFactory.create())
|
|
52
|
+
ClaimFactory.create(account=public_account)
|
|
53
|
+
ClaimFactory.create(account=child_public_account)
|
|
54
|
+
AccountRoleFactory.create(account=public_account, entry=entry)
|
|
55
|
+
AccountRoleFactory.create(account=public_account)
|
|
56
|
+
private_account = AccountFactory.create(is_public=False, owner=EntryFactory.create())
|
|
57
|
+
child_private_account = AccountFactory.create(parent=private_account, owner=EntryFactory.create())
|
|
58
|
+
ClaimFactory.create(account=private_account)
|
|
59
|
+
ClaimFactory.create(account=child_private_account)
|
|
60
|
+
return user
|
|
61
|
+
|
|
62
|
+
@pytest.mark.parametrize(
|
|
63
|
+
"viewset_class",
|
|
64
|
+
[
|
|
65
|
+
ClaimAPIModelViewSet,
|
|
66
|
+
ClaimRepresentationViewSet,
|
|
67
|
+
ClaimModelViewSet,
|
|
68
|
+
ClaimAccountModelViewSet,
|
|
69
|
+
ClaimProductModelViewSet,
|
|
70
|
+
ClaimEntryModelViewSet,
|
|
71
|
+
ClaimTradeModelViewSet,
|
|
72
|
+
ConsolidatedTradeSummaryTableView,
|
|
73
|
+
ConsolidatedTradeSummaryDistributionChart,
|
|
74
|
+
CumulativeNNMChartView,
|
|
75
|
+
ProfitAndLossPandasView,
|
|
76
|
+
],
|
|
77
|
+
)
|
|
78
|
+
def test_ensure_permission_on_account(self, account_user, viewset_class):
|
|
79
|
+
"""
|
|
80
|
+
We ensure that all claims viewset doesn't show more that what the user is allowed to see.
|
|
81
|
+
For claim, the allowed claim are all the claims where the account is among the account they is allowed to see
|
|
82
|
+
"""
|
|
83
|
+
allowed_accounts = Account.objects.filter_for_user(account_user)
|
|
84
|
+
allowed_claims = Claim.objects.filter(account__in=allowed_accounts)
|
|
85
|
+
|
|
86
|
+
request = APIRequestFactory().get("")
|
|
87
|
+
request.user = account_user
|
|
88
|
+
viewset = viewset_class(
|
|
89
|
+
request=request,
|
|
90
|
+
kwargs={
|
|
91
|
+
"entry_id": allowed_accounts.first().owner.id,
|
|
92
|
+
"account_id": allowed_accounts.filter(parent__isnull=False).first().id,
|
|
93
|
+
"product_id": allowed_claims.first().product.id,
|
|
94
|
+
"trade_id": allowed_claims.first().trade.id,
|
|
95
|
+
},
|
|
96
|
+
)
|
|
97
|
+
assert allowed_claims.exists()
|
|
98
|
+
assert allowed_claims.count() < Claim.objects.count() # Ensure that the filtering works
|
|
99
|
+
for claim in viewset.get_queryset():
|
|
100
|
+
assert claim in allowed_claims
|
|
101
|
+
|
|
102
|
+
def test_ensure_permission_on_terminal_account_negative_sum_view(
|
|
103
|
+
self, user, negative_claim_factory, account_with_owner_factory
|
|
104
|
+
):
|
|
105
|
+
entry = Entry.objects.get(id=user.profile.id)
|
|
106
|
+
|
|
107
|
+
request = APIRequestFactory().get("")
|
|
108
|
+
request.user = user
|
|
109
|
+
viewset = NegativeTermimalAccountPerProductModelViewSet(request=request)
|
|
110
|
+
# Create a bunch of account and roles
|
|
111
|
+
public_account = account_with_owner_factory.create(is_public=True)
|
|
112
|
+
AccountRoleFactory.create(account=public_account, entry=entry)
|
|
113
|
+
|
|
114
|
+
# create two negative claim, one only for an account the user can see
|
|
115
|
+
private_account = account_with_owner_factory.create(is_public=False)
|
|
116
|
+
public_claim = negative_claim_factory.create(account=public_account) # noqa
|
|
117
|
+
private_claim = negative_claim_factory.create(account=private_account) # noqa
|
|
118
|
+
|
|
119
|
+
assert set(viewset.get_queryset().values_list("account_id", flat=True)) == {public_account.id}
|
|
120
|
+
|
|
121
|
+
def test_claim_validate_product_valuations_exist(
|
|
122
|
+
self, claim_factory, super_user, weekday, instrument_price_factory
|
|
123
|
+
):
|
|
124
|
+
claim = claim_factory.create(create_product_val=False, date=weekday)
|
|
125
|
+
client = APIClient()
|
|
126
|
+
url = reverse("wbportfolio:claim-submit", args=[claim.id])
|
|
127
|
+
client.force_authenticate(user=super_user)
|
|
128
|
+
response = client.patch(url)
|
|
129
|
+
assert response.status_code == 412
|
|
130
|
+
# check that the response contains "date", which means the error was detected on the "date" field
|
|
131
|
+
assert response.json()["date"]
|
|
132
|
+
|
|
133
|
+
# test that estimated price don't count
|
|
134
|
+
instrument_price_factory.create(instrument=claim.product, date=weekday, calculated=True)
|
|
135
|
+
response = client.patch(url)
|
|
136
|
+
assert response.status_code == 412
|
|
137
|
+
|
|
138
|
+
# With a valid price we can now submit
|
|
139
|
+
instrument_price_factory.create(instrument=claim.product, date=weekday, calculated=False)
|
|
140
|
+
response = client.patch(url)
|
|
141
|
+
assert response.status_code == 200
|
|
142
|
+
|
|
143
|
+
url = reverse("wbportfolio:claim-approve", args=[claim.id])
|
|
144
|
+
client.force_authenticate(user=super_user)
|
|
145
|
+
response = client.patch(url)
|
|
146
|
+
assert response.status_code == 200
|
wbportfolio/urls.py
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
from django.urls import include, path
|
|
2
|
+
from wbcore.routers import WBCoreRouter
|
|
3
|
+
from wbportfolio import viewsets
|
|
4
|
+
|
|
5
|
+
router = WBCoreRouter()
|
|
6
|
+
router.register(r"assetposition", viewsets.AssetPositionModelViewSet, basename="assetposition")
|
|
7
|
+
router.register(r"adjustment", viewsets.AdjustmentModelViewSet, basename="adjustment")
|
|
8
|
+
router.register(r"product", viewsets.ProductModelViewSet, basename="product")
|
|
9
|
+
router.register(r"product_group", viewsets.ProductGroupModelViewSet, basename="product_group")
|
|
10
|
+
router.register(r"productcustomer", viewsets.ProductCustomerModelViewSet, basename="productcustomer")
|
|
11
|
+
router.register(r"productrepresentation", viewsets.ProductRepresentationViewSet, basename="productrepresentation")
|
|
12
|
+
router.register(
|
|
13
|
+
r"product_grouprepresentation", viewsets.ProductGroupRepresentationViewSet, basename="product_grouprepresentation"
|
|
14
|
+
)
|
|
15
|
+
router.register(
|
|
16
|
+
r"custodianrepresentation", viewsets.CustodianRepresentationViewSet, basename="custodianrepresentation"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
router.register(r"portfolio", viewsets.PortfolioModelViewSet, basename="portfolio")
|
|
21
|
+
router.register(r"portfoliocashflow", viewsets.DailyPortfolioCashFlowModelViewSet, basename="portfoliocashflow")
|
|
22
|
+
router.register(r"portfolioswingpricing", viewsets.PortfolioSwingPricingModelViewSet, basename="portfolioswingpricing")
|
|
23
|
+
router.register(r"portfoliocashtarget", viewsets.PortfolioCashTargetModelViewSet, basename="portfoliocashtarget")
|
|
24
|
+
router.register(r"modelportfolio", viewsets.ModelPortfolioModelViewSet, basename="modelportfolio")
|
|
25
|
+
|
|
26
|
+
router.register(
|
|
27
|
+
r"portfoliorepresentation", viewsets.PortfolioRepresentationViewSet, basename="portfoliorepresentation"
|
|
28
|
+
)
|
|
29
|
+
router.register(
|
|
30
|
+
r"portfoliosynchronizationrepresentation",
|
|
31
|
+
viewsets.PortfolioSynchronizationRepresentationViewSet,
|
|
32
|
+
basename="portfoliosynchronizationrepresentation",
|
|
33
|
+
)
|
|
34
|
+
router.register(
|
|
35
|
+
r"pricecomputationrepresentation",
|
|
36
|
+
viewsets.PriceComputationRepresentationViewSet,
|
|
37
|
+
basename="pricecomputationrepresentation",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
router.register(r"portfoliorole", viewsets.PortfolioRoleModelViewSet, basename="portfoliorole")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
router.register(r"transaction", viewsets.TransactionModelViewSet, basename="transaction")
|
|
45
|
+
router.register(r"fees", viewsets.FeesModelViewSet, basename="fees")
|
|
46
|
+
router.register(r"trade", viewsets.TradeModelViewSet, basename="trade")
|
|
47
|
+
router.register(
|
|
48
|
+
r"subscriptionredemption", viewsets.SubscriptionRedemptionModelViewSet, basename="subscriptionredemption"
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
router.register(r"traderepresentation", viewsets.TradeRepresentationViewSet, basename="traderepresentation")
|
|
52
|
+
router.register(
|
|
53
|
+
r"tradeproposalrepresentation", viewsets.TradeProposalRepresentationViewSet, basename="tradeproposalrepresentation"
|
|
54
|
+
)
|
|
55
|
+
router.register(
|
|
56
|
+
r"feesproductperformance", viewsets.ProductPerformanceFeesModelViewSet, basename="feesproductperformance"
|
|
57
|
+
)
|
|
58
|
+
router.register(r"aumchart", viewsets.InstrumentPriceAUMDataChartView, basename="aumchart")
|
|
59
|
+
|
|
60
|
+
router.register(r"custodian", viewsets.CustodianModelViewSet, basename="custodian")
|
|
61
|
+
|
|
62
|
+
router.register(r"tradeproposal", viewsets.TradeProposalModelViewSet, basename="tradeproposal")
|
|
63
|
+
|
|
64
|
+
router.register(
|
|
65
|
+
r"assetandnetnewmoneyprogression",
|
|
66
|
+
viewsets.AssetAndNetNewMoneyProgressionChartViewSet,
|
|
67
|
+
basename="assetandnetnewmoneyprogression",
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Subrouter for Portfolio
|
|
72
|
+
portfolio_router = WBCoreRouter()
|
|
73
|
+
portfolio_router.register(
|
|
74
|
+
r"portfoliocashflow", viewsets.DailyPortfolioCashFlowModelViewSet, basename="portfolio-portfoliocashflow"
|
|
75
|
+
)
|
|
76
|
+
portfolio_router.register(r"asset", viewsets.AssetPositionPortfolioModelViewSet, basename="portfolio-asset")
|
|
77
|
+
portfolio_router.register(r"contributor", viewsets.ContributorPortfolioChartView, basename="portfolio-contributor")
|
|
78
|
+
portfolio_router.register(r"fees", viewsets.FeesPortfolioModelViewSet, basename="portfolio-fees")
|
|
79
|
+
portfolio_router.register(r"transaction", viewsets.TransactionPortfolioModelViewSet, basename="portfolio-transaction")
|
|
80
|
+
portfolio_router.register(r"trade", viewsets.TradePortfolioModelViewSet, basename="portfolio-trade")
|
|
81
|
+
portfolio_router.register(
|
|
82
|
+
r"instrument", viewsets.InstrumentPortfolioThroughPortfolioModelViewSet, basename="portfolio-instrument"
|
|
83
|
+
)
|
|
84
|
+
portfolio_router.register(
|
|
85
|
+
r"preferredclassification",
|
|
86
|
+
viewsets.InstrumentPreferedClassificationThroughProductModelViewSet,
|
|
87
|
+
basename="portfolio-preferredclassification",
|
|
88
|
+
)
|
|
89
|
+
portfolio_router.register(
|
|
90
|
+
r"tradeproposal", viewsets.TradeProposalPortfolioModelViewSet, basename="portfolio-tradeproposal"
|
|
91
|
+
)
|
|
92
|
+
portfolio_router.register(
|
|
93
|
+
r"dependencyportfolio", viewsets.PortfolioPortfolioThroughModelViewSet, basename="portfolio-dependencyportfolio"
|
|
94
|
+
)
|
|
95
|
+
portfolio_router.register(
|
|
96
|
+
r"modelcompositionpandas",
|
|
97
|
+
viewsets.CompositionModelPortfolioPandasView,
|
|
98
|
+
basename="portfolio-modelcompositionpandas",
|
|
99
|
+
)
|
|
100
|
+
portfolio_router.register(
|
|
101
|
+
r"feesaggregated", viewsets.FeesAggregatedPortfolioPandasView, basename="portfolio-feesaggregated"
|
|
102
|
+
)
|
|
103
|
+
portfolio_router.register(
|
|
104
|
+
r"distributionchart",
|
|
105
|
+
viewsets.DistributionChartViewSet,
|
|
106
|
+
basename="portfolio-distributionchart",
|
|
107
|
+
)
|
|
108
|
+
portfolio_router.register(
|
|
109
|
+
r"distributiontable",
|
|
110
|
+
viewsets.DistributionTableViewSet,
|
|
111
|
+
basename="portfolio-distributiontable",
|
|
112
|
+
)
|
|
113
|
+
portfolio_router.register(
|
|
114
|
+
r"esgaggregation",
|
|
115
|
+
viewsets.ESGMetricAggregationPortfolioPandasViewSet,
|
|
116
|
+
basename="portfolio-esgaggregation",
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
router.register(r"register", viewsets.RegisterModelViewSet, basename="register")
|
|
120
|
+
router.register(r"registerrepresentation", viewsets.RegisterRepresentationViewSet, basename="registerrepresentation")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
# Subrouter for Products
|
|
124
|
+
product_router = WBCoreRouter()
|
|
125
|
+
product_router.register(r"nominalchart", viewsets.NominalProductChartView, basename="product-nominalchart")
|
|
126
|
+
product_router.register(r"aumchart", viewsets.AUMProductChartView, basename="product-aumchart")
|
|
127
|
+
product_router.register(r"claim", viewsets.ClaimProductModelViewSet, basename="product-claim")
|
|
128
|
+
|
|
129
|
+
# Subrouter for Trade Proposal
|
|
130
|
+
trade_proposal_router = WBCoreRouter()
|
|
131
|
+
trade_proposal_router.register(r"trade", viewsets.TradeTradeProposalModelViewSet, basename="tradeproposal-trade")
|
|
132
|
+
|
|
133
|
+
trade_router = WBCoreRouter()
|
|
134
|
+
trade_router.register(r"claim", viewsets.ClaimTradeModelViewSet, basename="trade-claim")
|
|
135
|
+
|
|
136
|
+
instrument_router = WBCoreRouter()
|
|
137
|
+
|
|
138
|
+
instrument_router.register(r"trade", viewsets.TradeInstrumentModelViewSet, basename="instrument-trade")
|
|
139
|
+
instrument_router.register(
|
|
140
|
+
r"subscriptionredemption",
|
|
141
|
+
viewsets.SubscriptionRedemptionInstrumentModelViewSet,
|
|
142
|
+
basename="instrument-subscriptionredemption",
|
|
143
|
+
)
|
|
144
|
+
instrument_router.register(
|
|
145
|
+
r"custodiandistribution",
|
|
146
|
+
viewsets.CustodianDistributionInstrumentChartViewSet,
|
|
147
|
+
basename="instrument-custodiandistribution",
|
|
148
|
+
)
|
|
149
|
+
instrument_router.register(
|
|
150
|
+
r"customerdistribution",
|
|
151
|
+
viewsets.CustomerDistributionInstrumentChartViewSet,
|
|
152
|
+
basename="instrument-customerdistribution",
|
|
153
|
+
)
|
|
154
|
+
instrument_router.register(r"asset", viewsets.AssetPositionInstrumentModelViewSet, basename="instrument-asset")
|
|
155
|
+
|
|
156
|
+
instrument_router.register(
|
|
157
|
+
r"portfoliorole", viewsets.PortfolioRoleInstrumentModelViewSet, basename="instrument-portfoliorole"
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
instrument_router.register(r"adjustment", viewsets.AdjustmentEquityModelViewSet, basename="instrument-adjustment")
|
|
161
|
+
instrument_router.register(
|
|
162
|
+
r"assetpositionchart",
|
|
163
|
+
viewsets.AssetPositionUnderlyingInstrumentChartViewSet,
|
|
164
|
+
basename="instrument-assetpositionchart",
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# app_name = 'wbportfolio'
|
|
168
|
+
|
|
169
|
+
router.register(r"productperformance", viewsets.PerformancePandasView, basename="productperformance")
|
|
170
|
+
router.register(
|
|
171
|
+
r"productperformancennmlist",
|
|
172
|
+
viewsets.ProductPerformanceNetNewMoneyListViewSet,
|
|
173
|
+
basename="productperformancennmlist",
|
|
174
|
+
)
|
|
175
|
+
router.register(
|
|
176
|
+
r"productperformancecomparison", viewsets.PerformanceComparisonPandasView, basename="productperformancecomparison"
|
|
177
|
+
)
|
|
178
|
+
router.register(r"productcashposition", viewsets.CashPositionPortfolioPandasAPIView, basename="productcashposition")
|
|
179
|
+
router.register(r"assetpositiongroupby", viewsets.AssetPositionPandasView, basename="assetpositiongroupby")
|
|
180
|
+
router.register(
|
|
181
|
+
r"aggregatedassetpositionliquidity",
|
|
182
|
+
viewsets.AggregatedAssetPositionLiquidityPandasView,
|
|
183
|
+
basename="aggregatedassetpositionliquidity",
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
router.register(r"accountreconciliation", viewsets.AccountReconciliationModelViewSet, basename="accountreconciliation")
|
|
187
|
+
router.register(
|
|
188
|
+
r"accountreconciliationline", viewsets.AccountReconciliationLineModelViewSet, basename="accountreconciliationline"
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
account_reconciliation_router = WBCoreRouter()
|
|
192
|
+
account_reconciliation_router.register(
|
|
193
|
+
r"accountreconciliationline",
|
|
194
|
+
viewsets.AccountReconciliationLineModelViewSet,
|
|
195
|
+
basename="accountreconciliation-accountreconciliationline",
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# Claim routers
|
|
199
|
+
router.register(r"claimrepresentation", viewsets.ClaimRepresentationViewSet, basename="claimrepresentation")
|
|
200
|
+
router.register(r"claim", viewsets.ClaimModelViewSet, basename="claim")
|
|
201
|
+
router.register(r"claim-api", viewsets.ClaimAPIModelViewSet, basename="claim-api")
|
|
202
|
+
router.register(
|
|
203
|
+
r"negativeaccountproduct",
|
|
204
|
+
viewsets.NegativeTermimalAccountPerProductModelViewSet,
|
|
205
|
+
basename="negativeaccountproduct",
|
|
206
|
+
)
|
|
207
|
+
router.register(
|
|
208
|
+
r"aumtable",
|
|
209
|
+
viewsets.ConsolidatedTradeSummaryTableView,
|
|
210
|
+
basename="aumtable",
|
|
211
|
+
)
|
|
212
|
+
router.register(
|
|
213
|
+
r"consolidatedtradesummarydistributionchart",
|
|
214
|
+
viewsets.ConsolidatedTradeSummaryDistributionChart,
|
|
215
|
+
basename="consolidatedtradesummarydistributionchart",
|
|
216
|
+
)
|
|
217
|
+
router.register(
|
|
218
|
+
r"cumulativennmchart",
|
|
219
|
+
viewsets.CumulativeNNMChartView,
|
|
220
|
+
basename="cumulativennmchart",
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
router.register(
|
|
224
|
+
r"pnltable",
|
|
225
|
+
viewsets.ProfitAndLossPandasView,
|
|
226
|
+
basename="pnltable",
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
account_router = WBCoreRouter()
|
|
230
|
+
account_router.register(r"claim", viewsets.ClaimAccountModelViewSet, basename="account-claim")
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
entry_router = WBCoreRouter()
|
|
234
|
+
entry_router.register(r"claim", viewsets.ClaimEntryModelViewSet, basename="entry-claim")
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
urlpatterns = [
|
|
238
|
+
path("", include(router.urls)),
|
|
239
|
+
path("product/<int:product_id>/", include(product_router.urls)),
|
|
240
|
+
path("trade/<int:trade_id>/", include(trade_router.urls)),
|
|
241
|
+
path("portfolio/<int:portfolio_id>/", include(portfolio_router.urls)),
|
|
242
|
+
path("tradeproposal/<int:trade_proposal_id>/", include(trade_proposal_router.urls)),
|
|
243
|
+
path("instrument/<int:instrument_id>/", include(instrument_router.urls)),
|
|
244
|
+
path("account/<int:account_id>/", include(account_router.urls)),
|
|
245
|
+
path("entry/<int:entry_id>/", include(entry_router.urls)),
|
|
246
|
+
path("accountreconciliation/<int:accountreconciliation_id>/", include(account_reconciliation_router.urls)),
|
|
247
|
+
]
|
wbportfolio/utils.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
from fuzzywuzzy import process as fuzzywuzzy_process
|
|
4
|
+
from fuzzywuzzy import utils
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def string_matching(s1, s2):
|
|
8
|
+
best_result = ("", 0)
|
|
9
|
+
for _s1 in s1.split(" "):
|
|
10
|
+
if _s1 in ["&"]:
|
|
11
|
+
continue
|
|
12
|
+
# validate query
|
|
13
|
+
if utils.full_process(_s1):
|
|
14
|
+
matches = fuzzywuzzy_process.extract(_s1, s2)
|
|
15
|
+
if matches[0][1] > best_result[1]:
|
|
16
|
+
best_result = matches[0]
|
|
17
|
+
|
|
18
|
+
return best_result
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def re_ric(input: str):
|
|
22
|
+
return set(re.findall(r"([A-Za-z0-9]{1,6}\.[A-Z]{1,2})(?:.)(?<!\.)", input))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def re_bloomberg(input: str):
|
|
26
|
+
return set(re.findall(r"[A-Z]{2,5}(?:\-[A-Z]{2})?", input))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def re_isin(input: str):
|
|
30
|
+
return set(re.findall(r"[A-Z]{2}[A-Z0-9]{9}[0-9]", input))
|