Skip to content

Instantly share code, notes, and snippets.

View scubamut's full-sized avatar

scubamut

  • Individual
  • Johannesburg and London
View GitHub Profile
import sys
if 'ziptrader36' in sys.path[1]:
active_kernel = 'ziptrader36'
elif 'zipline-reloaded' in sys.path[1]:
active_kernel = 'zipline-reloaded'
else:
active_kernel = 'not ziptrader36 or zipline-reloaded'
@scubamut
scubamut / vscode_shortcuts.md
Created June 9, 2020 14:44 — forked from bradtraversy/vscode_shortcuts.md
Helpful shortcuts for VSCode

VSCode Shortcuts

List of helpful shortcuts for faster coding

If you have any other helpful shortcuts, feel free to add in the comments of this gist :)

Official List of all commands

import talib
# routine to get args required for talib function
def find_talib_args(func):
s = eval('talib.' + func + '.__doc__')
try:
s = s.splitlines()[0].split('(')[1].split(')')[0].replace('[','').replace(']','').replace('?','')
return s.split(',')
except:
from fintools import endpoints
# end_points prices (in this case, monthly)
end_points = endpoints(period='M', trading_days=prices_d.index)
prices_m = prices_d.loc[end_points]
prices_m[:2]
etfs = [
# ----------------------------------------- #
# SPDRS/State Street Global Advisors (SSGA)
'XLY', # Select SPDR U.S. Consumer Discretionary
'XLP', # Select SPDR U.S. Consumer Staples
'XLE', # Select SPDR U.S. Energy
'XLF', # Select SPDR U.S. Financials
'XLV', # Select SPDR U.S. Healthcare
'XLI', # Select SPDR U.S. Industrials
'XLB', # Select SPDR U.S. Materials
import matplotlib.pylab as plt
plt.rc('figure', figsize=(8, 5))
plt.style.use('seaborn-dark')
import pandas_datareader.data as pdr
import matplotlib.pyplot as plt
import pandas as pd
from datetime import datetime, timezone
import pytz
import talib
import itable
import ffn
from fintools import get_DataArray,compute_weights_RS_DM,compute_weights_PMA,\
import pandas_datareader.data as pdr
import matplotlib.pyplot as plt
import pandas as pd
from datetime import datetime, timezone
import pytz
import talib
import itable
import ffn
from fintools import get_DataArray,compute_weights_RS_DM,compute_weights_PMA,\
##################################################
# DUAL MOMENTUM
###############
strategy_prices = strategy_values.dropna().copy()
# need to add prices for cash_proxy and, if necessary, risk_free
d = get_DataArray(['FFXSX'],start,end).to_pandas().transpose(1,2,0)
strategy_prices['FFXSX'] = d[:,:,'adj close'].loc[s_prices.index]
"""
MSMP v6.00 Major Upgrade
- single RS momentum portfolio with downside protection
- RAA - Robust Asset Allocation (4 portfolios)
- minimumn correlation strategy
- downside protection strategy based on Alpha Architect DPM Rule: 50% TMOM, 50% MA
- RS with downside protection, single portfolio, EtfReplay-like ranking formula
- RS with 2 portfolios based on EtfReplay ranking model
- EAA - Elastic Asset Allocation