Skip to content

Instantly share code, notes, and snippets.

View josephdunn's full-sized avatar

Joseph Dunn josephdunn

View GitHub Profile
hello milktrader!
library(quantmod)
library(PerformanceAnalytics)
getSymbols('HEIA.AS', src='yahoo')
Return.cumulative(Return.calculate(get('HEIA.AS')['2010-12-31::']))
#!/usr/bin/ruby
def winloss
if rand(2) == 1
return true
else
return false
end
end
#!/usr/bin/ruby
def winloss
if rand(2) == 1
return true
else
return false
end
end
require 'rubygems'
require 'eventmachine'
require 'em-http-request'
require 'json'
EventMachine.run {
bid = 0.0
ask = 0.0
spread = 0.0
data <- read.table('TrAEX.xls', header=TRUE, sep='\t', skip=5, stringsAsFactors=FALSE)
data.xts <- xts(data$Quote, order.by=as.POSIXlt(data$Date...time, format='%H:%M:%S'))
require(quantstrat)
# clean up
rm(list=ls(all=TRUE, pos=.blotter), pos=.blotter)
rm(list=ls(all=TRUE, pos=.instrument), pos=.instrument)
rm(list=ls(all=TRUE, pos=.strategy), pos=.strategy)
# set initial values
initDate <- '2011-08-05 06:00:00'
initEq <- 10000
djbutton = $($('a').get(0));
var djit = function() {
if (djbutton.css('display') != 'none') {
e = new jQuery.Event('click');
e.pageX=1;
e.pageY=1;
turntable.lastMotionTime=new Date().getTime();
djbutton.hover().trigger(e);
console.log(new Date() + ' -- triggered DJ');
} else {
require(xts)
data(sample_matrix)
dates <- as.POSIXct(rownames(sample_matrix), format = "%Y-%m-%d")
dayLookup <- 1:7
names(dayLookup) <- c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
datesDays <- dayLookup[weekdays(dates, abbreviate = TRUE)]
print(datesDays)
blah <- xts(cbind(sample_matrix, dow =datesDays), order.by = dates)
blah[blah$dow!=5]
cat('hi\n')
read.csv(file('stdin'), header=FALSE)
print(information)
cat('hi again\n')