captain-igloo/greenthumb

Feature request: export

turkeyphant opened this issue · 3 comments

Would there be any way to add a feature to export the data of a market (runner, lay price/liquidity, back price/liquidity, last price matched) to a csv or similar?

Other data would also be great.

I was thinking about storing market data and then show the prices on a graph, with the ability to zoom in on part of it. I'm not sure how useful it would be since the exchange api doesn't let you retrieve historic market data. Anyway the table would have columns something like:

  • market id
  • selection id
  • insert datetime
  • last price traded
  • best back price
  • best back size
  • best lay price
  • best lay size

There would be one row inserted per market runner each time the market is refreshed.

Once that's done (ie storing the data, not the graphing) it wouldn't be difficult to export to csv, either from greenthumb or by reading the database (sqlite) directly.

Why do you want to do this, what will you use the csv for?

I currently scrape the website using jquery to get market data primarily for analysis in excel or Google sheets. The issue is that this is a fairly manual process and also that markets are too illiquid to draw conclusions from queued prices and last matched (which is much much more involved to scrape) is a better metric.

You should find using the API is a lot easier than scraping the website. But I don't reckon greenthumb is the right tool for something like this. Have you thought about using a scripting language like nodejs / python etc? There are plenty of libraries on github you can use. Using betfair-ts for example you could start with this :

import { ExchangeApi, ListMarketBookRequest } from 'betfair-ts';

const api = new ExchangeApi('<app key here>');
api.login('<username here>', '<password here>').then(async (result: boolean) => {
    if (result) {
    
        const request = new ListMarketBookRequest(['<market id here>']);
        
        if (request.isValid()) {
            const response = await api.listMarketBook(request);
            console.log('RESPONSE', response);
        }
    }
});

The last matched price for each runner is in the response from listMarketBook().