Skip to content

Instantly share code, notes, and snippets.

Avatar

brian piercy bjpcjp

View GitHub Profile
@bjpcjp
bjpcjp / metrics.py
Created Jan 15, 2022 — forked from bfan1256/metrics.py
5 Performance Metrics for Trading Algorithms and Investment Portfolios
View metrics.py
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
@bjpcjp
bjpcjp / housingScrape.py
Created Feb 8, 2018 — forked from theriley106/housingScrape.py
Scraping Valid Addresses from all US ZipCodes
View housingScrape.py
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import requests
import bs4
import zipcode
import threading
import re
import json
import time
@bjpcjp
bjpcjp / denominator-snippet.rb
Created Sep 12, 2012 — forked from rweald/denominator-snippet.rb
Code Snippets for Simple Linear Regression Using Ruby Blog Post
View denominator-snippet.rb
denominator = @xs.reduce(0) do |sum, x|
sum + ((x - x_mean) ** 2)
end