Logo Lanfrica
  • Home
  • Atlas
  • Insights
  • Docs
  • Sign in

© 2026 Lanfrica. All rights reserved. All copyrights of the resources shown on the Lanfrica website belong to the original copyright holders, unless explicitly stated otherwise.

onekenosi/African-Risk-Market-Dashboard

Domain:

socioeconomic
Creator:
one
Host:
# African-Risk-Market-Dashboard import streamlit as st import pandas as pd import numpy as np import plotly.graph_objects as go import plotly.express as px from datetime import datetime, timedelta import yfinance as yf st.set_page_config( page_title="African Markets Risk Dashboard", page_icon="📊", layout="wide" ) st.title("📊 African Markets Risk Dashboard") st.markdown(""" Explore financial risk metrics across African stock markets and currencies. This dashboard provides real-time analysis of volatility, returns, and comparative performance. """) st.sidebar.header("Configuration") AFRICAN_MARKETS = { "South Africa (JSE Top 40)": "^J203.JO", "Nigeria (NGX All-Share)": "NGSEINDEX", "Egypt (EGX 30)": "^CASE30", "Kenya (NSE 20)": "^NSEI", "Morocco (MASI)": "^MASI.CS" } CURRENCIES = { "ZAR/USD (South African Rand)": "ZARUSD=X", "NGN/USD (Nigerian Naira)": "NGN=X", "EGP/USD (Egyptian Pound)": "EGP=X", "KES/USD (Kenyan Shilling)": "KES=X", "MAD/USD (Moroccan Dirham)": "MAD=X" } BENCHMARK_MARKETS = { "S&P 500": "^GSPC", "FTSE 100": "^FTSE", "Shanghai Composite": "000001.SS" } selected_market = st.sidebar.selectbox( "Select African Market", list(AFRICAN_MARKETS.keys()) ) selected_currency = st.sidebar.selectbox( "Select Currency Pair", list(CURRENCIES.keys()) ) time_period = st.sidebar.selectbox( "Time Period", ["1mo", "3mo", "6mo", "1y", "2y"], index=2 ) risk_free_rate = st.sidebar.slider( "Risk-Free Rate (%)", min_value=0.0, max_value=10.0, value=4.5, step=0.1 ) / 100 @st.cache_data(ttl=3600) def fetch_data(ticker, period): """Fetch historical data from Yahoo Finance""" try: data = yf.download(ticker, period=period, progress=False) return data except: return None def calculate_returns(data): """Calculate daily returns""" return data['Close'].pct_change().dropna() def calculate_volatility(returns, annualize=True): """Calculate volatility (standard deviation of returns)""" vol = returns.std() if annualize: vol = vol * np.sqrt(252) # Annualize assuming 252 trading day …

Visit

github.com

Languages

Mashi