Writing market data to a CSV file


This example demonstrates how to export data from MarketFeeder Pro to a CSV file using the "write to file" trigger action. A CSV file stands for "comma separated values" and is basically just text with fields separated with commas or semicolons, e.g.:

Fair Lady";1.05;3;10.0

MarketFeeder Pro has a built-in function of writing to a file, which you can use to export any piece of data, an expression, a trigger variable of a combination of thereof to a text file of your choice.

In this example, we will be writing down BetFair Starting Prices (SP) for selections within the specified price range. We will then learn to open that file in Excel to view and analyse the results.


Click here to download the trigger file.

There are just two constants in this file, and they are needed to filter out selections by their SP. The constants are used for the sake of example only, just to reduce the size of the end file.

min_sp : Minimum SP of qualifyng selections;

max_sp : Maximum SP of qualifying selections.

In Action

Please bear in mind that exporting proprietary market data, such as prices and volumes, for commercial purposes violates the Terms and Conditions of the BetFair Historical Data Licence!

So let's take a look at the triggers:

Triggers writing to a file

Here we have two triggers:

1. writing headers at the beginning of the file

You can run this trigger to make your data look like a table with headers. At the beginning of your session, it will write the headers "MarketName", "SelectionName" and "SP" into the file at the provided path (in this case, d:\sp_prices.csv). Note that it has the option "Rewrite existing contents" ticked, i.e. it first empties the contents of the file (if there were any). You can disable this trigger if you do not need headers or if you do not want the file to be rewritten each time you restart the triggers.

2. writing to a file

Here the trigger actually writes the name of the market, the name of the qualifying selection and its SP to the specified file. The values are separated with commas, the text variables (market_name and sel_name) are enclosed in double quotes to keep spaces inside them.

If you run the triggers against a few markets, you will get something similar to this:

CSV file with selections' SP

Importing to Excel

Open Excel and switch to the Data tab. Go through the steps illustrated below, each time pressing "Next" until you get to the last screen.

Step 1:

Import data from text

Step 2:

Text import wizard

Step 3:

Text import wizard

Step 4:

Text import wizard

Step 5:

Data from the text file in Excel

If you have not heard of BetFair yet or do not have an account, register today and get £20 free. Use the link below:
New customers only, bet up to €/£20 on the Exchange and if your first bet loses, we’ll refund you €/£20 in Cash. Bet must be placed in first 7 days of account opening. T&Cs apply.
Gamble responsibly! Always be aware that betting is NOT risk-free. You must be 18+ years old before you try gambling, but even as an adult, withhold from spending money in an ill-judged manner. Our company does not encourage you to prefer gambling over other meaningful activities. If gambling is affecting your life or the lives of people close to you, please contact GamCare
© 2005-2023 WellDone Creative Software. All rights reserved. Terms and conditions.
BetFair® and the BetFair Logo are registered trade marks of Flutter Entertainment plc. Gamble responsibly.