-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/devcartel/tclrfa
- Loading branch information
Showing
22 changed files
with
1,123 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/tclsh | ||
# | ||
# Subscribe to market price and and pause the streaming. Once paused, | ||
# updates are conflated at ADS. To get 10-second conflated update, just | ||
# resume and pause again every 10 seconds. | ||
# | ||
package require tclrfa | ||
source ./utils/trap.tcl | ||
source ./utils/every.tcl | ||
|
||
set t [tclrfa] | ||
$t createConfigDb "./tclrfa.cfg" | ||
$t acquireSession "Session1" | ||
$t createOMMConsumer | ||
$t login | ||
$t directoryRequest | ||
$t dictionaryRequest | ||
$t marketPriceRequest "JPY=" | ||
$t dispatchEventQueue 1000 | ||
$t pauseAll | ||
|
||
set ms 10000 | ||
every $ms { | ||
$t resumeAll | ||
foreach u [$t dispatchEventQueue 100] { | ||
puts "\n[dict get $u SERVICE] - [dict get $u RIC]" | ||
foreach {k v} $u { | ||
puts "[format "%15s %-10s" $k $v]" | ||
} | ||
} | ||
$t pauseAll | ||
} | ||
|
||
vwait forever | ||
$t -delete |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/tclsh | ||
# | ||
# - Subscribe to multiple RICs, using local dictionary, debug mode is manually off. | ||
# - Using Tcl to format and print out market data updates. | ||
# - trap.tcl requires TclX lib to trap control-c and exit gracefully. | ||
# | ||
# REFRESH/IMAGE: | ||
# {SERVICE {NIP} RIC {EUR=} MTYPE {REFRESH}} | ||
# {SERVICE {NIP} RIC {EUR=} MTYPE {IMAGE} RDNDISPLAY {100} RDN_EXCHID {SES} BID {0.988} ASK {0.999} DIVPAYDATE {23 JUN 2011}} | ||
# | ||
# UPDATE: | ||
# {SERVICE {NIP} RIC {EUR=} MTYPE {UPDATE} BID_NET_CH {0.0041} BID {0.988} ASK {0.999} ASK_TIME {15:14:24:180:000:000}} | ||
# | ||
# STATUS: | ||
# {SERVICE {NIP} RIC {EUR=} MTYPE {STATUS} DATA_STATE {Suspect} STREAM_STATE {Open} TEXT {Source unavailable... will recover when source is up}} | ||
|
||
package require tclrfa | ||
source ./utils/trap.tcl | ||
|
||
set t [tclrfa] | ||
$t createConfigDb "./tclrfa.cfg" | ||
$t acquireSession "Session1" | ||
$t createOMMConsumer | ||
$t login | ||
$t directoryRequest | ||
$t dictionaryRequest | ||
$t marketPriceRequest "EUR= JPY=" | ||
|
||
while {1} { | ||
foreach u [$t dispatchEventQueue] { | ||
puts "\n[dict get $u SERVICE] - [dict get $u RIC]" | ||
foreach {k v} $u { | ||
puts "[format "%15s %-10s" $k $v]" | ||
} | ||
} | ||
} | ||
|
||
$t -delete |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/tclsh | ||
package require tclrfa | ||
|
||
set t [tclrfa] | ||
$t createConfigDb "./tclrfa.cfg" | ||
$t setDebugMode "true" | ||
$t acquireSession "Session1" | ||
$t createOMMConsumer | ||
|
||
$t login | ||
|
||
# Download dictionary from server | ||
# Must call directory request first | ||
$t directoryRequest | ||
$t dictionaryRequest | ||
|
||
$t -delete |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/tclsh | ||
package require tclrfa | ||
|
||
set t [tclrfa] | ||
$t createConfigDb "./tclrfa.cfg" | ||
$t setDebugMode "true" | ||
$t acquireSession "Session1" | ||
$t createOMMConsumer | ||
|
||
$t login | ||
|
||
$t directoryRequest | ||
|
||
$t -delete |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/tclsh | ||
# | ||
# Request for historical data (RDM type 12) published by provider.history.tcl | ||
# This domain is not officially supported by Thomson Reuters | ||
# | ||
# REFRESH/IMAGE: | ||
# {SERVICE {NIP} RIC {tANZ.AX} MTYPE {REFRESH}} {SERVICE {NIP} RIC {tANZ.AX} MTYPE {IMAGE} TRPRC_1 {40.124} SALTIM {14:31:34:335:000:000} TRADE_ID {123456789} BID_ORD_ID {5307FBL20AL7B}ASK_ORD_ID {5307FBL20BN8A}} | ||
# | ||
# STATUS: | ||
# {SERVICE {NIP} RIC {tANZ.AX} MTYPE {STATUS} DATA_STATE {Suspect} STREAM_STATE {Open} TEXT {<NIP> Source cannot provide the requested capability of MMT_HISTORY [12].}} | ||
|
||
package require tclrfa | ||
source ./utils/trap.tcl | ||
source ./utils/every.tcl | ||
|
||
set t [tclrfa] | ||
$t createConfigDb "./tclrfa.cfg" | ||
$t setDebugMode "true" | ||
$t acquireSession "Session3" | ||
$t createOMMConsumer | ||
$t login | ||
$t directoryRequest | ||
$t dictionaryRequest | ||
|
||
set RIC "tANZ.AX" | ||
$t historyRequest $RIC | ||
|
||
set count 0 | ||
while {![$t isHistoryRefreshComplete]} { | ||
foreach u [$t dispatchEventQueue] { | ||
if {$count == 1} { | ||
puts "\n[dict get $u SERVICE] - [dict get $u RIC]" | ||
puts "-----------------------" | ||
foreach {k v} $u { | ||
puts -nonewline "$k," | ||
} | ||
puts "" | ||
foreach {k v} $u { | ||
puts -nonewline "$v," | ||
} | ||
} elseif {$count > 1} { | ||
foreach {k v} $u { | ||
puts -nonewline "$v," | ||
} | ||
} | ||
puts "" | ||
incr count | ||
} | ||
update | ||
} | ||
puts "\n\n########## total history records: [expr $count - 1] ###################\n\n" | ||
$t -delete |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/tclsh | ||
# | ||
# subscribe to MarketByOrder and orderbook cache | ||
# run this script with -n to not display orderbook | ||
# | ||
# REFRESH/IMAGE: | ||
# {SERVICE {NIP} RIC {ANZ.AX} MTYPE {REFRESH}} | ||
# {SERVICE {NIP} RIC {ANZ.AX} MTYPE {IMAGE} ACTION {ADD} KEY {538993C200035057B} ORDER_PRC {20.835}} | ||
# | ||
# UPDATE: | ||
# {SERVICE {NIP} RIC {ANZ.AX} MTYPE {UPDATE} ACTION {UPDATE} KEY {538993C200035057B} ORDER_PRC {20.214} ORDER_SIZE {41} ORDER_SIDE {BID} SEQNUM_QT {511} EX_ORD_TYP {0} CHG_REAS {10}} | ||
# | ||
# DELETE: | ||
# {SERVICE {NIP} RIC {ANZ.AX} MTYPE {UPDATE} ACTION {DELETE} KEY {538993C200083483B}} | ||
# | ||
# STATUS: | ||
# {SERVICE {NIP} RIC {ANZ.AX} MTYPE {STATUS} DATA_STATE {Suspect} STREAM_STATE {Open} TEXT {<NIP> Source cannot provide the requested capability of MMT_MARKET_BY_ORDER [7].}} | ||
|
||
package require tclrfa | ||
source ./utils/trap.tcl | ||
|
||
# run with -n to disble orderbook displayed | ||
if {[lindex $argv 0] == "-n"} { | ||
set displaybook "false" | ||
} else { | ||
set displaybook "true" | ||
source ./utils/orderbook.tcl | ||
} | ||
|
||
set t [tclrfa] | ||
$t createConfigDb "./tclrfa.cfg" | ||
$t setDebugMode "false" | ||
$t acquireSession "Session3" | ||
$t createOMMConsumer | ||
|
||
$t login | ||
$t directoryRequest | ||
$t dictionaryRequest | ||
|
||
set rics "ANZ.AX" | ||
$t marketByOrderRequest "$rics" | ||
|
||
# run for N millisecs, parse updates and display on stdout | ||
set end 0 | ||
after 1000000 {set end 1} | ||
while {!$end} { | ||
set updates [$t dispatchEventQueue 1000] | ||
if {$updates != ""} { | ||
puts "\n$updates" | ||
foreach u $updates { | ||
puts "\n[dict get $u SERVICE] - [dict get $u RIC]" | ||
foreach {k v} $u { | ||
puts "[format "%15s %-10s" $k $v]" | ||
} | ||
} | ||
|
||
# display orderbook | ||
if {$displaybook} { | ||
updateorderbook $updates | ||
foreach ric $rics { | ||
displayorderbook "$ric" 25 | ||
} | ||
} | ||
} | ||
} | ||
|
||
$t marketByOrderCloseAllRequest | ||
$t -delete |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/tclsh | ||
# | ||
# subscribe to MarketByPrice and depth cache | ||
# run this script with -n to not display market depth | ||
# | ||
# REFRESH/IMAGE: | ||
# {SERVICE {NIP} RIC {ANZ.CHA} MTYPE {REFRESH}} | ||
# {SERVICE {NIP} RIC {ANZ.CHA} MTYPE {IMAGE} ACTION {ADD} KEY {201000B} ORDER_PRC {20.1000} ORDER_SIDE {BID} ORDER_SIZE {17} NO_ORD {6} QUOTIM_MS {16987567} ORDER_TONE {}} | ||
# | ||
# UPDATE: | ||
# {SERVICE {NIP} RIC {ANZ.CHA} MTYPE {UPDATE} ACTION {UPDATE} KEY {201000B} NO_ORD {7} ORDER_SIDE {BID} ORDER_SIZE {5}} | ||
# | ||
# DELETE: | ||
# {SERVICE {NIP} RIC {ANZ.CHA} MTYPE {UPDATE} ACTION {DELETE} KEY {202000B}} | ||
# | ||
# STATUS: | ||
# {SERVICE {NIP} RIC {ANZ.CHA} MTYPE {STATUS} DATA_STATE {Suspect} STREAM_STATE {Open} TEXT {<NIP> Source cannot provide the requested capability of MMT_MARKET_BY_PRICE [8].}} | ||
|
||
package require tclrfa | ||
source ./utils/trap.tcl | ||
|
||
# run with -n to disable market depth displayed | ||
if {[lindex $argv 0] == "-o"} { | ||
set displaymarketdepth "false" | ||
} else { | ||
set displaymarketdepth "true" | ||
source ./utils/marketdepth.tcl | ||
} | ||
|
||
set t [tclrfa] | ||
$t createConfigDb "./tclrfa.cfg" | ||
$t acquireSession "Session3" | ||
$t createOMMConsumer | ||
|
||
$t login | ||
$t directoryRequest | ||
$t dictionaryRequest | ||
|
||
set rics "ANZ.CHA" | ||
$t marketByPriceRequest "$rics" | ||
|
||
# run for N millisecs, parse updates and display on stdout | ||
set end 0 | ||
after 1000000 {set end 1} | ||
while {!$end} { | ||
set updates [$t dispatchEventQueue 1000] | ||
if {$updates != ""} { | ||
puts "\n$updates" | ||
foreach u $updates { | ||
puts "\n[dict get $u SERVICE] - [dict get $u RIC]" | ||
foreach {k v} $u { | ||
puts "[format "%15s %-10s" $k $v]" | ||
} | ||
} | ||
|
||
# display depth | ||
if {$displaymarketdepth} { | ||
updatedepth $updates | ||
foreach ric $rics { | ||
displaydepth "$ric" 25 | ||
} | ||
} | ||
} | ||
} | ||
|
||
$t marketByPriceCloseAllRequest | ||
$t -delete |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/tclsh | ||
# | ||
# OMM Posting (off-stream) leverages on consumer login channel to contribute aka. "post" data | ||
# up to ADH/ADS cache. Posted service must be up. | ||
# | ||
package require tclrfa | ||
source ./utils/trap.tcl | ||
source ./utils/every.tcl | ||
|
||
set t [tclrfa] | ||
$t createConfigDb "./tclrfa.cfg" | ||
$t setDebugMode "true" | ||
$t acquireSession "Session3" | ||
$t createOMMConsumer | ||
$t login | ||
$t directoryRequest | ||
$t dictionaryRequest | ||
|
||
set ms 5000 | ||
every $ms { | ||
set price "4.[expr {round(rand()*1000)}]" | ||
$t marketPricePost "RIC TRI.N TIMACT now TRDPRC_1 $price" | ||
} | ||
|
||
vwait end | ||
$t -delete |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/tclsh | ||
# | ||
# Non-interactive (full cached) publisher for history domain | ||
# HISTORY provides full indexed time series | ||
# | ||
package require tclrfa | ||
source ./utils/trap.tcl | ||
source ./utils/every.tcl | ||
|
||
set t [tclrfa] | ||
$t createConfigDb "./tclrfa.cfg" | ||
$t setDebugMode "true" | ||
$t acquireSession "Session4" | ||
$t createOMMProvider | ||
$t login | ||
$t dictionaryRequest | ||
|
||
set UPDATE1 { RIC {tANZ.AX} TRDPRC_1 {40.124} SALTIM {now} TRADE_ID {123456789} BID_ORD_ID {5307FBL20AL7B} ASK_ORD_ID {5307FBL20BN8A}} | ||
set UPDATE2 { RIC {tBHP.AX} TRDPRC_1 {25.234} SALTIM {now} TRADE_ID {987654321} BID_ORD_ID {5307FBL2XXXXB} ASK_ORD_ID {5307FBL2YYYYA}} | ||
$t historySubmit $UPDATE1 $UPDATE2 | ||
|
||
set count 0 | ||
every 1000 { | ||
if {$count < 100} { | ||
$t historySubmit $UPDATE1 $UPDATE2 | ||
} | ||
incr count | ||
} | ||
|
||
vwait end | ||
$t -delete |
Oops, something went wrong.