Connect to TT Demo server: ttConnect()

options(warn=-1)
require(rClr)
## Loading required package: rClr
## Loading the dynamic library for Microsoft .NET runtime...
## Loaded Common Language Runtime version 4.0.30319.34209
require(FdkRLib)
## Loading required package: FdkRLib
ttConnect()
## Loading required package: jsonlite
## 
## Attaching package: 'jsonlite'
## 
## The following object is masked from 'package:utils':
## 
##     View
## [1] 0

Get 10000 bars of EURUSD symbol:

head(ttBars(“EURUSD”))

head(ttBars("EURUSD"))
##      high     low    open   close volume                from
## 1 1.30601 1.30568 1.30591 1.30597    936 2012-05-07 23:00:00
## 2 1.30600 1.30560 1.30596 1.30570    560 2012-05-07 23:01:00
## 3 1.30573 1.30534 1.30570 1.30554    583 2012-05-07 23:02:00
## 4 1.30560 1.30546 1.30554 1.30546    204 2012-05-07 23:03:00
## 5 1.30551 1.30546 1.30546 1.30550    124 2012-05-07 23:04:00
## 6 1.30572 1.30548 1.30550 1.30563    338 2012-05-07 23:05:00
##                    to
## 1 2012-05-07 23:01:00
## 2 2012-05-07 23:02:00
## 3 2012-05-07 23:03:00
## 4 2012-05-07 23:04:00
## 5 2012-05-07 23:05:00
## 6 2012-05-07 23:06:00

Get 10000 bar pairs of EURUSD symbol:

bars = ttBarPairs(“EURUSD”)

head(ttBarPairs("EURUSD"))
##   askHigh  askLow askopen askClose askVolume bidHigh  bidLow bidOpen
## 1 1.30602 1.30573 1.30593  1.30599       936 1.30601 1.30568 1.30591
## 2 1.30603 1.30566 1.30598  1.30575       560 1.30600 1.30560 1.30596
## 3 1.30578 1.30540 1.30575  1.30558       583 1.30573 1.30534 1.30570
## 4 1.30565 1.30550 1.30558  1.30550       204 1.30560 1.30546 1.30554
## 5 1.30556 1.30550 1.30550  1.30555       124 1.30551 1.30546 1.30546
## 6 1.30574 1.30554 1.30555  1.30567       338 1.30572 1.30548 1.30550
##   bidClose bidVolume                from                  to
## 1  1.30597       936 2012-05-07 23:01:00 2012-05-07 23:01:00
## 2  1.30570       560 2012-05-07 23:02:00 2012-05-07 23:02:00
## 3  1.30554       583 2012-05-07 23:03:00 2012-05-07 23:03:00
## 4  1.30546       204 2012-05-07 23:04:00 2012-05-07 23:04:00
## 5  1.30550       124 2012-05-07 23:05:00 2012-05-07 23:05:00
## 6  1.30563       338 2012-05-07 23:06:00 2012-05-07 23:06:00

Get quotes

now <-as.POSIXct(Sys.time())
prevNow <-as.POSIXct(Sys.time()-1000)
head(ttQuotes("EURUSD", startTime= prevNow, endTime = now))
##       ask     bid          createTime
## 1 1.12302 1.12295 2015-06-16 12:11:12
## 2 1.12301 1.12295 2015-06-16 12:11:12
## 3 1.12301 1.12295 2015-06-16 12:11:12
## 4 1.12300 1.12295 2015-06-16 12:11:12
## 5 1.12301 1.12295 2015-06-16 12:11:13
## 6 1.12301 1.12295 2015-06-16 12:11:13

Get trades of current account

head(ttTrades())
##  [1] agentComission     tradeClientOrderId tradeComment      
##  [4] created            expiration         initialVolume     
##  [7] isLimitOrder       isPendingOrder     isPosition        
## [10] isStopOrder        modified           orderId           
## [13] price              profit             side              
## [16] stopLoss           swap               takeProfit        
## [19] type               volume            
## <0 rows> (or 0-length row.names)

More functionality tested:

trades = ttTrades()


bars = ttBars("EURUSD", barCount = 1000000)
barPairs = ttBarPairs('EURUSD')

now <-as.POSIXct(Sys.time())
prevNow <-as.POSIXct(Sys.time()-1000)

qt = ttQuotes('EURUSD', startTime = prevNow, endTime=now)

qt2= ttQuotesLevel2('EURUSD', prevNow, now)
head(qt2)
##   volumeBid volumeAsk priceBid priceAsk          createTime
## 1      2000   3400000  1.12249  1.12303 2015-06-16 12:11:31
## 2      1000    240000  1.12243  1.12338 2015-06-16 12:11:31
## 3      2000   1000000  1.12249  1.12302 2015-06-16 12:11:32
## 4      1000   2900000  1.12243  1.12303 2015-06-16 12:11:32
## 5      2000   1000000  1.12249  1.12302 2015-06-16 12:11:32
## 6      1000   1500000  1.12243  1.12303 2015-06-16 12:11:32