Skip to content

Instantly share code, notes, and snippets.

@schalekamp
schalekamp / rjdbc.md
Created November 3, 2021 18:23
use RJDBC to connect to Clickhouse

First you have to make sure you have the java JDK installed.
In a terminal (ubuntu) do this.

sudo apt-get install default-jdk

Then in RStudio you have to install rJava and RJDBC

install.packages("rJava")
install.packages("RJDBC")
@schalekamp
schalekamp / RiskAdjustedReturnMetrics.py
Created October 5, 2015 06:58 — forked from StuartGordonReid/RiskAdjustedReturnMetrics.py
Measured of Risk-adjusted Return
import math
import numpy
import numpy.random as nrand
"""
Note - for some of the metrics the absolute value is returns. This is because if the risk (loss) is higher we want to
discount the expected excess return from the portfolio by a higher amount. Therefore risk should be positive.
"""
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import cvxopt as opt
from cvxopt import blas, solvers
import pandas as pd
import pandas.io.data as web
import datetime
# Turn off progress printing
@schalekamp
schalekamp / factor_analysis.py
Created June 2, 2015 10:20
simple factor analysis using python/pandas
# basic factor analysis
# http://blog.alphaarchitect.com/2015/05/28/basic-factor-analysis-simple-tools-to-understand-what-drives-performance/
import pandas as pd
import pandas.io.data as web
import datetime, re, copy
import numpy as np
import statsmodels.formula.api as sm
start = datetime.date(2000,1,1)
@schalekamp
schalekamp / yahoo
Last active August 29, 2015 14:08 — forked from szs8/yahoo
#!/usr/bin/env python
import dateutil
from datetime import date, datetime
import numpy as np
import pandas as pd
import requests
class YahooException(Exception):
#!/bin/sh
mkdir ~/down/
cd ~/down/
sudo apt-get install build-essential
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz
tar -xzf Python-2.7.2.tgz
cd Python-2.7.2
sudo apt-get install libsqlite3-dev zlib1g-dev libncurses5-dev
sudo apt-get install libgdbm-dev libbz2-dev libreadline5-dev
sudo apt-get install libssl-dev libdb-dev
#make sure llvm-3.3 is installed! + numba requirements
sudo apt-get install llvm cython python-pip llvm-3.3
sudo LLVM_CONFIG_PATH=/usr/lib/llvm-3.3/bin/llvm-config pip install llvmpy
sudo pip install numba