Sections * 1. Connection * 2. Configuration (symbols, currencies, accounts) * 3. Feed history (bars and quotes) * 4. Trades/Trade Reports
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.0
require(FdkRLib)
## Loading required package: FdkRLib
ttConnect("tp.st.soft-fx.eu", "100000", "123321")
## Loading required package: jsonlite
##
## Attaching package: 'jsonlite'
##
## The following object is masked from 'package:utils':
##
## View
## [1] 0
Get symbol and currency data
head(ttGetSymbolData())
## comission contractMultiplier currency limitsComission maxTradeVolume
## 1 1e+02 1e+05 EUR 1e+02 1e+07
## 2 5e-03 1e+03 XAG 5e-03 5e+05
## 3 5e-03 1e+01 ASX 5e-03 1e+03
## 4 5e-03 1e+03 XNG 5e-03 1e+07
## 5 5e-03 1e+02 XBR 5e-03 1e+06
## 6 1e+02 1e+05 EUR 1e+02 1e+07
## minTradeVolume name precision roundLog settlementCurrency
## 1 1000 EURUSD 5 1e+05 USD
## 2 50 XAGUSD 3 5e+03 USD
## 3 1 #AUS200 1 1e+01 AUD
## 4 1000 XNGUSD 3 1e+04 USD
## 5 10 XBRUSD 2 1e+03 USD
## 6 1000 EURAUD 5 1e+05 AUD
## swapSizeLong swapSizeShort
## 1 2.32 2.23
## 2 0.00 0.00
## 3 88.28 -156.00
## 4 0.28 0.09
## 5 6.80 5.40
## 6 0.00 0.00
head(ttGetCurrencyData())
## currency description precision sortOrder
## 1 USD United States Dollar 6 1
## 2 EUR Euro 2 2
## 3 CAD Canadian Dollar 2 3
## 4 GBP Great Britain Pound 2 4
## 5 AUD Australian Dollar 2 5
## 6 CHF Swiss Franc 2 6
Get 10000 bars of EURUSD symbol:
head(ttBars(“EURUSD”))
head(ttBars("EURUSD"))
## high low open close volume from
## 1 1.35718 1.35679 1.35718 1.35683 80 2011-10-10 05:55:00
## 2 1.35709 1.35677 1.35681 1.35703 78 2011-10-10 05:56:00
## 3 1.35730 1.35701 1.35701 1.35712 79 2011-10-10 05:57:00
## 4 1.35713 1.35692 1.35703 1.35702 73 2011-10-10 05:58:00
## 5 1.35713 1.35661 1.35702 1.35673 78 2011-10-10 05:59:00
## 6 1.35677 1.35649 1.35672 1.35660 83 2011-10-10 06:00:00
## to
## 1 2011-10-10 05:56:00
## 2 2011-10-10 05:57:00
## 3 2011-10-10 05:58:00
## 4 2011-10-10 05:59:00
## 5 2011-10-10 06:00:00
## 6 2011-10-10 06:01:00
Get 10000 bar pairs of EURUSD symbol:
bars = ttBarPairs(“EURUSD”)
head(ttBarPairs("EURUSD"))
## askHigh askLow askopen askClose askVolume bidHigh bidLow bidOpen
## 1 1.35731 1.35679 1.35731 1.35683 80 1.35718 1.35679 1.35718
## 2 1.35709 1.35677 1.35681 1.35703 78 1.35709 1.35677 1.35681
## 3 1.35730 1.35701 1.35701 1.35712 79 1.35730 1.35701 1.35701
## 4 1.35713 1.35692 1.35703 1.35702 73 1.35713 1.35692 1.35703
## 5 1.35713 1.35661 1.35702 1.35673 78 1.35713 1.35661 1.35702
## 6 1.35677 1.35649 1.35672 1.35660 83 1.35677 1.35649 1.35672
## bidClose bidVolume from to
## 1 1.35683 80 2011-10-10 05:56:00 2011-10-10 05:56:00
## 2 1.35703 78 2011-10-10 05:57:00 2011-10-10 05:57:00
## 3 1.35712 79 2011-10-10 05:58:00 2011-10-10 05:58:00
## 4 1.35702 73 2011-10-10 05:59:00 2011-10-10 05:59:00
## 5 1.35673 78 2011-10-10 06:00:00 2011-10-10 06:00:00
## 6 1.35660 83 2011-10-10 06:01:00 2011-10-10 06:01:00
Get quotes
now <-as.POSIXct(Sys.time())
prevNow <-as.POSIXct(Sys.time()-(300))
head(ttQuotes("EURUSD", , startTime = prevNow, endTime=now))
## ask bid createTime
## 1 1.13954 1.13951 2015-06-22 11:45:17
## 2 1.13954 1.13950 2015-06-22 11:45:17
## 3 1.13954 1.13951 2015-06-22 11:45:17
## 4 1.13954 1.13951 2015-06-22 11:45:18
## 5 1.13954 1.13951 2015-06-22 11:45:18
## 6 1.13954 1.13951 2015-06-22 11:45:18
Get quotes L2
head(ttTrades())
## agentComission tradeClientOrderId
## 1 0 ManagerOrder-a0b70568-9bdd-4538-8d41-1554b9cca9c7
## 2 0 ManagerOrder-2f28f9b4-d138-4c1c-9893-0349bcb478aa
## 3 0 ManagerOrder-f15a4d6d-afdf-4914-94e8-a8c5076853d7
## 4 0 a6eda539-d50a-4214-98a5-4a5e3d772fb9
## 5 0 a857dd1d-3879-453d-bd8c-86295a11c256
## 6 0 ManagerOrder-07d7cf8d-8aab-4065-a71a-2d8cb2ffa706
## tradeComment created expiration initialVolume
## 1 2015-06-17 09:27:15 1969-12-31 22:00:00 1e+05
## 2 2015-06-17 13:41:55 1969-12-31 22:00:00 1e+05
## 3 2015-06-17 13:41:58 1969-12-31 22:00:00 1e+05
## 4 2015-06-17 13:47:24 1969-12-31 22:00:00 3e+00
## 5 2015-06-17 13:47:26 1969-12-31 22:00:00 3e+00
## 6 2015-06-17 13:52:30 1969-12-31 22:00:00 1e+05
## isLimitOrder isPendingOrder isPosition isStopOrder modified
## 1 False False True False 2015-06-17 12:41:55
## 2 False False True False 2015-06-17 13:41:55
## 3 False False True False 2015-06-17 13:41:58
## 4 False False True False 2015-06-17 13:47:24
## 5 False False True False 2015-06-17 13:47:26
## 6 False False True False 2015-06-17 13:52:31
## orderId price profit side stopLoss swap takeProfit type
## 1 388007 1.12690 0 Buy 0 11.6000 0 Position
## 2 396002 1.12665 0 Sell 0 11.1500 0 Position
## 3 396003 1.12669 0 Buy 0 11.6000 0 Position
## 4 396004 5587.20000 0 Sell 0 -181.2906 0 Position
## 5 396005 5593.20000 0 Buy 0 102.5823 0 Position
## 6 396006 1.12676 0 Sell 0 11.1500 0 Position
## volume
## 1 1e+05
## 2 1e+05
## 3 1e+05
## 4 3e+00
## 5 3e+00
## 6 1e+05
now <-as.POSIXct(Sys.time())
prevNow <-as.POSIXct(Sys.time()-1000)
qt2= ttQuotesLevel2('EURUSD', prevNow, now)
head(qt2)
## volumeBid volumeAsk priceBid priceAsk createTime quoteIndex
## 1 5000 4e+03 1.13906 1.13968 2015-06-22 11:44:47 359
## 2 2000 2e+06 1.13886 1.13969 2015-06-22 11:44:47 359
## 3 5000 4e+03 1.13906 1.13968 2015-06-22 11:44:47 714
## 4 2000 2e+06 1.13886 1.13969 2015-06-22 11:44:47 714
## 5 5000 4e+03 1.13906 1.13968 2015-06-22 11:44:48 308
## 6 2000 1e+06 1.13886 1.13969 2015-06-22 11:44:48 308
Get trades of current account
now <-as.POSIXct(Sys.time())
prevNow <-as.POSIXct(Sys.time()-(120*3600))
head(ttTradeRecords(prevNow, now))
## AgentCommission ClientId
## 1 0 e9d0f3a2-7b02-47f9-b5ff-a9b4ad878c5c
## 2 0 e9d0f3a2-7b02-47f9-b5ff-a9b4ad878c5c
## 3 0 ManagerOrder-f34ab632-0e00-4ae7-ae9e-5ba43a2adb3e
## CloseConversionRate InitialVolume Comment Commission Id
## 1 -1.0000000 0 396017
## 2 0.8211799 0 396017
## 3 -1.0000000 0 404053
## LeavesQuantity OpenConversionRate OrderCreated OrderFillPrice
## 1 1e+05 1 2015-06-18 08:57:20 -1
## 2 0e+00 1 2015-06-18 08:57:20 -1
## 3 1e+01 -1 2015-06-19 11:51:52 -1
## OrderLastFillAmount OrderModified PosOpenPrice PositionClosePrice
## 1 -1 2015-06-18 08:57:20 0.00000 0.00000
## 2 -1 2015-06-18 08:57:36 1.21786 1.21776
## 3 -1 2015-06-19 11:51:53 0.00000 0.00000
## PositionCloseRequestedPrice PositionClosed PositionLastQuantity
## 1 0 1970-01-01 00:00:00 0
## 2 0 2015-06-18 08:57:36 0
## 3 0 1970-01-01 00:00:00 0
## PositionLeavesQuantity PositionModified PositionOpened
## 1 0 1970-01-01 1970-01-01 00:00:00
## 2 0 1970-01-01 2015-06-18 08:57:20
## 3 0 1970-01-01 1970-01-01 00:00:00
## PositionQuantity Price Quantity StopLoss Swap Symbol TakeProfit
## 1 0 1.21786 1e+05 0 0 USDCAD 0
## 2 0 1.21786 1e+05 0 0 USDCAD 0
## 3 0 5612.60000 1e+01 0 0 #AUS200 0
## TradeRecordSide TradeRecordType TradeTransactionReason
## 1 Buy Position PendingOrderActivation
## 2 Buy Position ClientRequest
## 3 Sell Limit DealerDecision
## TradeTransactionReportType TransactionAmount TransactionCurrency
## 1 PositionOpened 0
## 2 PositionClosed 0
## 3 OrderOpened 0
## TransactionTime
## 1 2015-06-18 08:57:20
## 2 2015-06-18 08:57:36
## 3 2015-06-19 11:51:53
Trades in account:
# head(ttTrades())
All trades
head(ttTradeRecordAll())
## AgentCommission ClientId
## 1 0
## 2 0 ManagerOrder-f3e2dfd3-527c-402b-8a6e-fc8f4a1198a0
## 3 0 ManagerOrder-7e0dca55-c44b-44e2-af86-6c329934fe78
## 4 0 ManagerOrder-7f5be08e-01a7-40a2-a494-ee64de8a7d3d
## 5 0 ManagerOrder-6bf551f9-442f-4079-828a-9f05b42236dc
## 6 0 ManagerOrder-050e0848-d4cb-47cd-a8fe-fee4cd5d1d1e
## CloseConversionRate InitialVolume Comment Commission Id
## 1 -1 0.00 329002
## 2 1 USD -5.64 329003
## 3 1 0.00 329004
## 4 1 USD -22.54 329006
## 5 1 0.00 329005
## 6 -1 0.00 329008
## LeavesQuantity OpenConversionRate OrderCreated OrderFillPrice
## 1 0e+00 -1.00000 2015-06-10 11:20:45 -1
## 2 0e+00 1.12689 2015-06-10 11:22:54 -1
## 3 0e+00 1.12689 2015-06-10 11:22:58 -1
## 4 0e+00 1.12689 2015-06-10 11:28:16 -1
## 5 0e+00 1.12689 2015-06-10 11:28:14 -1
## 6 1e+05 1.12689 2015-06-10 11:34:34 -1
## OrderLastFillAmount OrderModified PosOpenPrice PositionClosePrice
## 1 -1 1970-01-01 00:00:00 0.00000 0.00000
## 2 -1 1970-01-01 00:00:00 1.12684 1.12689
## 3 -1 1970-01-01 00:00:00 1.12689 1.12689
## 4 -1 1970-01-01 00:00:00 1.12689 1.12684
## 5 -1 1970-01-01 00:00:00 1.12684 1.12684
## 6 -1 2015-06-10 11:44:22 0.00000 0.00000
## PositionCloseRequestedPrice PositionClosed PositionLastQuantity
## 1 0 1970-01-01 00:00:00 0e+00
## 2 0 2015-06-10 11:25:23 1e+05
## 3 0 2015-06-10 11:25:23 0e+00
## 4 0 2015-06-10 11:28:55 1e+05
## 5 0 2015-06-10 11:28:55 0e+00
## 6 0 1970-01-01 00:00:00 0e+00
## PositionLeavesQuantity PositionModified PositionOpened
## 1 0 1970-01-01 1970-01-01 00:00:00
## 2 0 1970-01-01 2015-06-10 11:22:56
## 3 0 1970-01-01 2015-06-10 11:22:59
## 4 0 1970-01-01 2015-06-10 11:28:17
## 5 0 1970-01-01 2015-06-10 11:28:14
## 6 0 1970-01-01 1970-01-01 00:00:00
## PositionQuantity Price Quantity StopLoss Swap Symbol TakeProfit
## 1 0e+00 0.00000 0e+00 0 0 0
## 2 1e+05 0.00000 0e+00 0 0 EURUSD 0
## 3 1e+05 0.00000 0e+00 0 0 EURUSD 0
## 4 1e+05 0.00000 0e+00 0 0 EURUSD 0
## 5 1e+05 0.00000 0e+00 0 0 EURUSD 0
## 6 0e+00 1.12689 1e+05 0 0 EURUSD 0
## TradeRecordSide TradeRecordType TradeTransactionReason
## 1 -1 -1 DealerDecision
## 2 Sell Position DealerDecision
## 3 Buy Position DealerDecision
## 4 Buy Position DealerDecision
## 5 Sell Position DealerDecision
## 6 Buy Position DealerDecision
## TradeTransactionReportType TransactionAmount TransactionCurrency
## 1 BalanceTransaction 1000000.00 USD
## 2 PositionClosed -10.64 USD
## 3 PositionClosed 0.00 USD
## 4 PositionClosed -27.54 USD
## 5 PositionClosed 0.00 USD
## 6 OrderCanceled 0.00 USD
## TransactionTime
## 1 2015-06-10 11:20:45
## 2 2015-06-10 11:25:23
## 3 2015-06-10 11:25:23
## 4 2015-06-10 11:28:55
## 5 2015-06-10 11:28:55
## 6 2015-06-10 11:44:22