Skip to content

Instantly share code, notes, and snippets.

>>dbGetQuery(wrds, wrap("SELECT periodEndDate, companyId, TotTermLoans,
periodTypeName, formType
FROM CIQ.WRDS_SUMMARY
WHERE companyId=18527 AND YEAR(periodEndDate)=2008
ORDER BY periodEndDate, formType"))
periodEndDate companyId TotTermLoans periodTypeName formType
1 2008-03-31 18527 NA YTD 6-K
2 2008-03-31 18527 NA YTD 6-K
3 2008-03-31 18527 NA LTM 6-K
>dbGetQuery(wrds, "SELECT * from CIQ.CIQCOMPANYINDUSTRYTREE WHERE companyId=18527")
companyIndustryId companyId subTypeId primaryFlag charTypeId
1 4029005 18527 3000000 1 3
2 4029006 18527 3010000 1 3
3 4029007 18527 3040000 0 3
4 4029008 18527 3041000 0 3
5 4029009 18527 3041500 0 3
6 4029010 18527 3041510 0 3
7 4029011 18527 3041511 0 3
8 12816597 18527 3050000 1 3
Provisions of the Company's Memorandum of Association which, by Virtue
of Section 28 of the Companies Act of 2006, are to be Treated as
Provisions of the Company's Articles of Association 17 Approve That a
General Meeting Other For For Management Than an Annual General Meeting
May Be Called on Not Less Than 14 Clear Days' Notice -
-----------------------------------------------------------------------
--------- BALFOUR BEATTY PLC Ticker: BBY Security ID: G3224V108 Meeting
Date: MAY 14, 2009 Meeting Type: Annual Record Date: # Proposal Mgt Rec
Vote Cast Sponsor 1 Accept Financial Statements and For For Management
Statutory Reports 2 Approve Remuneration Report For For Management 3
@erikcs
erikcs / cal.py
Last active September 17, 2016 08:16
get calender data
#!/usr/bin/env python
import bs4
import requests
import re
import icalendar
import pytz
from datetime import datetime
import os
def datestr_to_dateobj(datestr):
function score(theta::Array, y::Array)
T = size(y, 1)
h = zeros(T)
eps = y .- theta[1]
h[1] = theta[2]^2 / (1 - theta[3]^2 - theta[4]^2)
if h[1] < 0
return -oftype(h[1], Inf)
end
for t=2:T
h[t] = theta[2]^2 + theta[3]^2 * eps[t-1]^2 + theta[4]^2 * h[t-1]
@erikcs
erikcs / garchrec.jl
Last active March 1, 2017 23:45
Recursive GARCH
function ht(theta, Y, t)
if t == 1
return theta[2]^2 / (1 - theta[3]^2 - theta[4]^2)
end
theta[2]^2 + theta[3]^2 * (Y[t-1] - theta[1])^2 + theta[4]^2 * ht(theta, Y, t-1)
end
function score(theta, Y, t)
var = ht(theta, Y, t)
@erikcs
erikcs / combine.R
Last active November 27, 2016 23:15
combine stuff with data.table
library(readr)
library(data.table)
# convert file encoding before reading into R AND remove all the commas
# $ for file in *.txt; do iconv -f UTF-16LE -t UTF-8 "$file" | sed 's/,//g' > "$file.utf8.txt"; done
process = function(df) {
# remove duplicate columns
df[, grep('.*_[0-9]$', names(df)) := NULL]
# remove all ...yr columns
@erikcs
erikcs / reg.R
Created December 19, 2016 19:27
source('R/penfmbr.R')
library(stargazer)
factors = read.csv('data/factors.csv')[, -1]
returns = read.csv('data/returns.csv')[, -1]
# Models
fmb_mkt = fmb(factors[, 1, drop = FALSE], returns)
fmb_ff = fmb(factors[, c(1, 2, 3)], returns)
fmb_ch = fmb(factors, returns)
@erikcs
erikcs / cd.py
Last active December 23, 2016 00:02
Toy coordinate descent for lasso regression
# Toy coordinate descent for Lasso regression
import numpy as np
import warnings
def _normalise(X, y):
Xbar = X.mean(axis=0)
Xstd = X.std(axis=0)
ybar = y.mean(axis=0)
ystd = y.std()
@erikcs
erikcs / rcheck.py
Last active January 12, 2017 19:23
scikit-learn random_state check
# rcheck.py: check sklearn test files for class/function invocations that
# lack the optional `random_state` argument. For each file a missing invocation
# is found, prints out the class/function name followed by line number(s)
#
# Usage (from scikit-learn base directory)
# $ find * -type f | grep "/test_.*py$" | python rcheck.py
import fileinput
import inspect
import importlib
import re