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 socket | |
import struct | |
def quadtolong(ip): | |
return struct.unpack('!L',socket.inet_aton(ip))[0] | |
def longtoquad(long): | |
return socket.inet_ntoa(struct.pack('!L', long)) | |
def inc_ip(ip): |
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
type InitFunction func() (interface{}, error) | |
type ConnectionPoolWrapper struct { | |
size int | |
conn chan interface{} | |
} | |
/** | |
Call the init function size times. If the init function fails during any call, then | |
the creation of the pool is considered a failure. |
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
/** | |
This function creates a connection to the database. It shouldn't have to know anything | |
about the pool, It will be called N times where N is the size of the requested pool. | |
*/ | |
func initCirrusConnections() (interface{}, error) { | |
dbserver, _ := configFile.GetString("default", "dbserver") | |
dbuser, _ := configFile.GetString("default", "dbuser") | |
dbpass, _ := configFile.GetString("default", "dbpass") | |
db := autorc.New("tcp", "", dbserver, dbuser, dbpass) |
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
# Setup your home directory to handle a go installation | |
mkdir ~/go | |
cd ~/ | |
# Grab and untar the binary the binary | |
# If you have a 64bit system, use http://go.googlecode.com/files/go1.0.2.linux-amd64.tar.gz | |
wget http://go.googlecode.com/files/go1.0.2.linux-386.tar.gz | |
tar -xzf go1.0.2.linux-386.tar.gz | |
# Setup your environment to handle the root Go install |
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
package main | |
import "fmt" | |
import "encoding/json" | |
import "net/http" | |
import "bytes" | |
type Test struct{ | |
Name string | |
Token string |
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
# | |
# Skeleton code, don't use this because it isn't going to work for you | |
""" | |
This is heavily taken from the MovingAverage | |
""" | |
import numpy | |
import talib | |
from numbers import Number |
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
''' | |
As usual, this is a wallofcode beta, don't use this in real life | |
''' | |
import numpy | |
import talib | |
from talib.abstract import Function | |
from numbers import Number | |
from collections import defaultdict |
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
# Verify that our benchmark msgpack file is up to date | |
bm_list = msgpack.loads(fp_bm.read()) | |
bm_date, _ = bm_list[len(bm_list)-1] | |
last_date = datetime(bm_date[0], bm_date[1], bm_date[2]) | |
today = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0) | |
if last_date < today-timedelta(days=1): | |
update_benchmarks(last_date) | |
fp_bm = get_datafile('benchmark.msgpack', "rb") |
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 | |
from talib.abstract import Function | |
from numbers import Number | |
from collections import defaultdict | |
from zipline.transforms.utils import EventWindow, TransformMeta | |
class TATransform(object): | |
""" |
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
@batch_transform | |
def bbands_transform(data, sid1): | |
print "bbands_transform()" | |
print data | |
inputs = {} | |
inputs['high'] = numpy.asarray([v for v in data.high[sid1]]) | |
inputs['open'] = numpy.asarray([v for v in data.open[sid1]]) | |
inputs['low'] = numpy.asarray([v for v in data.low[sid1]]) | |
inputs['close'] = numpy.asarray([v for v in data.close[sid1]]) |
OlderNewer