Polling JSE market data

<?php?>

Well-Known Member
Joined
Nov 15, 2010
Messages
367
I wan't to poll both current and historical JSE market data for specific companies into a local database, from where I will perform analitical queries.

Any idea from where I can poll and the API documentation. The app will be for personal use only, and poll data for my personal watchlist, about ten companies.

Thanks in advance.
 

DJ...

Banned
Joined
Jan 24, 2007
Messages
70,287
All of the market data companies provide this, as well as an excel plugin to pull data directly into excel. JSE provide this in a limited fashion. Basically, there is no need to develop an app. You can obtain a licence from one of the market data providers for around the same cost, and you can bolt on various feeds, watchlists, portfolio management functions, excel analytics, news feeds, SENS announcements etc...
 

Gushesh

Well-Known Member
Joined
Sep 12, 2009
Messages
370
@<?php?> What did you end up doing? I had a similar idea to create my own app for my watchlist.
 

Tjoker

Expert Member
Joined
Sep 22, 2009
Messages
1,662
Bump, just curious to know if something came of this?

Im looking to code a java app with bloomberg API as expermiment
 

Hamster

Resident Rodent
Joined
Aug 22, 2006
Messages
42,928
Open Blomberg is meh. What I did at one stage is look at Blomberg's quote page's source. There is an API they call with the ticker code. Brings back a nice JSON struct with all the details they use on the quote page...
 

Thor

Honorary Master
Joined
Jun 5, 2014
Messages
44,236
Open Blomberg is meh. What I did at one stage is look at Blomberg's quote page's source. There is an API they call with the ticker code. Brings back a nice JSON struct with all the details they use on the quote page...

Going to look into that.

I am building something similar, on my personal website I want to add a little investment section where I have everything I want.

Since I'll rather use that of I can get all the info I want on one page instead of going through multiple websites
 

Hamster

Resident Rodent
Joined
Aug 22, 2006
Messages
42,928
Going to look into that.

I am building something similar, on my personal website I want to add a little investment section where I have everything I want.

Since I'll rather use that of I can get all the info I want on one page instead of going through multiple websites

Here you go:
Code:
package main

import (
	"encoding/json"
	"flag"
	"fmt"
	"io/ioutil"
	"net/http"
	"os"
	"os/exec"
	"runtime"
	"strings"
	"text/tabwriter"
	"time"
)

var (
	codeStr        = flag.String("c", "NFSWIX:SJ,DBXWD:SJ", "bloomberg instrument codes")
	updateInterval = flag.Duration("i", 1*time.Minute, "")
)

type quoteResult struct {
	SecurityType string     `json:"securityType"`
	BasicQuote   basicQuote `json:"basicQuote"`
}

type basicQuote struct {
	ID                string    `json:"id"`
	Name              string    `json:"name"`
	OpenPrice         int32     `json:"openPrice"`
	Price             int32     `json:"price"`
	PercentChange1Day float32   `json:"percentChange1Day"`
	LastUpdateISO     time.Time `json:"lastUpdateISO"`
}

func main() {
	flag.Parse()

	codes := strings.Split(*codeStr, ",")

	for {
		clearScreen()
		w := tabwriter.NewWriter(os.Stdout, 0, 0, 4, ' ', 0)
		fmt.Fprintln(w, fmt.Sprintf("%s\t%s\t%s\t%s\t%s", "ID", "OPEN", "NOW", "CHANGE %", "DATE"))

		for _, c := range codes {
			res, err := query(c)
			if err != nil {
				fmt.Fprintln(w, fmt.Sprintf("%s\t%d\t%d\t%d\t%s", "", 0, 0, 0, err))
			} else {
				timeHere := res.BasicQuote.LastUpdateISO.In(time.Local)

				fmt.Fprintln(w, fmt.Sprintf("%s\t%d\t%d\t%f\t%s", res.BasicQuote.ID, res.BasicQuote.OpenPrice, res.BasicQuote.Price, res.BasicQuote.PercentChange1Day, timeHere))
			}
		}

		w.Flush()

		<-time.After(*updateInterval)
	}
}

func query(code string) (*quoteResult, error) {
	url := fmt.Sprintf("http://www.bloomberg.com/markets/api/quote-page/%s", code)

	resp, err := http.Get(url)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	var res *quoteResult
	err = json.Unmarshal(body, &res)
	if err != nil {
		return nil, err
	}

	return res, nil
}

func clearScreen() {
	var cmd *exec.Cmd

	if runtime.GOOS == "windows" {
		cmd = exec.Command("cmd", "/c", "cls")
	} else {
		cmd = exec.Command("clear")
	}

	cmd.Stdout = os.Stdout
	cmd.Run()
}

Basically: http://www.bloomberg.com/markets/api/quote-page/LON:SJ for "lommy"
 
Last edited:

Thor

Honorary Master
Joined
Jun 5, 2014
Messages
44,236
@Hamster.

Is there a way I can achieve this that Sharenet has on their website: I suspect it might be a bespoke solution, but would like to try and get something similar.

Top 10 Moves
2016-05-18_13-04-10.jpg
 

Hamster

Resident Rodent
Joined
Aug 22, 2006
Messages
42,928
@Hamster.

Is there a way I can achieve this that Sharenet has on their website: I suspect it might be a bespoke solution, but would like to try and get something similar.

Top 10 Moves
View attachment 362646

You'll have to check if that info is available on Bloomberg and use the feed their page uses, or get a list of all the share codes, pull them all and work it out yourself.
 

Thor

Honorary Master
Joined
Jun 5, 2014
Messages
44,236
You'll have to check if that info is available on Bloomberg and use the feed their page uses, or get a list of all the share codes, pull them all and work it out yourself.

I'm in the deep end:(
 

Thor

Honorary Master
Joined
Jun 5, 2014
Messages
44,236
@hamster.

Would you be open for the possibility of helping me getting that bloomberg data displays using say: http://www.highcharts.com/

Since form what I read on http://www.highcharts.com/ is that they give you the charting software, but you will need to feed your own data and me being a front end fundi I am at a bit of lost when it comes to how to pull in data.

This is for my personal website ( I have someone else going atm that I am building there, but would like to use the beauty of http://www.highcharts.com/ with actual data. ) Let me finish this site of mine as it is then I will pm you the link to see what I mean, if that is okey with you?
 
Top