|
6 | 6 | in a particular environment; it is offered solely as sample code for guidance. |
7 | 7 | Please see the Thomson Reuters Knowledge Direct product page at http://customers.thomsonreuters.com |
8 | 8 | 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.''' |
10 | 17 |
|
11 | 18 | import os |
12 | 19 | import sys |
@@ -42,27 +49,33 @@ def CreateAuthorization(username, password, appid): |
42 | 49 | return token |
43 | 50 |
|
44 | 51 | ## 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 | + |
46 | 76 | quoteURL = 'https://api.trkd.thomsonreuters.com/api/Quotes/Quotes.svc/REST/Quotes_1/RetrieveItem_3' |
47 | 77 | 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 | + |
66 | 79 | print '############### Sending Quote request message to TRKD ###############' |
67 | 80 | try: |
68 | 81 | ##send request |
|
0 commit comments