Skip to content

Instantly share code, notes, and snippets.

View mbusigin's full-sized avatar

Matt Busigin mbusigin

View GitHub Profile
@mbusigin
mbusigin / copy-code.sh
Last active March 31, 2024 05:00
MacOS X shell script to recursively copy a code base into a single OSX paste buffer so we can paste it into GPT-4 or Claude.
#!/bin/sh
for x in `find . | grep -v .git | grep -v node_modules | grep -v '~' | grep -v package-lock.json | grep -v package.json | grep -v png | grep -v ico | grep -v "backend/db.sqlite" | grep -v .mp3 | grep -v .ogg | grep -v uploads | grep -v .db | grep -v .svg | grep -v log.txt`
do
echo "<code filename=\"$x\">"
cat $x
echo "</code>"
done | pbcopy
@mbusigin
mbusigin / cyclical_adjustment.R
Created September 7, 2017 00:42
R function to return cyclically-adjusted series using labour & GDP output gaps
labour_output_gap = function()
{
if ( exists("UNRATE") == FALSE ) { fred("UNRATE", environment()) }
if ( exists("NROU") == FALSE ) { fred("NROU", environment()) }
a = na.trim(na.locf(merge(UNRATE, NROU)))
a = a[endpoints(a)]
return(UNRATE - NROU)
}
@mbusigin
mbusigin / multiplot.R
Created September 2, 2017 17:13
R function for multiplotting (overplotting), either on the same, or differing axes.
multiplot = function(r, legend.loc="topleft", legend.cex=1, overplot=F, plotSecondAxis=F, s_lty=1, plotfunc=recplot, legend=T, pointMax=F, pointLast=F, legendLast=F, legendLastRoundDigits=0 )
{
r = na.omit(r)
for ( x in names(r) )
{
n = r[,x]
m = n
r[,x] = m
}
@mbusigin
mbusigin / 10y-oscillator.R
Created June 11, 2013 02:13
Generate chart with 10y yield oscillator (10y yield minus 260d moving average), +/- 1 stdev dashed lines
library(quantmod)
recplot = function(var, maintitle="", ylab="", ylim=NULL)
{
if ( exists("USRECD") == FALSE ) { getSymbols("USRECD", src="FRED", env=.GlobalEnv) }
a = na.locf(cbind(USRECD, var))
a = a[ .index(a) %in% .index(var) ]
par(oma=c(0,0,0,0))
par(xaxt="n", yaxt="n")
@mbusigin
mbusigin / MultiComboBox.js
Last active August 9, 2017 15:31
A multi-selection ComboBox for Qooxdoo.
/*
* This is a multi-select dropdown combobox deriviative!
*
* I had seen that some other folks had been looking for similar functionality, and although the Qooxdoo
* community was helpful, and explained what kinds of things they'd have to do to implement it, no finished class
* emerged. So, I had the need, and here it is. Please spin any improvements back to me!
*
* Matthew Busigin, CIO @ Hover Networks, Inc (mbusigin <at> hovernetworks <dot> com)
*
* We're overriding a bunch of stuff here:
@mbusigin
mbusigin / Cumulative Utility of Household Debt.R
Created December 15, 2013 16:51
Estimating the cumulative utility of household debt to national income.
library(quantmod)
getSymbols(c("GDP", "CMDEBT"), src="FRED")
plot(cumsum(na.omit(diff(GDP) - diff(CMDEBT))))
@mbusigin
mbusigin / Baa-spread-impute.R
Created October 10, 2016 22:00
Impute the Baa Spread using LQD, IEF and inverted 10s.
##
## Unfortunately, FRED no longer will be providing a whole bunch of interest rate series, principally Moody's.
## I use the Baa spread as the bedrock of my analysis, and although I can get a colleague to export the data from a BB terminal,
## I really needed to create a proxy so I can get data more quickly than that.
##
## The idea here is to impute the Baa spread from market inputs that we still have access to: 10s30s (because Baa spread has a
## duration spread embedded in it), the IEF/LQD ratio, and inverted 10s, in order to correct for convexity.
##
## The result is pretty decent: from 1986-2016, we get an R^2 of 0.9, RMSE of 0.26. I'm sure it could be improved upon, so let me know
## if you have any other ideas.
@mbusigin
mbusigin / llxc.R
Created December 10, 2013 02:53
Lead/Lag Cross Correlation between XTS objects
llxc = function( a, ll=-12:12, legend.loc="topleft", displayLegend=T, legend.cex=1.0, overplot=F )
{
if ( ncol(a) < 2 )
{
print( "Not enough columns")
return;
}
a = na.omit(a)
#!/usr/bin/perl -W
# From populationpyramid.net's data source https://github.com/madewulf/PopulationPyramid.net/tree/master/static/data/generated
# Takes the JSON as stdin, returns a CSV with the M/O ratio
use strict;
use JSON;
use Data::Dumper;
my $json = JSON->new;
function()
{
if ( exists("CPIAUCSL") == FALSE ) { fred("CPIAUCSL", environment()) }
if ( exists("MCOILWTICO") == FALSE ) { fred("MCOILWTICO", environment()) }
if ( exists("CUSR0000SEHC") == FALSE ) { fred("CUSR0000SEHC", environment()) }
recplot( (MCOILWTICO/CPIAUCSL)*-1.5736 + Delt(CUSR0000SEHC, k=12*5)* 6.5426 + 1.5954 )
lines( cagr(dlag(CPIAUCSL, k=12*5), 5), col="dodgerblue3" )
}