Skip to content

feat: Replace portfolio/position ops with unified portfolio block management#107

Merged
jfrench9 merged 1 commit intomainfrom
feature/portfolio-block
Apr 26, 2026
Merged

feat: Replace portfolio/position ops with unified portfolio block management#107
jfrench9 merged 1 commit intomainfrom
feature/portfolio-block

Conversation

@jfrench9
Copy link
Copy Markdown
Member

Summary

Introduces a new portfolio block abstraction that unifies portfolio and position operations into a single, cohesive management model. This replaces the previous separate CRUD operations for portfolios and positions with consolidated portfolio block operations that handle both concerns atomically.

Key Accomplishments

API Layer Refactoring

  • Renamed and refactored op_create_portfolio, op_delete_portfolio, and op_update_portfolio to their _block counterparts (op_create_portfolio_block, op_delete_portfolio_block, op_update_portfolio_block)
  • Removed standalone position operation modules (op_create_position, op_delete_position, op_update_position) — position management is now handled within portfolio block operations

New Domain Models

  • CreatePortfolioBlockRequest — encapsulates portfolio creation with embedded position data
  • UpdatePortfolioBlockOperation — supports portfolio patching, position adds, updates, and disposals in a single operation
  • DeletePortfolioBlockOperation — handles portfolio block deletion
  • PortfolioBlockPortfolioFields — defines portfolio-level field schema
  • PortfolioBlockPortfolioPatch — represents partial portfolio updates
  • PortfolioBlockPositionAdd / PortfolioBlockPositionUpdate / PortfolioBlockPositionDispose — granular position mutation types within a block context
  • PortfolioBlockPositions — container model for position collections

Client Simplification

  • Refactored investor_client.py to use the new portfolio block API surface, reducing overall complexity (~120 lines net reduction in client code)
  • Updated GraphQL query definitions in the investor query module to align with the new block-based schema

Model Exports

  • Updated models/__init__.py to export all new models and remove deprecated ones

Breaking Changes

⚠️ This is a breaking change for all consumers of the investor client API.

  • Removed operations: create_portfolio, update_portfolio, delete_portfolio, create_position, update_position, delete_position — these no longer exist as separate client methods
  • Removed models: CreatePortfolioRequest, UpdatePortfolioOperation, DeletePortfolioOperation, CreatePositionRequest, UpdatePositionOperation, DeletePositionOperation
  • Replaced by: Portfolio block equivalents (create_portfolio_block, update_portfolio_block, delete_portfolio_block) which manage positions inline
  • Consumers must migrate to the new portfolio block API and update all model imports accordingly

Testing

  • tests/test_investor_client.py has been substantially updated (~175 lines changed) to cover the new portfolio block operations
  • Tests cover creation, update (including position add/update/dispose), and deletion flows
  • Existing position-specific test cases have been replaced with block-level equivalents

Infrastructure Considerations

  • GraphQL schema/queries have been updated to support the new block-based operations — ensure the backend GraphQL API is deployed with the corresponding schema changes before rolling out this client version
  • No new dependencies introduced; net reduction in codebase size (~310 fewer lines overall)

🤖 Generated with Claude Code

Branch Info:

  • Source: feature/portfolio-block
  • Target: main
  • Type: feature

Co-Authored-By: Claude noreply@anthropic.com

- Added models for portfolio block operations including:
  - PortfolioBlockPortfolioPatch
  - PortfolioBlockPositionAdd
  - PortfolioBlockPositionDispose
  - PortfolioBlockPositionUpdate
  - PortfolioBlockPositions
  - UpdatePortfolioBlockOperation

- Updated tests to cover new portfolio block functionalities:
  - Test for creating, updating, and deleting portfolio blocks.
  - Enhanced test coverage for portfolio block retrieval and position management.
@jfrench9 jfrench9 merged commit 5398f3d into main Apr 26, 2026
1 check passed
@jfrench9 jfrench9 deleted the feature/portfolio-block branch April 26, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant