Skip to content

Instantly share code, notes, and snippets.

View armstrtw's full-sized avatar
🏠
Working from home

Whit Armstrong armstrtw

🏠
Working from home
  • Morgan Stanley Investment Management
  • Greenwich, CT
View GitHub Profile
@armstrtw
armstrtw / increment.jl
Created May 2, 2019 01:10
julia generic
## working strongly typed version
# function incr(d::Dict{String,Float64},k::String,v::Float64)
# if haskey(d,k)
# if (d[k] += v)==0
# delete!(d, k)
# end
# else
# d[k] = v
# end
# end
@armstrtw
armstrtw / getFieldInfoSample.cpp
Created February 9, 2016 21:27
assign into dataframe
// [[Rcpp::export]]
Rcpp::List fieldInfo_Impl(SEXP con_, std::vector<std::string> fields) {
Session* session =
reinterpret_cast<Session*>(checkExternalPointer(con_, "blpapi::Session*"));
// get the field info
std::vector<FieldInfo> fldinfos(getFieldTypes(session, fields));
std::vector<std::string> colnames {"id","mnemonic","datatype","ftype"};
std::vector<RblpapiT> res_types(4,RblpapiT::String);
@armstrtw
armstrtw / bdh.test.R
Created June 25, 2015 13:50
test of Rbbg speed vs Rblpapi speed for a simple bdh call
tickers <- c("ATVI UW Equity","ADBE UW Equity","AKAM UW Equity","ALXN UW Equity","ALTR UW Equity","AMZN UW Equity","AMGN UW Equity","APOL UW Equity","AAPL UW Equity","AMAT UW Equity","ADSK UW Equity","ADP UW Equity","AVGO UW Equity","BIDU UW Equity","BBBY UW Equity","BIIB UW Equity","BMC UW Equity","BRCM UW Equity","CA UW Equity","CELG UW Equity","CERN UW Equity","CHRW UW Equity","CHKP UW Equity","CSCO UW Equity","CTXS UW Equity","CTSH UW Equity","CMCSA UW Equity","COST UW Equity","DELL UW Equity","XRAY UW Equity","DTV UW Equity","DLTR UW Equity","EBAY UW Equity","EA UW Equity","EXPE UW Equity","EXPD UW Equity","ESRX UW Equity","FFIV UW Equity","FAST UW Equity","FISV UW Equity","FLEX UW Equity","FOSL UW Equity","GRMN UW Equity","GILD UW Equity","GOOG UW Equity","GMCR UW Equity","HSIC UW Equity","INFY UW Equity","INTC UW Equity","INTU UW Equity","ISRG UW Equity","KLAC UW Equity","MDLZ US Equity","LRCX UW Equity","LINTA UW Equity","LIFE UW Equity","LLTC UW Equity","MRVL UW Equity","MAT UW Equity","MXIM UW Equit
@armstrtw
armstrtw / swap.current.curve.cpp
Created February 11, 2014 18:24
quantlib forward rate does not match fairRate
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#include <iostream>
#include <vector>
#include <ql/quantlib.hpp>
using namespace QuantLib;
int main() {
Date todaysDate(10, Feb, 2014);
Settings::instance().evaluationDate() = todaysDate;
@armstrtw
armstrtw / aws.estimatePi.R
Created October 17, 2011 12:07
deathstar example
library(AWS.tools)
library(rzmq)
estimatePi <- function(seed) {
set.seed(seed)
numDraws <- 1e6
r <- .5
x <- runif(numDraws, min=-r, max=r)