Skip to content

Instantly share code, notes, and snippets.

View bfan1256's full-sized avatar
😶

Brandon Fan bfan1256

😶
View GitHub Profile
@bfan1256
bfan1256 / metrics.py
Last active January 15, 2022 18:06
5 Performance Metrics for Trading Algorithms and Investment Portfolios
from blankly import Alpaca, CoinbasePro # supports stocks, crypto, and forex
import numpy as np
from math import sqrt
def cagr(start_value: float, end_value: float, years: int):
return (end_value / start_value) ** (1.0 / years) - 1
def sharpe(account_values: np.array, risk_free_rate, annualize_coefficient):
diff = np.diff(account_values, 1) / account_values[1:] # this gets our pct_return in the array
@bfan1256
bfan1256 / cloudSettings
Created July 18, 2017 21:35
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-07-18T21:35:48.318Z","extensionVersion":"v2.8.2"}