• About Us
  • Contact Us
  • Terms & Conditions
  • Privacy Policy
Technology Hive
  • Home
  • Technology
  • Artificial Intelligence (AI)
  • Cyber Security
  • Machine Learning
  • More
    • Deep Learning
    • AI in Healthcare
    • AI Regulations & Policies
    • Business
    • Cloud Computing
    • Ethics & Society
No Result
View All Result
  • Home
  • Technology
  • Artificial Intelligence (AI)
  • Cyber Security
  • Machine Learning
  • More
    • Deep Learning
    • AI in Healthcare
    • AI Regulations & Policies
    • Business
    • Cloud Computing
    • Ethics & Society
No Result
View All Result
Technology Hive
No Result
View All Result
Home Technology

Risk-Adjusted Returns with Python: The Treynor Ratio

Linda Torries – Tech Writer & Digital Trends Analyst by Linda Torries – Tech Writer & Digital Trends Analyst
September 13, 2025
in Technology
0
Risk-Adjusted Returns with Python: The Treynor Ratio
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

Introduction to Risk-Adjusted Returns

“Risk comes from not knowing what you’re doing.” — Warren Buffett. Most investors chase returns, but seasoned fund managers ask a different question: “Am I being rewarded fairly for the risks I’m taking?” This is where risk-adjusted returns come in. Over this two-part series, we will explore metrics that are more than just raw returns. In this part, we’ll start with the Treynor Ratio and implement it step by step using Python.

What is the Treynor Ratio?

The Treynor Ratio measures how much excess return (above the risk-free rate) a portfolio generates per unit of market risk (beta). The formula for the Treynor Ratio is:
$Treynor Ratio = frac{Excess Return}{Beta}$

Difference from Sharpe Ratio

  • Sharpe uses standard deviation (total risk).
  • Treynor uses beta (systematic risk).

Interpretation

  • A higher Treynor Ratio means better compensation for market risk.
  • Best used when comparing diversified portfolios or funds.

Python Implementation

Let’s bring this to life with an example of a real multi-national company ‘APPLE’.

Step 1: Importing Libraries

import pandas as pd
import numpy as np
import yfinance as yf
import statsmodels.api as sm
import matplotlib.pyplot as plt
import seaborn as sns

Step 2: Downloading and Loading Data

# Calculate daily returns from the 'Close' prices
portfolio_ticker = 'AAPL'
market_ticker = '^GSPC'
start_date = '2023-01-01'
end_date = '2024-01-01'
portfolio_data = yf.download(portfolio_ticker, start = start_date, end = end_date)
market_data = yf.download(market_ticker, start = start_date, end = end_date)

Step 3: Computing Stock Daily Returns

# Combine into single DataFrame
portfolio_returns = portfolio_data['Close'].pct_change().dropna()
market_returns = market_data['Close'].pct_change().dropna()
returns = pd.concat([portfolio_returns, market_returns], axis = 1)
returns.columns = ['AAPL', 'SP500']
returns = returns.dropna()

Step 4: Calculating Treynor Ratio

# Computation of Beta value
X = sm.add_constant(returns['SP500']) 
y = returns['AAPL']
model = sm.OLS(y, X).fit()
beta = model.params['SP500']
print("Beta (Systematic Risk):", beta)

# Define Risk-free Rate (annualized, e.g., 3% U.S. T-bills) 
rf = 0.03 / 252 
# Calculate average excess return of portfolio 
excess_return = returns['AAPL'].mean() - rf
# Computation of Treynor Ratio 
treynor_ratio = excess_return / beta
print("Treynor Ratio:", treynor_ratio)

Understanding Beta

To understand beta better, let’s visualize it using a regression plot.

# Regression Plot (AAPL vs SP500) 
plt.figure(figsize = (8,6))
sns.regplot(x = returns['SP500'], y = returns['AAPL'], line_kws = {'color':'red'})
plt.title("Regression of AAPL on S&P500 (Beta Estimation)")
plt.xlabel("S&P500 Daily Returns")
plt.ylabel("AAPL Daily Returns")
plt.grid(True)
plt.show()

Interpretation of Beta

  • If the slope (β) = 1, AAPL moves in line with the market.
  • If β > 1, AAPL is more volatile than the market (amplifies market movements).
  • If β < 1, AAPL is less volatile than the market.

Conclusion

In this first part, we reviewed the Treynor Ratio, from its definition, use, and formula, to analyzing its application with a financial dataset. We saw its measures risk-adjusted returns in regards to systematic risk (beta), making it a viable metric for investors who are seeking to measure portfolio performance with respect to market movements, or risk factors. “Information is the oxygen of the modern age.” Similar to the life giving characteristic of oxygen, the information provides essentials for the decision-making process in finance. But information is not enough — we need to have tools that help us understand it, assess it and even compare it to other information. This is where performance ratios like the Sharpe Ratio and Treynor Ratio come in to the picture and ultimately bring focus and clarity to the cloudy decisions we are often making with investments.

FAQs

  1. What is the Treynor Ratio?
    The Treynor Ratio is a financial metric that measures the excess return of a portfolio over the risk-free rate, relative to its systematic risk (beta).
  2. How is the Treynor Ratio calculated?
    The Treynor Ratio is calculated as the excess return of a portfolio divided by its beta.
  3. What is beta in the context of the Treynor Ratio?
    Beta, in the context of the Treynor Ratio, refers to the systematic risk or volatility of a portfolio relative to the overall market.
  4. What is the difference between the Treynor Ratio and the Sharpe Ratio?
    The main difference between the Treynor Ratio and the Sharpe Ratio is that the Treynor Ratio uses beta (systematic risk) as the risk measure, while the Sharpe Ratio uses standard deviation (total risk).
  5. When is the Treynor Ratio more useful than the Sharpe Ratio?
    The Treynor Ratio is more useful when comparing the performance of diversified portfolios or funds, as it focuses on systematic risk rather than total risk.
Previous Post

Digital Twin Creation by AI

Next Post

Measuring AI Reasoning Incorrectly

Linda Torries – Tech Writer & Digital Trends Analyst

Linda Torries – Tech Writer & Digital Trends Analyst

Linda Torries is a skilled technology writer with a passion for exploring the latest innovations in the digital world. With years of experience in tech journalism, she has written insightful articles on topics such as artificial intelligence, cybersecurity, software development, and consumer electronics. Her writing style is clear, engaging, and informative, making complex tech concepts accessible to a wide audience. Linda stays ahead of industry trends, providing readers with up-to-date analysis and expert opinions on emerging technologies. When she's not writing, she enjoys testing new gadgets, reviewing apps, and sharing practical tech tips to help users navigate the fast-paced digital landscape.

Related Posts

MLOps Mastery with Multi-Cloud Pipeline
Technology

MLOps Mastery with Multi-Cloud Pipeline

by Linda Torries – Tech Writer & Digital Trends Analyst
October 30, 2025
Expert Panel to Decide AGI Arrival in Microsoft-OpenAI Deal
Technology

Expert Panel to Decide AGI Arrival in Microsoft-OpenAI Deal

by Linda Torries – Tech Writer & Digital Trends Analyst
October 30, 2025
Closed-Loop CNC Machining with IIoT Feedback Integration
Technology

Closed-Loop CNC Machining with IIoT Feedback Integration

by Linda Torries – Tech Writer & Digital Trends Analyst
October 30, 2025
1 million users discuss suicide with ChatGPT weekly
Technology

1 million users discuss suicide with ChatGPT weekly

by Linda Torries – Tech Writer & Digital Trends Analyst
October 30, 2025
Tree-GRPO Reduces AI Training Expenses by Half and Enhances Performance
Technology

Tree-GRPO Reduces AI Training Expenses by Half and Enhances Performance

by Linda Torries – Tech Writer & Digital Trends Analyst
October 30, 2025
Next Post
Measuring AI Reasoning Incorrectly

Measuring AI Reasoning Incorrectly

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Latest Articles

Broadcom Enhances VMware Platform for Simplified Private Cloud Management

Broadcom Enhances VMware Platform for Simplified Private Cloud Management

June 18, 2025
Meta AI Model Reproduces Almost Half of Harry Potter Book

Meta AI Model Reproduces Almost Half of Harry Potter Book

June 20, 2025
Can Recursion Improve LLM Efficiency?

Can Recursion Improve LLM Efficiency?

September 18, 2025

Browse by Category

  • AI in Healthcare
  • AI Regulations & Policies
  • Artificial Intelligence (AI)
  • Business
  • Cloud Computing
  • Cyber Security
  • Deep Learning
  • Ethics & Society
  • Machine Learning
  • Technology
Technology Hive

Welcome to Technology Hive, your go-to source for the latest insights, trends, and innovations in technology and artificial intelligence. We are a dynamic digital magazine dedicated to exploring the ever-evolving landscape of AI, emerging technologies, and their impact on industries and everyday life.

Categories

  • AI in Healthcare
  • AI Regulations & Policies
  • Artificial Intelligence (AI)
  • Business
  • Cloud Computing
  • Cyber Security
  • Deep Learning
  • Ethics & Society
  • Machine Learning
  • Technology

Recent Posts

  • Bending Spoons’ Acquisition of AOL Highlights Legacy Platform Value
  • The Consequential AGI Conspiracy Theory
  • MLOps Mastery with Multi-Cloud Pipeline
  • Thailand becomes one of the first in Asia to get the Sora app
  • Clinician-Centered Agentic AI Solutions

Our Newsletter

Subscribe Us To Receive Our Latest News Directly In Your Inbox!

We don’t spam! Read our privacy policy for more info.

Check your inbox or spam folder to confirm your subscription.

© Copyright 2025. All Right Reserved By Technology Hive.

No Result
View All Result
  • Home
  • Technology
  • Artificial Intelligence (AI)
  • Cyber Security
  • Machine Learning
  • AI in Healthcare
  • AI Regulations & Policies
  • Business
  • Cloud Computing
  • Ethics & Society
  • Deep Learning

© Copyright 2025. All Right Reserved By Technology Hive.

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?