!!!!!!IMPORTANT!!!!!!! Make sure that whenever you run this test setup you use a PAPER TRADING ACCOUNT, since this test _does_ place orders. !!!!!!IMPORTANT!!!!!!! To run this alpha stage code in a test setup you will need these R packages (in addition to R version >2.12) quantstrat 0.3.2 IBrokers 0.9-0 You will also need an interactivebrokers TWS or GW instance listening on port 5001 (this is not the configured standard port. you can change the port in the TWS configuration seetings) Quick start: =========================================================================== There is no quickstart with this version anymore since it was modified so that it could be run via the (cron)script 'cronR-qsibliveEODrun'. The cron entry could look like this (assuming that 9:00 am is the time the markets open from Monday to Friday) 15 9 * * 1,2,3,4,5 /QSIBLIVEHOME/cronR-qsibliveEODrun >/dev/null 2>/dev/null & How to prepare your own strategy for execution in this live trading environment ============================================================================= look at the code in "strategy-source/maCross.R". This is the unaltered package demo code. However, at the end, we are writing the strategy object and some other information, such as the parameters we want to run the strategy with, to the file "strat.rdata". this is the file that will be read by the live trading evironment. this file will not be altered during live trading, but most of the other *.rdata files will be. So in order to take your own strategy from backtesting straight to live trading, just append that section of R code to your strategy source file, run it to create the "strat.rdata" file and then copy "strat.rdata" into whatever directory you are using for QSIBLIVEHOME. How to trade a different symbol/exchange ============================================================================= You will need to edit two lines in 'IBcreateExecPortfAcct-eod.r' symbol='DBXD' #P .... ibContract <- twsSTK(symbol='DBXD',exch="FWB",currency='EUR') #P Initialization ============================================================================= Initialization is done by calling 'IBcreateExecPortfAcct-eod.r' from the R prompt this will create all necessary *rdata files. Existing files will be deleted! Q&A =============================== Q2:why are we using marketdata that is not live (saved 'DBXD.rdata' file)? A: marketdata is read from a file right now but the orders the strategy generates are placed with IB. In the future it may be desireable to get the marketdata directly from IB through a marketdata feed. But again. for now 'qsiblive' is designed with EOD trading in mind, so doing it that way is fine. This may change in the future. The process to query and download the most recent marketdata is not part of qsiblive. Q3:why are we reading/writing all those *.rdata files before and after processing a new timestamp? A: for persistence reasons. If you would like to run this in a process that stays in memroy permanently, then this would not be needed. reading and writing all the important data to files may be slow, but it is also safe! When I first thought about this whole setup, I did want to trade on EOD data only. i.e. I wanted to use 'cron' to run R at specific times and therefore I needed a way of making data persistent. Q3a: What type of orders are supported ?? A: This demo runs with MKT = market orders. Q6:why are indicators and signals calculated for the entire marketdata set for every timestamp that is being processed: A: Just a quick & dirty solution. Am happy to have your suggestions on how to do this better. Q7:What platforms has this been tested on? A: linux only. Q8: Will it be possible to execute a strategy on a portfolio containing more than one symbol ? A: yes it will. But currently this is not the case. ============================== Soren Wilkening. 29 Jan 2012 Please note that I am NOT working for IB! I just happen to be one of their clients