Skip to content

Commit 78aee5c

Browse files
author
Wasin Waeosri
committed
be able to subscribe Quote
1 parent 294a4a1 commit 78aee5c

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

trkd_quote.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
in a particular environment; it is offered solely as sample code for guidance.
77
Please see the Thomson Reuters Knowledge Direct product page at http://customers.thomsonreuters.com
88
for additional information regarding the TRKD API.'''
9-
9+
'''
10+
The TRKD API sample code is provided for informational purposes only
11+
and without knowledge or assumptions of the end users development environment.
12+
We offer this code to provide developers practical and useful guidance while developing their own code.
13+
However, we do not offer support and troubleshooting of issues that are related to the use of this code
14+
in a particular environment; it is offered solely as sample code for guidance.
15+
Please see the Thomson Reuters Knowledge Direct product page at http://customers.thomsonreuters.com
16+
for additional information regarding the TRKD API.'''
1017

1118
import os
1219
import sys
@@ -42,27 +49,33 @@ def CreateAuthorization(username, password, appid):
4249
return token
4350

4451
## Perform Quote request
45-
def RetrieveQuotes(token,appid):
52+
def RetrieveQuotes(token, appid):
53+
54+
ricName = raw_input('Please input Symbol: ')
55+
fieldFiltering = raw_input('Subscribe all Field? (Yes|No)')
56+
quoteRequestMsg = None
57+
fieldsName = 'CF_LAST:CF_HIGH:CF_LOW:CF_BID:CF_ASK:CF_YIELD:CF_SOURCE:CF_SRC_PAGE:CF_LOTSIZE:CF_DATE:CF_TIME:CF_TICK:CF_NETCHNG:CF_EXCHNG:CF_VOLUME:CF_CLOSE:CF_OPEN:CF_NAME:CF_CURRENCY'
58+
if fieldFiltering == 'Yes':
59+
## Request all Fields
60+
quoteRequestMsg = \
61+
{'RetrieveItem_Request_3': {'TrimResponse': False,
62+
'ItemRequest': [{'RequestKey': [{'Name': ricName, 'NameType': 'RIC'}], 'Scope': 'All',
63+
'ProvideChainLinks': True}]}}
64+
elif fieldFiltering == 'No':
65+
## Request specific Fields
66+
fieldsName = raw_input('Input interested Field Name in the following format (BID:ASK:TRDPRC_1)')
67+
quoteRequestMsg = \
68+
{'RetrieveItem_Request_3': {'TrimResponse': False,
69+
'ItemRequest': [{
70+
'RequestKey': [{'Name': ricName, 'NameType': 'RIC'}],
71+
'Fields': fieldsName,
72+
'Scope': 'List',
73+
'ProvideChainLinks': True,
74+
}]}}
75+
4676
quoteURL = 'https://api.trkd.thomsonreuters.com/api/Quotes/Quotes.svc/REST/Quotes_1/RetrieveItem_3'
4777
headers = {'content-type': 'application/json;charset=utf-8' ,'X-Trkd-Auth-ApplicationID': appid, 'X-Trkd-Auth-Token' : token}
48-
quoteRequestMsg = {
49-
'RetrieveItem_Request_3': {
50-
'TrimResponse': False,
51-
'ItemRequest': [
52-
{
53-
'Fields': 'CF_LAST:CF_HIGH:CF_LOW:CF_BID:CF_ASK:CF_YIELD:CF_DATE:CF_TIME:CF_VOLUME:CF_CLOSE:CF_OPEN:CF_NAME',
54-
'RequestKey': [
55-
{
56-
'Name': 'VOD.L',
57-
'NameType': 'RIC'
58-
}
59-
],
60-
'Scope': 'List',
61-
'ProvideChainLinks': True
62-
}
63-
]
64-
}
65-
}
78+
6679
print '############### Sending Quote request message to TRKD ###############'
6780
try:
6881
##send request

0 commit comments

Comments
 (0)