SECTION 1: LEARNING OBJECTIVES

By the end of this lesson, you will be able to:

  • Define open banking and its impact on digital banking products.

  • Understand the regulatory drivers – PSD2, CDR, and others.

  • Design API-driven banking products for open banking.

  • Understand the key API types – Account Information (AIS) and Payment Initiation (PIS).

  • Apply security and consent management in open banking.

  • Identify business models for open banking.

  • Measure open banking product performance using key metrics.

  • Develop an open banking product strategy for a digital bank.


SECTION 2: WHAT IS OPEN BANKING?

2.1 Definition

Open Banking is a regulatory framework that requires banks to share customer data (with customer consent) with authorised third-party providers (TPPs) via secure APIs. It enables customers to access a wider range of financial services and enables innovation in the financial ecosystem.

2.2 Key Open Banking Principles
 
 
Principle Description Impact
Customer Consent Customers control their data. Data sharing requires explicit consent.
Secure APIs Standardised, secure data sharing. Interoperability, security.
Third-Party Access TPPs can access bank data. Innovation, competition.
Data Portability Customers can move data. Switching, comparison.
Transparency Clear terms and conditions. Customer trust.
2.3 Open Banking Ecosystem
text
┌─────────────────────────────────────────────────────────────────────────────┐
│                    OPEN BANKING ECOSYSTEM                                 │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    CUSTOMER                                         │   │
│  │  (Data owner, consents to sharing)                                 │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    BANK (ASPSP)                                     │   │
│  │  (Account Servicing Payment Service Provider)                       │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    API PLATFORM                                     │   │
│  │  (Secure, standardised APIs)                                       │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    THIRD-PARTY PROVIDERS (TPPs)                     │   │
│  │  • AISP (Account Information Service Provider)                      │   │
│  │  • PISP (Payment Initiation Service Provider)                       │   │
│  │  • Other TPPs                                                       │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    OPEN BANKING PRODUCTS                            │   │
│  │  • Account aggregation                                              │   │
│  │  • Payment initiation                                               │   │
│  │  • Personal financial management                                   │   │
│  │  • Lending                                                          │   │
│  │  • Wealth management                                                │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

SECTION 3: OPEN BANKING REGULATIONS

3.1 Key Regulations
 
 
Regulation Region Key Requirements
PSD2 EU Strong Customer Authentication (SCA), AIS/PIS access.
Open Banking UK Standardised APIs, TPP access.
CDR (Consumer Data Right) Australia Open banking, open data.
CCPA US Data access rights.
Canada Canada Consumer-driven banking.
3.2 PSD2 Requirements
 
 
Requirement Description Implementation
Strong Customer Authentication Multi-factor authentication. MFA for payments.
Account Information Access TPP access to account data. API access.
Payment Initiation TPPs can initiate payments. Payment APIs.
Customer Consent Explicit customer consent. Consent management.
Security Secure API communication. OAuth 2.0, TLS.

SECTION 4: OPEN BANKING API TYPES

4.1 Account Information Services (AIS)
 
 
Feature Description Benefit
Account Information Access to account balances and transactions. Account aggregation.
Customer Data Access to customer profile data. Personalisation.
Transaction History Access to transaction history. Financial management.
4.2 Payment Initiation Services (PIS)
 
 
Feature Description Benefit
Payment Initiation Initiate payments from customer account. Seamless payments.
Confirmation of Funds Check account balance. Payment validation.
Recurring Payments Schedule recurring payments. Subscription management.
4.3 Other Open Banking APIs
 
 
API Type Description Use Case
Product APIs Access to product information. Product comparison.
Identity APIs Identity verification. KYC, onboarding.
SME APIs Business banking data. Business lending.
Mortgage APIs Mortgage data. Mortgage comparison.

SECTION 5: OPEN BANKING PRODUCTS

5.1 Open Banking Product Categories
 
 
Category Description Examples
Account Aggregation View multiple accounts in one place. Personal financial management apps.
Payment Initiation Pay directly from bank account. Paydirect, merchant payments.
Lending Credit assessment using bank data. Income verification, affordability checks.
Wealth Management Investment advice using account data. Robo-advisory, portfolio management.
Business Banking Cash flow management, lending. SME lending, cash flow forecasting.
Insurance Insurance pricing using bank data. Usage-based insurance.
5.2 Open Banking Business Models
 
 
Model Description Revenue
Data Aggregation Aggregate and monetise data. Subscription, data licensing.
Payment Initiation Facilitate payments. Transaction fees.
Lending Use data for credit assessment. Interest, origination fees.
Advisory Provide financial advice. Advisory fees.
Referral Refer customers to products. Referral fees.

SECTION 6: IMPLEMENTATION IN PYTHON – OPEN BANKING TOOLS

python
# ===================================================================
# MODULE 7, LESSON 3: OPEN BANKING AND API-DRIVEN PRODUCTS
# ===================================================================

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from datetime import datetime, timedelta
import json
import hashlib
import warnings
warnings.filterwarnings('ignore')

print("="*70)
print("OPEN BANKING AND API-DRIVEN PRODUCTS")
print("="*70)

# ----------------------------------------------------------------
# PART A: OPEN BANKING ECOSYSTEM MAPPING
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART A: Open Banking Ecosystem Mapping")
print("-"*60)

ecosystem = {
    "1. ASPSPs (Banks)": {
        "Description": "Account Servicing Payment Service Providers.",
        "Examples": ["Traditional Banks", "Digital Banks", "Neobanks"],
        "Role": "Provide account and payment services."
    },
    "2. TPPs (Third-Party Providers)": {
        "Description": "Licensed third-party providers.",
        "Types": ["AISP (Account Information)", "PISP (Payment Initiation)"],
        "Role": "Provide innovative services using bank data."
    },
    "3. API Platform": {
        "Description": "Secure API infrastructure.",
        "Components": ["API Gateway", "Identity Management", "Consent Management"],
        "Role": "Enable secure data sharing."
    },
    "4. Regulators": {
        "Description": "Regulatory bodies.",
        "Examples": ["FCA (UK)", "CMA", "EBA"],
        "Role": "Oversee and regulate open banking."
    },
    "5. Customers": {
        "Description": "End-users of open banking products.",
        "Role": "Data owners, benefit from innovative products."
    }
}

print("Open Banking Ecosystem:")
for component, details in ecosystem.items():
    print(f"\n{component}:")
    print(f"  Description: {details['Description']}")
    if 'Examples' in details:
        print(f"  Examples: {', '.join(details['Examples'])}")
    if 'Types' in details:
        print(f"  Types: {', '.join(details['Types'])}")
    if 'Components' in details:
        print(f"  Components: {', '.join(details['Components'])}")
    print(f"  Role: {details['Role']}")

# ----------------------------------------------------------------
# PART B: SIMULATED OPEN BANKING API
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART B: Simulated Open Banking API")
print("-"*60)

class OpenBankingAPI:
    """Simulate an open banking API platform."""
    
    def __init__(self):
        self.accounts = {}
        self.transactions = {}
        self.consents = {}
        self.api_calls = []
        self.tpp_registry = {}
    
    def register_tpp(self, tpp_id, name, type):
        """Register a third-party provider."""
        self.tpp_registry[tpp_id] = {
            'name': name,
            'type': type,
            'registered': datetime.now().isoformat(),
            'status': 'Active'
        }
        return tpp_id
    
    def add_account(self, account_id, customer_id, balance, currency='USD'):
        """Add a customer account."""
        self.accounts[account_id] = {
            'customer_id': customer_id,
            'balance': balance,
            'currency': currency,
            'created': datetime.now().isoformat()
        }
        return account_id
    
    def add_transaction(self, account_id, amount, description):
        """Add a transaction to an account."""
        if account_id not in self.accounts:
            return {'error': 'Account not found'}
        
        transaction = {
            'id': len(self.transactions) + 1,
            'account_id': account_id,
            'amount': amount,
            'description': description,
            'timestamp': datetime.now().isoformat()
        }
        self.transactions[transaction['id']] = transaction
        
        # Update balance
        self.accounts[account_id]['balance'] += amount
        return transaction
    
    def grant_consent(self, customer_id, tpp_id, permissions):
        """Grant consent for a TPP to access customer data."""
        consent_key = f"{customer_id}:{tpp_id}"
        self.consents[consent_key] = {
            'customer_id': customer_id,
            'tpp_id': tpp_id,
            'permissions': permissions,
            'granted': datetime.now().isoformat(),
            'status': 'Active',
            'expires': (datetime.now() + timedelta(days=90)).isoformat()
        }
        return consent_key
    
    def check_consent(self, customer_id, tpp_id, permission):
        """Check if consent exists for a specific permission."""
        consent_key = f"{customer_id}:{tpp_id}"
        if consent_key not in self.consents:
            return False, {'error': 'No consent found'}
        
        consent = self.consents[consent_key]
        if consent['status'] != 'Active':
            return False, {'error': 'Consent expired or revoked'}
        
        if permission not in consent['permissions']:
            return False, {'error': 'Permission not granted'}
        
        return True, {'status': 'Authorized'}
    
    def get_accounts(self, customer_id, tpp_id):
        """API: Get customer accounts."""
        # Check consent
        has_consent, result = self.check_consent(customer_id, tpp_id, 'view_accounts')
        if not has_consent:
            return result
        
        # Get accounts
        customer_accounts = {}
        for acc_id, acc in self.accounts.items():
            if acc['customer_id'] == customer_id:
                customer_accounts[acc_id] = {
                    'balance': acc['balance'],
                    'currency': acc['currency']
                }
        
        # Log API call
        self.api_calls.append({
            'api': 'Accounts',
            'customer_id': customer_id,
            'tpp_id': tpp_id,
            'timestamp': datetime.now().isoformat()
        })
        
        return {'accounts': customer_accounts}
    
    def initiate_payment(self, customer_id, tpp_id, from_account, to_account, amount):
        """API: Initiate a payment."""
        # Check consent
        has_consent, result = self.check_consent(customer_id, tpp_id, 'initiate_payments')
        if not has_consent:
            return result
        
        # Validate accounts
        if from_account not in self.accounts:
            return {'error': 'From account not found'}
        if to_account not in self.accounts:
            return {'error': 'To account not found'}
        
        # Check balance
        if self.accounts[from_account]['balance'] < amount:
            return {'error': 'Insufficient funds'}
        
        # Execute payment
        self.accounts[from_account]['balance'] -= amount
        self.accounts[to_account]['balance'] += amount
        
        # Log API call
        self.api_calls.append({
            'api': 'Payments',
            'customer_id': customer_id,
            'tpp_id': tpp_id,
            'from_account': from_account,
            'to_account': to_account,
            'amount': amount,
            'timestamp': datetime.now().isoformat()
        })
        
        return {
            'status': 'Success',
            'amount': amount,
            'from_account': from_account,
            'to_account': to_account,
            'timestamp': datetime.now().isoformat()
        }
    
    def get_api_analytics(self):
        """Get API usage analytics."""
        df = pd.DataFrame(self.api_calls)
        if df.empty:
            return {'total_calls': 0}
        return {
            'total_calls': len(df),
            'by_api': df['api'].value_counts().to_dict(),
            'by_tpp': df['tpp_id'].value_counts().to_dict()
        }

# Create Open Banking API platform
api_platform = OpenBankingAPI()

# Register TPPs
api_platform.register_tpp('TPP001', 'Account Aggregator', 'AISP')
api_platform.register_tpp('TPP002', 'Payment Provider', 'PISP')
api_platform.register_tpp('TPP003', 'Lending Platform', 'AISP/PISP')

# Add customer accounts
api_platform.add_account('ACC001', 'CUST001', 5000)
api_platform.add_account('ACC002', 'CUST001', 10000)
api_platform.add_account('ACC003', 'CUST002', 3000)

# Grant consent
api_platform.grant_consent('CUST001', 'TPP001', ['view_accounts', 'view_transactions'])
api_platform.grant_consent('CUST001', 'TPP002', ['view_accounts', 'initiate_payments'])

print("Open Banking API Platform Initialised:")
print(f"Accounts: {len(api_platform.accounts)}")
print(f"TPPs Registered: {len(api_platform.tpp_registry)}")
print(f"Consents Granted: {len(api_platform.consents)}")

# Test API calls
print("\nAPI Calls:")
result = api_platform.get_accounts('CUST001', 'TPP001')
print(f"TPP001 -> Get Accounts: {json.dumps(result, indent=2)[:200]}...")

result = api_platform.initiate_payment('CUST001', 'TPP002', 'ACC001', 'ACC003', 500)
print(f"TPP002 -> Initiate Payment: {json.dumps(result, indent=2)[:200]}...")

analytics = api_platform.get_api_analytics()
print(f"\nAPI Analytics: {json.dumps(analytics, indent=2)}")

# ----------------------------------------------------------------
# PART C: OPEN BANKING PRODUCT CATALOGUE
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART C: Open Banking Product Catalogue")
print("-"*60)

open_banking_products = pd.DataFrame({
    'Product': [
        'Account Aggregation',
        'Payment Initiation',
        'Personal Financial Management',
        'Lending (Affordability)',
        'Wealth Management',
        'SME Cash Flow',
        'Insurance Pricing',
        'Identity Verification'
    ],
    'Category': [
        'Data', 'Payments', 'Data', 'Lending', 'Wealth',
        'Business', 'Insurance', 'Identity'
    ],
    'TPP Type': [
        'AISP', 'PISP', 'AISP', 'AISP', 'AISP',
        'AISP', 'AISP', 'AISP'
    ],
    'Revenue Model': [
        'Subscription', 'Transaction', 'Subscription', 'Interest', 'Advisory',
        'Subscription', 'Referral', 'Per-use'
    ],
    'Maturity': [
        'Mature', 'Mature', 'Growing', 'Growing', 'Emerging',
        'Growing', 'Emerging', 'Mature'
    ]
})

print("Open Banking Product Catalogue:")
print(open_banking_products.to_string(index=False))

# ----------------------------------------------------------------
# PART D: OPEN BANKING METRICS
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART D: Open Banking Metrics Dashboard")
print("-"*60)

open_banking_metrics = pd.DataFrame({
    'Metric': [
        'TPP Integrations',
        'API Calls (Monthly)',
        'Customer Consents',
        'Payment Volume (Monthly)',
        'Data Sharing Rate',
        'API Availability',
        'API Response Time',
        'Customer NPS (Open Banking)'
    ],
    'Current Value': [
        '45',
        '250,000',
        '12,500',
        '$15M',
        '35%',
        '99.8%',
        '145ms',
        '52'
    ],
    'Target Value': [
        '100+',
        '500,000+',
        '25,000+',
        '$40M+',
        '> 60%',
        '> 99.95%',
        '< 100ms',
        '> 65'
    ],
    'Status': ['🟡', '🟡', '🟡', '🟡', '🔴', '🟡', '🟡', '🟡']
})

print("Open Banking Metrics Dashboard:")
print(open_banking_metrics.to_string(index=False))

# ----------------------------------------------------------------
# PART E: OPEN BANKING ROADMAP
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART E: Open Banking Roadmap")
print("-"*60)

roadmap = {
    "Phase 1 (0-6 months) – Foundation": {
        "Focus": "Build open banking foundation.",
        "Activities": [
            "Implement API gateway and security.",
            "Develop AIS and PIS APIs.",
            "Establish consent management.",
            "Comply with PSD2 requirements."
        ],
        "Success Metrics": ["APIs live", "TPP onboarding > 20"]
    },
    "Phase 2 (6-12 months) – Scale": {
        "Focus": "Scale open banking products.",
        "Activities": [
            "Launch account aggregation products.",
            "Launch payment initiation products.",
            "Build TPP ecosystem.",
            "Enable developer portal."
        ],
        "Success Metrics": ["TPP integrations > 50", "API calls > 300K/month"]
    },
    "Phase 3 (12-24 months) – Advanced": {
        "Focus": "Advanced open banking capabilities.",
        "Activities": [
            "Launch lending and wealth products.",
            "Enable SME banking products.",
            "Implement advanced analytics.",
            "Build open banking marketplace."
        ],
        "Success Metrics": ["New products launched", "Revenue from open banking > $10M"]
    },
    "Phase 4 (24+ months) – Leadership": {
        "Focus": "Industry-leading open banking.",
        "Activities": [
            "Lead open banking innovation.",
            "Build global open banking capabilities.",
            "Establish open banking ecosystem.",
            "Achieve industry leadership."
        ],
        "Success Metrics": ["Industry-leading open banking", "Continuous innovation"]
    }
}

for phase, details in roadmap.items():
    print(f"\n{phase}:")
    print(f"  Focus: {details['Focus']}")
    print("  Activities:")
    for activity in details['Activities']:
        print(f"    • {activity}")
    print("  Success Metrics:")
    for metric in details['Success Metrics']:
        print(f"    • {metric}")

# ----------------------------------------------------------------
# PART F: SUMMARY AND RECOMMENDATIONS
# ----------------------------------------------------------------

print("\n" + "="*70)
print("PART F: Summary and Recommendations")
print("="*70)

print("""
Open Banking and API-Driven Products – Key Takeaways:

1. Open banking enables secure data sharing with authorised TPPs.
2. Key regulations: PSD2, Open Banking (UK), CDR (Australia).
3. Key API types: AIS (Account Information) and PIS (Payment Initiation).
4. Open banking products: account aggregation, payment initiation, PFM, lending, wealth.
5. Business models: subscription, transaction fees, interest, advisory, referral.
6. Key metrics: TPP integrations, API calls, customer consents, payment volume.
7. Roadmap: foundation → scale → advanced → leadership.

Recommendations:
  - Implement AIS and PIS APIs.
  - Build consent management capabilities.
  - Create a developer portal and TPP onboarding.
  - Launch account aggregation and payment initiation products.
  - Develop lending and wealth products using open banking data.
  - Build an open banking ecosystem and marketplace.
""")

print("="*70)
print("END OF LESSON 3 – MODULE 7")
print("="*70)

SECTION 7: SUMMARY FOR THE DATA PRACTITIONER

  • Open banking enables secure data sharing with authorised third-party providers via APIs.

  • Key regulations include PSD2 (EU), Open Banking (UK), and CDR (Australia).

  • Key API types include AIS (Account Information Services) and PIS (Payment Initiation Services).

  • Open banking products include account aggregation, payment initiation, personal financial management, lending, wealth management, SME cash flow, insurance pricing, and identity verification.

  • Business models include subscription, transaction fees, interest, advisory fees, and referral fees.

  • Key metrics include TPP integrations, API calls, customer consents, payment volume, and API availability.

  • Roadmap progresses from foundation to scaling, advanced, and leadership phases.


SECTION 8: RECOMMENDED NEXT STEPS

  1. Implement AIS and PIS APIs.

  2. Build consent management capabilities.

  3. Create a developer portal and TPP onboarding.

  4. Launch account aggregation and payment initiation products.

  5. Develop lending and wealth products using open banking data.

  6. Build an open banking ecosystem and marketplace.

  7. Prepare for Lesson 4: Embedded Finance and Banking-as-a-Service.


[END OF LESSON 3 – MODULE 7]