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
from deephaven.TableTools import emptyTable | |
t = emptyTable(10).update("X=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
# add JDK to path (otherwise jnius gives DLL load error) | |
import os | |
os.environ['PATH'] = os.environ['PATH'] + ";C:\\Program Files\\Java\jdk1.8.0_72\\jre\\bin\\server" | |
os.environ['PATH'] = os.environ['PATH'] + ";C:\\Program Files\\Java\jdk1.8.0_60\\jre\\bin\\server" | |
print(os.environ['PATH']) | |
# add jpy to the python path | |
import sys | |
if sys.version_info.major == 2 and sys.version_info.minor == 7: |
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
using Distributions | |
using BenchmarkTools | |
function lratio2{FT}(dd::Dict{FT,Tuple{Float64, ContinuousUnivariateDistribution}}) | |
num::Float64 = 0.0 | |
denom::Float64 = 0 | |
for (k, v) in dd |
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
using NamedArrays | |
function compute_betas{T <: AbstractFloat}(factors::AbstractArray{T,2}, returns::AbstractArray{T,2}) | |
# make sure the dimension labels match | |
if typeof(factors) <: NamedArrays.NamedArray && typeof(returns) <: NamedArrays.NamedArray | |
@assert NamedArrays.names(factors,1) == NamedArrays.names(returns,1) | |
@assert factors.dimnames[1] == returns.dimnames[1] | |
end |
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
using DataFrames | |
symbol = ["A","A","A","A","A","B","B","B","B","B"] | |
date = ["d1","d2","d3","d4","d5","d1","d2","d3","d4","d5"] | |
value = Float64[1,2,3,4,5,6,7,8,9,10] | |
df = DataFrame(S=symbol,D=date,V=value) | |
df[2,3] = NA | |
df[8,3] = 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
using NamedArrays | |
function compute_covariance{T <: AbstractFloat}( M::AbstractArray{T,2}, I::AbstractArray{T,2}) | |
return make_positive_definite( (M'*M) ./ (I'*I) ) | |
end | |
make_positive_definite{T <: AbstractFloat}( m::AbstractArray{T,2}, epsilon::Real=1e-8 ) = nearPSD(m,epsilon) | |
nearPSD{T <: AbstractFloat}( A::NamedArrays.NamedArray{T,2}, epsilon::Real=1e-12 ) = |
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
module XYZ | |
export | |
SERDataStore | |
abstract AbstractDataStore{K,V} <: Associative{K,V} | |
immutable SERDataStore{K<:AbstractString,V} <: AbstractDataStore{K,V} | |
rootdir::AbstractString #TODO rename |