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
| library(IBrokers) | |
| library(twsInstrument) | |
| tws <- twsConnect(host='127.0.0.1', port=4001) | |
| contract <- getContract("EUR.USD") | |
| reqHistoricalData( tws, contract, verbose=T, whatToShow="BID" ) | |
| reqHistoricalData( tws, contract, verbose=T, whatToShow="ASK" ) | |
| twsDisconnect(tws) |
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
| #sources | |
| #https://www.quandl.com/CURRFX/USDCAD-Currency-Exchange-Rates-USD-vs-CAD | |
| #curl https://www.quandl.com/api/v1/datasets/CURRFX/USDCAD.csv -o /tmp/USDCAD.csv | |
| #https://www.quandl.com/DOE/RWTC-WTI-Crude-Oil-Spot-Price-Cushing-OK-FOB | |
| #curl https://www.quandl.com/api/v1/datasets/DOE/RWTC.csv -o /tmp/RWTC.csv | |
| library(xts) | |
| library(ggplot2) | |
| usd.cad <- read.csv("/tmp/USDCAD.csv") |
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
| ############################################################ | |
| ## Content of the Traders in Financial Futures (TFF) Report | |
| ## http://www.cftc.gov/ucm/groups/public/@commitmentsoftraders/documents/file/tfmexplanatorynotes.pdf | |
| ############################################################ | |
| # Dealer/Intermediary | |
| # These participants are what are typically described as the "sell side” of the market. Though they | |
| # may not predominately sell futures, they do design and sell various financial assets to clients. | |
| # They tend to have matched books or offset their risk across markets and clients. Futures | |
| # contracts are part of the pricing and balancing of risk associated with the products they sell and | |
| # their activities. These include large banks (U.S. and non-U.S.) and dealers in securities, swaps |
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
| #curl http://www.dailyfx.com/files/Calendar-02-01-2015.csv -o /tmp/Calendar-02-01-2015.csv | |
| cal <- read.csv("/tmp/Calendar-02-01-2015.csv") |
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
| library(ggplot2) | |
| #curl 'http://research.stlouisfed.org/fred2/series/PAYEMS/downloaddata' --data 'form%5Bnative_frequency%5D=Monthly&form%5Bunits%5D=lin&form%5Bfrequency%5D=Monthly&form%5Baggregation%5D=Average&form%5Bobs_start_date%5D=1939-01-01&form%5Bobs_end_date%5D=2015-01-01&form%5Bfile_format%5D=csv&form%5Bdownload_data_2%5D=' -o /tmp/PAYEMS.csv | |
| nfp <- read.csv("/tmp/PAYEMS.csv") | |
| nfp$DATE <- as.Date( nfp$DATE, "%Y-%m-%d" ) | |
| df <- data.frame( change=diff(nfp$VALUE), date=tail(nfp$DATE,-1) ) | |
| plot <- ggplot(df,aes(x=date,y=change)) + | |
| geom_area() | |
| plot |
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
| #http://www20.statcan.gc.ca/tables-tableaux/cansim/csv/02820087-eng.zip |
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
| /* | |
| * AlmostEqual.h | |
| * | |
| */ | |
| #ifndef ALMOSTEQUAL_H_ | |
| #define ALMOSTEQUAL_H_ | |
| // Usable AlmostEqual function - http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm | |
| bool AlmostEqual(float A, float B) { |
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
| [alias] | |
| sstash = "!f() { git stash save $1; }; f" | |
| sshow = "!f() { echo $@; git stash show stash^{/$*} -p; }; f" | |
| sapply = "!f() { git stash apply stash^{/$*}; }; f" |
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
| #$ curl -o /tmp/cad.cpi.csv http://www.statcan.gc.ca/daily-quotidien/160122/cg160122a001-eng.csv | |
| # "The 12-month change in the Consumer Price Index (CPI) and the CPI excluding gasoline, 12-month % change" | |
| # ,"CPI","CPI excluding gasoline" | |
| library(ggplot2) | |
| cad.cpi <- read.table( "/tmp/cad.cpi.csv", sep = ",", col.names=c("date", "cpi", "exgas"), skip=2, fill=T ) | |
| cad.cpi <- cad.cpi[1:(nrow( cad.cpi ) - 1),] | |
| cad.cpi$date = as.Date( paste( cad.cpi$date, '01' ), "%B %Y %d" ) | |
| df <- data.frame(cad.cpi) |
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
| library(xts) | |
| library(ggplot2) | |
| #cad gdp | |
| #curl http://www20.statcan.gc.ca/tables-tableaux/cansim/csv/03790031-eng.zip -o /tmp/ca.gpd.zip && unzip /tmp/ca.gpd.zip -d /tmp | |
| #curl http://www.statcan.gc.ca/cgi-bin/sum-som/fl/cstsaveascsv.cgi?filename=gdps04a-eng.htm&lan=eng -o | |
| #http://www20.statcan.gc.ca/tables-tableaux/cansim/csv/03790031-eng.zip | |
| #Ref_Date,GEO,SEAS,PRICES,NAICS,Vector,Coordinate,Value | |
| if( !exists( "ca.gdp" ) ) { | |
| ca.gdp <- read.csv("/tmp/03790031-eng.csv") |
OlderNewer