Skip to content

Instantly share code, notes, and snippets.

View IanMadlenya's full-sized avatar

Ian Madlenya IanMadlenya

View GitHub Profile
@IanMadlenya
IanMadlenya / Recessions.R
Created September 5, 2018 13:24 — forked from zachmayer/Recessions.R
Forecasting Recessions
#Code to re-create John Hussman's Recession warning index
#http://www.hussmanfunds.com/wmc/wmc110801.htm
#R code by Zach Mayer
rm(list = ls(all = TRUE)) #CLEAR WORKSPACE
library(quantmod)
#################################################
# 1. Credit spreads
#################################################
# This simple script gathers data of stocks and uses it to simulate future price for
# 1 year (255 days). Then it optimises the portfolio for risk and returns using risk
# measures such as VaR
#
# Note: tickers are all lower case, such as "aapl"
from scipy.special import ndtri
import matplotlib.pyplot as plt
import numpy as np
import itertools
@IanMadlenya
IanMadlenya / trendline-orders.mq4
Created August 22, 2018 13:10 — forked from currencysecrets/trendline-orders.mq4
Entries and exits now in one script
string VERSION = "TL BO 1.0";
extern int EXT_ATR = 300; // ATR(x)
extern double EXT_ATR_INI_STOP = 0.1; // additional buffer to add beyond the initial stop
extern int EXT_LOOKBACK = 3; // number of bars to find highest high/lowest low
extern double EXT_RISK_MINAMT = 50; // dollar value of the minimum amount to risk per trade
extern double EXT_RISK_DIVISOR = 10; // AccountBalance/X = risk per trade
extern int EXT_MAX_SLIP = 10; // maximum points of slippage allowed for order 10 = 1 pip
extern double EXT_ATR_TRAILSTOP = 2; // multiple for trailing the market ATR(EXT_ATR) * X
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@IanMadlenya
IanMadlenya / Blockchain security research.md
Created April 13, 2018 21:48 — forked from trietptm/Blockchain security research.md
Open-source blockchain security research (contributions welcome!)

What is a blockchain?

  • Distributed ledger system; for tracking the transfer of tokens (currency, data of any type).
  • A cross between economics, cryptography, and the internet.
    • Side note- if you ever wanted a financial incentive to get involved in cryptography, this is it.
  • A blockchain is literally a chain of blocks, where each block contains a list of transactions that everyone agrees have occurred.
    • Each block builds upon all the ones before it.

A blockchain is literally a chain of blocks

@IanMadlenya
IanMadlenya / GFW_WS.md
Created February 25, 2018 18:50 — forked from namessanti/GFW_WS.md
EDU: Global Forest Watch
import urllib2
import json
import csv
import pandas as pd
import numpy as np
import decimal
D = decimal.Decimal
url = "https://www.wework.com/locations/all"
data = urllib2.urlopen(url).read()
@IanMadlenya
IanMadlenya / ornsteinUhlenbeck.m
Created November 26, 2017 08:54 — forked from leon-nn/ornsteinUhlenbeck.m
Ornstein-Uhlenbeck Process
%% Ornstein-Uhlenbeck Process
% ...from the paper "FLUCTUATING SYNAPTIC CONDUCTANCES RECREATE IN
% VIVO-LIKE ACTIVITY IN NEOCORTICAL NEURONS"
% The stochastic differential equation is given by:
% dx/dt = 1/tau * (mu - x) + sqrt(D) * chi(t)
% where:
% x is the random variable
% D is the amplitude of the stochastic component
% chi(t) is a normally-distributed (zero-mean) noise source
% tau is the time constant (tau = 0 gives white noise, tau > 0 gives
@IanMadlenya
IanMadlenya / OrnsteinUhlenbeck.py
Created November 26, 2017 08:53 — forked from StuartGordonReid/OrnsteinUhlenbeck.py
Ornstein Uhlenbeck Stochastic Process
import math
import numpy
import random
import decimal
import scipy.linalg
import numpy.random as nrand
import matplotlib.pyplot as plt
"""
Note that this Gist uses the Model Parameters class found here - https://gist.github.com/StuartGordonReid/f01f479c783dd40cc21e
import Quandl as q
import pandas as pd
x = str(raw_input("Enter a symbol"))
x = x.capitalize()
symbol = 'SI/'+ x + '_SI'
print symbol
sym = q.get(symbol, authtoken="Hbkxrvo898cZ42h-VrCe")
ShIn = sym["Days to Cover"]
med = ShIn.median()
print med