Skip to content

jabrena/plinth / skills/810-regulations-eu-mifid-ii

810-regulations-eu-mifid-ii

Verified

Use when reviewing Java enterprise evidence for MiFID II investment services, investment activities, client classification, suitability, appropriateness, order-handling evidence, best-execution evidence, algorithmic-trading governance evidence, market-access governance evidence, transaction evidence, record keeping, monitoring, or compliance-owner handoff. This should trigger for requests such as Review a Java investment-service platform for MiFID II evidence; Assess suitability, appropriateness, order-handling evidence, or best-execution evidence; Document audit, monitoring, or clock-synchronisation gaps for algorithmic-trading governance; Assess investment-service engineering evidence before production release. Part of Plinth Toolkit

references/810-regulations-eu-mifid-ii-engineering-examples.md

View on GitHub
---
name: 810-regulations-eu-mifid-ii-engineering-examples
description: Use as Java-focused MiFID II engineering examples for investment-service scope triage, client classification, suitability, appropriateness, order-handling evidence, best-execution evidence, algorithmic-trading governance controls, record keeping, monitoring, and compliance evidence handoff.
license: Apache-2.0
metadata:
  author: Juan Antonio Breña Moral
  version: 0.19.0
---
# MiFID II Regulation for Java Enterprise Investment Service Controls

## Role

You are a senior Java enterprise architect and financial-services compliance reviewer who translates MiFID II themes into concrete Java engineering examples and reviewable evidence patterns

## Goal

Apply these MiFID II-aware examples after the regulation summary has been read and the target investment-service scope is understood.

These examples are not legal advice. They show engineering patterns that help Java teams create reviewable evidence for legal, compliance, risk, product, operations, trading, market-structure, data-protection, security, and accountable business owners.

Use this examples reference together with `810-regulations-eu-mifid-ii-chapters-summary.md` and the [MiFID II engineering review report template](../assets/reports/810-mifid-ii-engineering-review-report-template.md).

## Constraints

Translate MiFID II concerns into engineering controls for Java enterprise systems without replacing qualified legal, compliance, risk, product, operations, trading, market-structure, data-protection, security, or accountable business-owner review.

- **NOT LEGAL ADVICE**: Treat the examples as engineering control patterns and escalation aids, not legal findings
- **EVIDENCE FIRST**: Prefer reviewable evidence over claims that client classification, suitability, appropriateness, order-handling, best-execution, algorithmic-trading governance, timestamping, or record-keeping controls exist
- **REVIEW ONLY**: Use these examples for offline evidence review, auditability, control design, and owner handoff; live trading operations remain outside their scope
- **OWNER HANDOFFS**: Include product, compliance, risk, operations, trading, data, security, architecture, and legal owners in control records
- **SAFE EVIDENCE**: Preserve MiFID II evidence without exposing secrets, trading credentials, broker secrets, venue secrets, personal data, client confidential information, business secrets, or confidential trading strategy
- **RELEASE READINESS**: Do not mark a system ready when critical MiFID II controls are undocumented, untested, ownerless, not reconstructable, or dependent on unclear regulatory interpretation

## Examples

### Table of contents

- Example 1: Inventory investment-service scope before control design
- Example 2: Preserve client classification and product governance evidence
- Example 3: Make suitability and appropriateness workflows reconstructable
- Example 4: Audit order handling and best-execution decisions
- Example 5: Gate algorithmic trading releases with controls and approvals
- Example 6: Preserve timestamp and record-keeping evidence
- Example 7: Hand off compliance evidence with owners and open questions

### Example 1: Inventory investment-service scope before control design

Title: service, instrument, client, venue, owner, and escalation evidence
Description: Use this pattern when a Java system touches investment advice, portfolio management, order reception records, order-handling records, execution evidence, market-access governance, product governance, transaction evidence, or client records. The goal is not to decide legal applicability or operate trading workflows, but to make the system scope reviewable by qualified owners.

**Good example:**

```yaml
mifidScopeInventory:
  service: equity-order-evidence-api
  possibleInvestmentServiceSignals:
    - order reception evidence
    - execution evidence for owner review
  financialInstruments: [listed-equities, etfs]
  clientCategories: [retail, professional]
  tradingVenues: [regulated-market, mtf]
  owners:
    product: investments-platform
    technical: trading-services
    compliance: mifid-compliance
    risk: trading-risk
    operations: brokerage-operations
  evidence:
    architectureDecision: adr-2026-014-order-evidence
    dataLineage: lineage:order-evidence-v4
    ownerReview: evidence:mifid-scope-review-2026-06
  openQuestions:
    - legal confirmation of service classification
    - best-execution policy mapping for new venue
```

**Bad example:**

```yaml
mifidScopeInventory:
  service: order-api
  status: not regulated
  owner: backend
```


### Example 2: Preserve client classification and product governance evidence

Title: retail, professional, eligible counterparty, target market, restrictions, and review
Description: Use this pattern when an onboarding, entitlement, advisory, portfolio, or order-entry workflow depends on client category or product target-market decisions. Classification interpretation belongs to qualified owners; engineering should keep the decision inputs, owner approvals, and effective dates reconstructable.

**Good example:**

```java
public TradingEntitlement evaluate(ClientProductRequest request) {
    ClientClassification classification = clientRegistry.currentClassification(request.clientId())
        .orElseThrow(() -> new MissingClientClassificationException(request.clientId()));

    ProductGovernanceRecord product = productCatalog.requireApprovedProduct(
        request.instrumentId(),
        request.requestedService()
    );

    TargetMarketDecision decision = targetMarketPolicy.evaluate(
        classification.category(),
        product.targetMarket(),
        request.countryOfResidence(),
        request.channel()
    );

    entitlementAudit.record(new ClientEntitlementAuditEvent(
        request.clientId(),
        classification.category(),
        product.productId(),
        decision.status(),
        decision.ownerReviewId(),
        clock.instant()
    ));

    return TradingEntitlement.from(decision);
}
```

**Bad example:**

```java
public boolean canTrade(String clientId, String symbol) {
    return true;
}
```


### Example 3: Make suitability and appropriateness workflows reconstructable

Title: knowledge, experience, objectives, warnings, suitability report, and owner escalation
Description: Use this pattern when a Java service supports investment advice, portfolio management, complex product journeys, or appropriateness checks. The workflow should show what evidence was used, what warning or report was issued, and which owner must review unclear client-impact decisions.

**Good example:**

```java
public AdviceDecision assess(AdviceRequest request) {
    ClientProfile profile = clientProfileService.requireCurrentProfile(request.clientId());
    InstrumentProfile instrument = instrumentCatalog.requireInstrument(request.instrumentId());

    SuitabilityResult suitability = suitabilityPolicy.evaluate(
        profile.investmentObjectives(),
        profile.riskTolerance(),
        profile.lossCapacity(),
        instrument.riskProfile()
    );

    AppropriatenessResult appropriateness = appropriatenessPolicy.evaluate(
        profile.knowledgeAndExperience(),
        instrument.complexity()
    );

    SuitabilityReport report = suitabilityReports.create(
        request.clientId(),
        request.requestId(),
        suitability,
        appropriateness,
        request.adviserId()
    );

    adviceAudit.record(new AdviceAssessmentAuditEvent(
        request.requestId(),
        request.clientId(),
        request.instrumentId(),
        suitability.status(),
        appropriateness.status(),
        report.id(),
        clock.instant()
    ));

    return AdviceDecision.withReport(report.id(), suitability, appropriateness);
}
```

**Bad example:**

```java
public AdviceDecision assess(String clientId, String isin) {
    return AdviceDecision.approved();
}
```


### Example 4: Audit order handling and best-execution decisions

Title: client instruction, routing, venue, execution quality, aggregation, allocation, and reconstruction
Description: Use this pattern when an order management service records evidence about received, validated, aggregated, allocated, cancelled, corrected, routed, or executed orders. The review should make order decisions reconstructable from stored evidence, including client instructions and policy versions, without causing live order activity.

**Good example:**

```java
public OrderDecisionEvidence reviewOrderDecision(OrderDecisionRecord record) {
    ClientInstruction instruction = instructionStore.requireInstruction(record.orderId());
    ExecutionPolicyVersion policy = executionPolicyRegistry.requireVersion(record.policyVersion());
    MarketSnapshotReference snapshot = marketDataEvidence.requireSnapshot(record.marketSnapshotId());

    OrderDecisionEvidence evidence = new OrderDecisionEvidence(
        record.orderId(),
        record.clientId(),
        record.instrumentId(),
        instruction.id(),
        policy.version(),
        record.selectedVenue(),
        snapshot.id(),
        record.decisionTimestamp(),
        evidenceHasher.hash(record.safeDecisionPayload())
    );

    orderEvidenceStore.append(evidence);
    bestExecutionEvidence.record(evidence);
    return evidence;
}
```

**Bad example:**

```java
public void saveOrderEvidence(OrderDecisionRecord record) {
    log.info("order decision {}", record);
}
```


### Example 5: Gate algorithmic trading releases with controls and approvals

Title: algorithm inventory, testing, throttles, emergency stop, monitoring, and change control
Description: Use this pattern when a Java deployment changes algorithmic-trading governance logic, market-access connectivity configuration, throttling controls, pricing evidence, hedging evidence, quoting evidence, smart-order-routing evidence, or automated-order-generation evidence. The release gate should fail closed when approval, testing, monitoring, or operational control evidence is missing; the example is for review records and must not operate trading workflows.

**Good example:**

```yaml
algorithmicTradingReleaseGate:
  algorithmId: smart-router-eu-equities-v7
  owner: algorithmic-trading
  complianceOwner: mifid-compliance
  riskOwner: trading-risk
  inventoryRecord: evidence:algo-inventory-smart-router-v7
  tests:
    unit: passed
    simulation: passed
    marketReplay: passed
    stress: passed
    killSwitch: passed
  controls:
    preTradeRiskChecks: enabled
    throttling: orders-per-second policy v3
    maxOrderValue: risk-limit-policy v5
    circuitBreaker: enabled
    emergencyStopEvidence: runbook:algo-emergency-stop
  monitoring:
    dashboards: [algo-latency, order-rejects, throttle-events, emergency-stop-state]
    alerts: [unexpected-order-rate, venue-reject-spike, stale-market-data]
  approvals:
    trading: approved
    risk: approved
    compliance: approved
    operations: approved
```

**Bad example:**

```yaml
algorithmicTradingReleaseGate:
  algorithmId: smart-router
  tests: passed locally
  approval: team lead said ok
```


### Example 6: Preserve timestamp and record-keeping evidence

Title: clock source, event time, order event sequence, retention, redaction, and replay
Description: Use this pattern when Java services record order, trade, quote, transaction, client-interaction, advice, or algorithm events. Evidence should show reliable event sequencing and retention without leaking credentials, personal data, or confidential trading strategy.

**Good example:**

```java
public void recordOrderEvent(OrderEvent event) {
    ClockStatus clockStatus = clockMonitor.requireSynchronized("trading-cluster-eu");
    OrderAuditRecord record = new OrderAuditRecord(
        event.orderId(),
        event.eventType(),
        event.clientId(),
        event.instrumentId(),
        event.venue(),
        event.policyVersion(),
        event.occurredAt(),
        clockStatus.source(),
        clockStatus.maxObservedDrift(),
        evidenceHasher.hash(event.safePayload())
    );

    orderAuditStore.append(record);
    retentionPolicy.apply(record, RetentionClass.MIFID_ORDER_RECORD);
    reconstructionIndex.index(record);
}
```

**Bad example:**

```java
public void recordOrderEvent(OrderEvent event) {
    log.info("order event {}", event);
}
```


### Example 7: Hand off compliance evidence with owners and open questions

Title: scope, findings, source links, owner decisions, residual risk, and release status
Description: Use this pattern at the end of review. The engineering report should distinguish reviewed facts from assumptions, mark open regulatory decisions for qualified owners, and include actionable remediation items with evidence expectations.

**Good example:**

```markdown
| Potential violation or non-compliance signal | MiFID II reference area | Associated official-source link | Evidence from reviewed system | Current status | Required owner review | Engineering action |
| --- | --- | --- | --- | --- | --- | --- |
| Missing owner-approved algorithm deployment evidence | Algorithmic trading / organisational requirements | https://eur-lex.europa.eu/eli/dir/2014/65/oj/eng | Deployment changes smart-router-v7 but no risk or compliance approval record was provided | Potential gap | Trading / risk / compliance / operations | Add release gate requiring algorithm inventory, market replay, emergency-stop test, and owner approval evidence |
```

**Bad example:**

```markdown
System is MiFID II compliant. No further action.
```


## Output Format

- Describe each example as an engineering pattern, not legal advice
- Map each recommendation to reviewed evidence, MiFID II topic area, owner, and release decision
- Use source links and owner handoffs when potential violation or non-compliance signals are identified
- Redact secrets, trading credentials, broker secrets, venue secrets, personal data, and confidential trading strategy from evidence summaries
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 196kUpdated Claude CodeCodexVerifiedInstall