This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suppressMessages(require(quantstrat)) | |
Sys.setenv(TZ='America/New_York') | |
# define variables | |
sym <- 'AAPL' | |
initDate <- '2013-01-22' | |
endDate <- '2013-02-08' | |
port <- 'z' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from math import pi, log | |
import pylab | |
from scipy import fft, ifft | |
from scipy.optimize import curve_fit | |
i = 10000 | |
x = np.linspace(0, 3.5 * pi, i) | |
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 * | |
np.random.randn(i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(quantmod) | |
getSymbols('SPY') | |
expiry_idx <- options.expiry(SPY) | |
for (i in 2:length(expiry_idx)-1) | |
{ | |
period_start <- index(SPY[expiry_idx[i] + 1]) | |
period_end <- index(SPY[expiry_idx[i + 1]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
class BidAskParseError(Exception): pass | |
import datetime | |
from twisted.internet import reactor | |
from twisted.protocols.basic import LineReceiver | |
from twisted.internet.protocol import ClientFactory | |
class ExampleClient(LineReceiver): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(RQuantLib) | |
goog <- list(spot = 570.225, | |
yield = 0, | |
rate = 0.05, | |
maturity = as.numeric(as.Date('2012-06-29') - Sys.Date()) / 365, | |
volatility = 0.3038834, # annualizedVol() | |
chain = matrix(c(550.00, 21.95, | |
555.00, 17.40, | |
560.00, 13.30, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible " We're running Vim, not Vi! | |
syntax on " Enable syntax highlighting | |
filetype on " Enable filetype detection | |
filetype indent on " Enable filetype-specific indenting | |
filetype plugin on " Enable filetype-specific plugins |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
running.acf.max <- function(returns, window=100, nlags=5, plot=TRUE, main='') | |
{ | |
clevel <- qnorm (0.5 + 0.95/2) / sqrt(window) | |
series <- rollapply(returns, window, align='right', by=1, function(w) | |
{ | |
acfs <- pacf(coredata(w), lag.max=nlags, plot=FALSE)$acf | |
cum <- cumsum(acfs) | |
low <- min(cum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<div class='navbar navbar-fixed-top'> | |
<div class='navbar-inner'> | |
<div class='container'> | |
<a class='btn btn-navbar' data-target='.nav-collapse' data-toggle='collapse'> | |
<span class='icon-bar'></span> | |
<span class='icon-bar'></span> | |
<span class='icon-bar'></span> | |
</a> | |
<a class='brand' href='#'>Frooom</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RocSys = function(x, nEMA, nROC, nTREND) | |
{ | |
rocema = ROC(EMA(x, nEMA), nROC) | |
trend = EMA(x, nTREND) | |
signal = | |
ifelse(rocema>0 & lag(rocema)<=0, ifelse(x>trend, 1, 0), | |
ifelse(rocema<0 & lag(rocema)>=0, ifelse(x<trend, -1, 0), | |
NA) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chart_Series <- function(x, | |
name=deparse(substitute(x)), | |
type="candlesticks", | |
subset="", | |
TA="", | |
pars=chart_pars(), theme=chart_theme(), | |
clev=0) { |