-
-
Save quantra-go-algo/87799c56dee99d1266adc079f90dadbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# Example PnL data for an intraday trading strategy | |
pnl_per_trade = np.array([0.002, -0.005, 0.003, 0.004, -0.002, 0.001, -0.005, 0.002, -0.004, 0.006]) | |
# Number of trades (N) | |
num_trades = len(pnl_per_trade) | |
# Calculate Sharpe Ratio components | |
mean_pnl = np.mean(pnl_per_trade) | |
std_dev_pnl = np.std(pnl_per_trade, ddof=1) | |
# ddof=1 for sample standard deviation | |
# Calculate Sharpe Ratio | |
sharpe_ratio = np.sqrt(num_trades) * (mean_pnl / std_dev_pnl) | |
print(f"Mean of PnL: {mean_pnl}") | |
print(f"Standard Deviation of PnL: {std_dev_pnl}") | |
print(f"Sharpe Ratio: {sharpe_ratio}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment