TT Stock Exchange Web Services anyone?


2011-07-17 10:57 PM: Added AsJson API operation as requested from a reader.

I know that I have been writing quite a bit of “general” posts, but I think that I should put up and early disclaimer that the latter part of this one will be a bit on the technical side, however, I think that that can be of interest to non-technical folks out there.

For those of you following me on twitter, for the last week or so I’ve have been playing around with some code that would bring a bit more “exposure” to the trading data coming out from the Trinidad and Tobago Stock Exchange. So, let me build this story up properly…

networkFor a  long time, particularly since the invention of computer and telecommunication networks, software engineers have been trying to make it easier for different computer programs built using different technology stacks, running on different hardware, to share information. There have been numerous attempts in this area with quite a bit of success and many continuing challenges. For those of you out there that are reading this and aren’t software engineers, the industry has gone a really long way to solving this problem, and one of the most significant components of getting us there was … you guessed it … the web.

The “web” (this is pretty loaded term, so I had to throw up the air-bunnies Winking smile) has vaulted the need to share information to a whole new level, and not just information between people but information between computer programs. It’s so pervasive today that most of us don’t even know it or those of us that do generally don’t think about it. You don’t think about the fact that when you log into Windows Live Messenger and see images or even chat with your friends on Facebook that a bunch of completely different computer systems are communicating with each other, same goes for internet back games, online PC games, online Console game, and the list goes on…

Financial systems are also a key area that can benefit from data exchange between computers and ultimately between people. I’ve been working on a project for a couple of years that needed up-to-date information from the Trinidad and Tobago Stock Exchange (TTSE) on a daily basis. Luckily the TTSE now has a website where anyone can get information about the day’s changes after the trading has closed. That said, there are a couple of ways that this problem can be addressed from on my end:

  1. Have a human enter the data after visiting the TTSE website
  2. Get the required information “programmatically” from TTSE system TTSE%20Logo%20_280309891

    With option one, there is the possibility that we can inject human errors, forget to enter the information, not to mention the fact that we actually need a human “resource” to do this every day … so there is an obvious bias to being able to directly interface with the stock exchange in some way. There’s just one small problem here – the TTSE has deliberately decided to actively support programmatic information sharing … which they currently don’t do.

    What I have been working on (currently without their direct support) is a way to provide this programmatic interface so that other computer applications can make use of their information without the need for human intervention.

    I’ve built a couple of “web services” for experimental reasons that provide several methods of accessing data from the TTSE. The manner in which I implemented them was the initial reason I started this post, but I think I’ll deal with that as well as explaining to the non-techie folk what Web Services are.

    Couple of weeks ago I built a simple proof-of-concept (POC) bit that allowed you to get an RSS feed of the information on the stock exchange. This old POC can still be found here:

    This weekend, I finally got some time to completely nerd-out and with a couple of late night coding sprints, I’ve completely re-written the app to do a whole lot more, and to do it better:

    The new base URL is: – (This currently just bounces you back to this page since I haven’t yet created a project write up + documentation etc. … but read on!)

    The API’s are RESTful (I’ll explain in a later post on web services), which means that using the API’s is as simple as making a web request … for the non-techies –> typing in a URL in the browser and hitting enter or clicking on a hyperlink.

    From the base URL identified above, the URLs to access the services are as follows:

    API’s Description
    Feed/AsXml Returns an XML representation of TTSE trading data
    Feed/AsCsv Returns a CSV representation of TTSE trading data
    Feed/AsRss20 Returns an RSS 2.0 representation of TTSE trading data
    Feed/AsAtom10 Returns an ATOM 1.0 representation of TTSE trading data
    Feed/AsJson Returns a JSON representation of the TTSE trading data
    Feed/AsHtml Returns an HTML/XHTML representation of TTSE trading data

    What this mean is that developers can go to the following URLs and get the trade information from the TTSE:

    Fully qualified API URL

    Note the addition of the specific “API call” at the end of the base URL.

    However, that isn’t all folks. All of the operations identified above support the following optional parameter list:

    Parameter Description
    date Represents the date for which trade data should be returned.

    Format: YYYY-MM-DD

    changesOnly Defines whether or not all Securities or only those whose values have changed should be returned.

    true  – Only returns securities whose values have changed
    false – Returns all securities

    market * Currently not implemented completely, however, when implemented:
    This will identify which market the user would like information returned from


    tt – Gets data from Trinidad and Tobago Stock Exchange
    ja – Gets data from Jamaica Stock Exchange

    complexView * Currently not implemented completely, however, when implemented:

    This will determine whether more properties other than Tag, Volume, Open, Close and Change data will be returned

    true – Returns many more data columns
    false – Only returns Tag, Volume, Open, Close and Change columns

    styleUrl Only supported by the AsHtml operation

    When supplied, the HTML/XHTML document being returned by the call will be styled according to the CSS style sheet URL provided by this parameter

    Format: <any url> that points to a style sheet

    What all of that stuff up there means, is that if you would like to get the trade data for the 1st of June 2010 as a CSV you can go to the following URL:

    The same pattern can be applied to any of the API calls and multiple parameters can be used in any order as long as they are properly delimited by the ampersand ( ‘&’ ) character. Here is an example to get trade data as XML on a specific date with only changed items:

    The AsHtml?styleUrl parameter is an interesting one. Try using it without the parameter and then try using it with a sample style that I have provided. To make it easy I have provided the hyperlink below:

    The parameters all have default values, as the API matures and * if * you guys think it interesting/useful enough to make use of it, then I’ll provide comprehensive documentation. What this means for developers is that you can easily inject data from this service into you own website and style the information such that it is consistent with you website. Cool huh… well I think it’s pretty cool.

    I could go on a bit more about this, but I feel like the length of this post is getting out of hand … so I’ll start wrapping up …

    According to their website ( in the Trading System section, the TTSE has moved to an electronic platform some time ago:

    On March 18th 2005 the Trinidad and Tobago Stock Exchange Limited implemented an Electronic Trading System replacing the manual open outcry system which was used at the Exchange since its inception in 1981.

    Wouldn’t it be fantastic if we could actually programmatically interface with this system and not have to “hack” a solution to this problem? Well hopefully someone from the TTSE will see this and get some ideas about how it can help drive Trinidad and Tobago towards a more information-driven society.

    So, for all you coders out there, have fun with API’s and feel free to drop me a line at if you have any comments or suggestions as to how they can be improved or any bugs that there may be.

    PLEASE NOTE: These APIs are not supported by TTSE and there is no guarantee that I will absolutely have the time or resources to continue working on them, so I strongly suggest that you do not use these APIs on your production systems. If you wish to do so, contact me via email or by commenting on this post so that we can discuss further.


    Cordell Lawrence

    Tagged with: , , , ,
    Posted in .NET, Enterprise, Microsoft, Personal Projects, Research, Web 2.0, Web Services
    8 comments on “TT Stock Exchange Web Services anyone?
    1. ferron says:

      Hey Cordell nice post, but I am a bit disappointed that your API did not provide a JSON transport format. I would have like to see that, and it is much easier to traverse than the current formats. What are your thoughts ?

      • Hey Ferron, excellent question… really on this one, I simply forgot to implement it before… but as a result of you raising, I have just implemented it and I have just uploaded it to the site… I will make changes to the post momentarily.

        Much thanks for the feedback man!

    2. Steve Spence says:

      Hey Cordell

      Good stuff I am actually playing around with it

      keep up the good work

    3. Gyasi A says:

      Hey Cordell,

      What’s the update on this? Are you planning to continue work on it?

    4. Hasani says:

      You can interface directly with the TTSE’s trading system by signing up for a reader account. You have to pay an annual subscription fee but you’ll get access to real time trading data without having to ‘hack’ a solution.

    5. @Gasyi, I left the service up for a long time, but didn’t really see anyone hitting the web services, so I took it down. I still have the code and it still works, but not too many people seem interested.

      @Hasani, I knew there was some sort of subscription … when you say “interface directly with their system” what do you mean though? programmatically interface with the trading system?

    6. Hasani says:

      @Cordell Yes with a Viewer Package (see you are given a client application that can remotely connect to the trading system however I met a member of the TTSE’s IT department at MobiWorld and he mentioned that you could also write a custom application to do the interaction and use your subscription. I guess you’d have to implement the communication protocol yourself since I could not find any API’s for it

    7. Adolfo says:

      Appreciating the time and effodt you put into your website
      and dettailed information you offer. It’sgood to come across a blog every once in a while that
      isn’t the same old rehashed material. Great read! I’ve bookmarked
      your sitte and I’m including your RSS feeds to my Google account.

    Leave a Reply

    Fill in your details below or click an icon to log in: Logo

    You are commenting using your account. Log Out /  Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )


    Connecting to %s

    July 2011
    S M T W T F S
    « Jun   Aug »

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 410 other followers

    %d bloggers like this: