Skip to content

Instantly share code, notes, and snippets.

View chipkent's full-sized avatar

Chip Kent chipkent

View GitHub Profile
@chipkent
chipkent / example_gist.py
Created June 23, 2020 16:11
Example Gist
from deephaven.TableTools import emptyTable
t = emptyTable(10).update("X=i")
# 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:
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
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
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
@chipkent
chipkent / covariance_reproducer.jl
Created July 19, 2016 03:48
Covariance Bug reproducer
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 ) =
module XYZ
export
SERDataStore
abstract AbstractDataStore{K,V} <: Associative{K,V}
immutable SERDataStore{K<:AbstractString,V} <: AbstractDataStore{K,V}
rootdir::AbstractString #TODO rename