Ghana Stock Exchange (GSE) API

Published on December 5, 2013 at 13:05 UTC Updated: 7 months, 3 weeks ago

IMAGE: "Reliable platform to query real-time GSE market data from.""Reliable platform to query real-time GSE market data from."

Once upon a time, I was looking for an API for the Ghana Stock Exchange to build an app which I don't even remember what it was about. After being tremendously disappointed that no such thing existed, I threw the idea into the Ghanaian ocean and went home to eat "yorkor gari" and "shitor." Last week, I stumbled upon Selasie Agbavor's Python API for Ghana Stock Exchange. I liked his implementation although it is a bit fallible. (See lines 18-19 and 25-30.) Then I said to myself, Why don't you build a real API for that? So I picked up my hoe and cutlass, and marched on to develop the first ever Ghana Stock Exchange API! (I doubt Selasie will join the cheer.)

Here are some questions I think you might ask, and may want to get straight answers to:

  • Where do you get the data from? I scrape them from the official website, gse.com.gh.
  • How often is the database updated? In real-time, using cron jobs and a secret protocol.
  • Is the code publicly available? Currently no, but hopefully, shortly will be.
  • For how long will this API be live? For as long as GSE shares the market data online.
  • Wud u rite da codez 4 ma PHP 4 me? No, unless you become a mummified Pharaoh.

Overview

This GSE API provides a reliable and consistent platform to query real-time trading statistics, in-depth market data and analysis, and authentic company information from the Ghana Stock Exchange. Also, it allows you to quickly and easily integrate the stock exchange's market data into your application, by launching simple HTTP requests. It's fast and easy to interact with. You don't have to sign up for any authentication keys before you can start using it. It's a free public web service! This webpage serves as the official documentation destination for the API. You may want to check out this GSE Live app that I've written to consume the API.

The API's request endpoint is http://apis.michaelkwayisi.com/gse. Currently, the response data format is available only in JSON and JSONP, however, support for XML and other data formats is being considered. When launching a request, you may append a prettify query string parameter to the URI to get the response data in human readable layout. (For example, http://apis.michaelkwayisi.com/gse/live?prettify.) One noteworthy thing is that, although some properties of the API objects are stated to be of type "float," their values may sometimes appear as integers, i.e. without decimal places. This anomaly may be corrected later.

Following are the various API resources and objects you should know about.

GET /live

This resource returns an array of equity_live objects, representing the real-time trading data for each symbol listed on the Ghana Stock Exchange.

Example request

http://apis.michaelkwayisi.com/gse/live

Example response

[
   {
       "change": 1.59,
       "name": "ABC",
       "price": 10.52,
       "volume": 230
   },
   {
       "change": -0.05,
       "name": "DEF",
       "price": 1.06,
       "volume": 1040
   },
   {
       "change": 0.01,
       "name": "GHI",
       "price": 37.17,
       "volume": 542
   }
]

GET /live/{symbol}

This resource returns an equity_live object, representing the real-time trading data for {symbol} on the Ghana Stock Exchange. If the specified ticker symbol is not found, an HTTP 404 status response is triggered.

Example request

http://apis.michaelkwayisi.com/gse/live/abc

Example response

{
   "change": 1.59,
   "name": "ABC",
   "price": 10.52,
   "volume": 230
}

GET /equities

This resource returns an array of equity_live objects without the "change" and "volume" properties, representing a summary of each equity listed on the Ghana Stock Exchange.

Example request

http://apis.michaelkwayisi.com/gse/equities

Example response

[
   {
       "name": "ABC",
       "price": 10.52
   },
   {
       "name": "DEF",
       "price": 1.06
   },
   {
       "name": "GHI",
       "price": 37.17
   }
]

GET /equities/{symbol}

This resource returns an equity object, representing in-depth market and company data for {symbol} on the Ghana Stock Exchange. If the specified ticker symbol is not found, an HTTP 404 status response is triggered.

Example request

http://apis.michaelkwayisi.com/gse/equities/abc

Example response

{
   "ask_price": 10.60,
   "bid_price": 10.50,
   "capital": 567.22,
   "close_price": 10.52,
   "company": {
       "address": "P. O. Box 123, Accra",
       "date_inc": "2013-01-01",
       "directors": [
           {
               "name": "Kofi Abanga",
               "position": "Chairman"
           },
           {
               "name": "Ama Nantwie",
               "position": null
           }
       ],
       "email": "abc@example.com",
       "facsimile": "+233 (302) 123 456",
       "industry": "Mining",
       "name": "ABC Company Ltd.",
       "notes": "Merged with XYZ company.",
       "office": "123rd Abrewa Rd., Accra",
       "sector": "Basic Materials",
       "telephone": "+233 (302) 123 789",
       "website": "http://abc.example.com"
   },
   "date_listed": "2013-02-01",
   "div_yield": 3.57,
   "dps": 0.077,
   "eps": 0.17,
   "isin": "GH0000000001",
   "last_price": 10.52,
   "name": "ABC",
   "nrf_pct": 20.5,
   "open_price": 10.51,
   "pe_ratio": 19,
   "prev_price": 10.50,
   "shares": 36.5,
   "year_high": 10.78,
   "year_low": 9.52
}

Equity object

PropertyTypeNullableDescription
ask_pricefloatYesClosing asking/offer price.
bid_pricefloatYesClosing bid price.
capitalfloatNoMarket capitalization (in GHS millions).
close_pricefloatNoClosing share price.
companyobjectNoIssuing company. (Instance of company.)
date_listedstringYesDate listed on the exchange (YYYY-MM-DD).
div_yieldfloatYesDividend yield percentage.
dpsfloatYesDividend per share.
epsfloatYesEarnings per share.
isinstringNoInternational security identification number.
last_pricefloatNoLast transaction price.
namestringNoTicker symbol.
nrf_pctfloatYesNon-resident foreign investors' holding percentage.
open_pricefloatNoOpening share price.
pe_ratiofloatYesPrice/Earning ratio.
prev_pricefloatNoPrevious closing price.
sharesfloatNoTotal issued shares (in millions).
year_highfloatNoYear's high price.
year_lowfloatNoYear's low price.

Equity_Live object

PropertyTypeNullableDescription
changefloatNoPrice change.
namestringNoTicker symbol.
pricefloatNoShare price.
volumeintegerNoVolume of shares traded.

Company object

PropertyTypeNullableDescription
addressstringYesPostal address of company.
date_incstringYesDate of incorporation (YYYY-MM-DD).
directorsobjectNoBoard of directors. (Array of director instances.)
emailstringYesEmail address.
facsimilestringYesFacsimile number.
industrystringYesICB/GICS industry classification.
namestringNoName of company.
notesstringYesSummary of company profile.
officestringYesRegistered office.
sectorstringYesICB/GICS sector classification.
telephonestringYesTelephone number.
websitestringYesWebsite address.

Director object

PropertyTypeNullableDescription
namestringNoFull name.
positionstringYesJob title.

Comments (0)

Related Content

Copyright © 2014 Michael Kwayisi.