Skip to content

Instantly share code, notes, and snippets.

private Contract createBag(int conidOne, int conidTwo) {
ComboLeg leg1 = new ComboLeg(); // for the first leg
ComboLeg leg2 = new ComboLeg(); // for the second leg
Vector addAllLegs = new Vector();
log.info("conid in bag "+conidOne);
leg1.m_conId = conidOne;
leg1.m_ratio = 1;
leg1.m_action = "BUY";
leg1.m_exchange = "NYMEX";
@axs
axs / spline
Created August 18, 2011 21:12
Spline
class Spline{
function Spline($x,$y){
$this->hold = array();
$this->hold[0] = $x;
$this->hold[1] = $y;
$y2 = Derivative2($this->hold[0],$this->hold[1]);
$this->hold[2] = $y2;
}
@axs
axs / gist:1155227
Created August 18, 2011 21:14
hurst
def hurst (x):
"""
takes log returns
hurst exponent is you measure of "trendiness".
if it is going back to 0.5 that would mean your serie is loosing trendiness and behaves as a random walk again.
(hurst >0.5 -> autocorrelation,ie trends; hurst<0.5 -> negative aurocorrelation,ie mean reverting behavior)
"""
N=len(x)
@axs
axs / impliedPricer
Created November 28, 2011 20:53
implied pricer
import matplotlib.pyplot as plt
import sys
import networkx as nx
"""
A, B, C, AB, AC, BC.
@axs
axs / bgcloudrollout.py
Created December 28, 2011 19:51
Backgammon cloud rollout
import cloud
# http://www.picloud.com
def rollout (gnubgfile):
import commands
fh=cloud.files.getf(gnubgfile)
cmds = fh.readlines()
pp=open('tmpfile.txt','w')
pp.writelines(cmds)
pp.close()
@axs
axs / markettopology.py
Created December 30, 2011 20:42
market-topology.com wsdl example
"""
http://www.market-topology.com
wsdl service
"""
from suds.client import Client
url='https://api.impactopia.com/ImpactopiaWS0.5/ImpactopiaWS?wsdl'
client = Client(url)
client.service.login('blahlogin','blahpass')
client.service.getStock('AAPL')
@axs
axs / MatchEquity
Created January 2, 2012 19:29
Backgammon MatchEquity formulas
import numpy as np
class MatchEquity(object):
def __init__ (self):
#rockwell kazaross match equity table
self.met = np.matrix([ [ 0, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],
[ 100, 50, 68, 75, 81, 84, 89, 91, 93, 94, 96, 97, 98, 98, 98, 99, 50],
[ 100, 32, 50, 60, 67, 74, 80, 84, 87, 90, 92, 94, 95, 96, 97, 98, 49],
@axs
axs / ddbkup.py
Created November 14, 2012 00:16
dropbox backup
from PyQt4 import QtCore,QtGui
import sys,os,signal
from dropbox import client, rest, session
class ddbackup(object):
def __init__ (self):
# Get your app key and secret from the Dropbox developer website
self.APP_KEY = 'xsdU786dsfsf'
self.APP_SECRET = 'sfsLO3fsf'
@axs
axs / gist:4327984
Created December 18, 2012 13:30
Cloud Option Calculator
import cloud
from QuantLib import *
import datetime,dateutil
def OptionCalculator(strike,und,opttype,vola,expiry):
dateoffset = 0
# global data
today = datetime.date.today() + datetime.timedelta(days= dateoffset)
from nose import with_setup # optional
from unnecessary_math import multiply
def setup_module(module):
print ("") # this is to get a newline after the dots
print ("setup_module before anything in this file")
def teardown_module(module):