betfair 0.0.18 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -4
- data/README.md +383 -0
- data/{README → README_OLD} +7 -3
- data/examples/bar.rb +23 -0
- data/examples/foo.rb +1 -1
- data/examples/simplebot.log +4 -0
- data/examples/simplebot/README.md +51 -0
- data/examples/simplebot/daemonize.rb +8 -0
- data/examples/simplebot/monit.conf +6 -0
- data/examples/simplebot/simplebot.log +0 -0
- data/examples/simplebot/simplebot.rb +168 -0
- data/lib/betfair/api.rb +167 -105
- data/lib/betfair/version.rb +1 -1
- data/spec/betfair/api_spec.rb +92 -16
- data/spec/fixtures/cancel_bets_by_market/failure.xml +0 -0
- data/spec/fixtures/cancel_bets_by_market/success.xml +17 -0
- data/spec/fixtures/keep_alive/fail.xml +16 -0
- data/spec/fixtures/keep_alive/success.xml +16 -0
- data/spec/fixtures/logout/fail.xml +16 -0
- data/spec/fixtures/logout/success.xml +16 -0
- data/spec/fixtures/update_bets/fail.xml +27 -0
- data/spec/fixtures/update_bets/success.xml +27 -0
- metadata +37 -13
data/.gitignore
CHANGED
data/README.md
ADDED
@@ -0,0 +1,383 @@
|
|
1
|
+
# BETFAIR API #
|
2
|
+
## Install the gem ##
|
3
|
+
|
4
|
+
Install it with [RubyGems](http://rubygems.org/gems/betfair)
|
5
|
+
|
6
|
+
gem install betfair
|
7
|
+
|
8
|
+
or add this to your Gemfile if you use [Bundler](http://gembundler.com/):
|
9
|
+
|
10
|
+
gem 'betfair'
|
11
|
+
|
12
|
+
## Introduction
|
13
|
+
In a irb console
|
14
|
+
|
15
|
+
require 'betfair'
|
16
|
+
|
17
|
+
From a Gemfile
|
18
|
+
|
19
|
+
gem 'betfair'
|
20
|
+
|
21
|
+
Load the general api class
|
22
|
+
|
23
|
+
bf = Betfair::API.new
|
24
|
+
|
25
|
+
If you want to use a proxy or turn on Savon's logging then just pass
|
26
|
+
in like so:
|
27
|
+
|
28
|
+
This is a local squid proxy I tunnel to from my local
|
29
|
+
machine to access the host server in UK for dev purposes.
|
30
|
+
|
31
|
+
proxy = 'http://localhost:8888'
|
32
|
+
logging = true
|
33
|
+
bf = Betfair::API.new(proxy, logging)
|
34
|
+
|
35
|
+
Proxies can be useful if you want to host on a cloud service such as
|
36
|
+
Heroku, as you will be denied access to the Betfair API from the
|
37
|
+
USA. Just proxy via a server from a country that Betfair allows, such
|
38
|
+
as the UK.
|
39
|
+
|
40
|
+
# General API METHODS #
|
41
|
+
## Login ##
|
42
|
+
At the heart of the Betfair API is the `session_token`. In order to
|
43
|
+
get one of these simply call:
|
44
|
+
|
45
|
+
username = 'foo'
|
46
|
+
password = 'bar'
|
47
|
+
product_id = 82
|
48
|
+
vendor_software_id = 0
|
49
|
+
location_id = 0
|
50
|
+
ip_address = nil
|
51
|
+
|
52
|
+
session_token = bf.login(username, password, product_id, vendor_software_id, location_id, ip_address)
|
53
|
+
|
54
|
+
The `session_token` value you get back responds to #success? which will tell you whether login
|
55
|
+
was successful or not. If `session_token.success?` returns false,
|
56
|
+
`session_token.to_s` will give you the error message.
|
57
|
+
|
58
|
+
The standard `product_id` is 82, you may have a different one depending
|
59
|
+
on the level of Betfair API access that you have.
|
60
|
+
|
61
|
+
## Logout ##
|
62
|
+
It is considered good API etiquette to logout once you are done.
|
63
|
+
|
64
|
+
foo = bf.logout(session_token)
|
65
|
+
|
66
|
+
## Keep Alive ##
|
67
|
+
Your session_token will expire after 20 mins of inactivity.
|
68
|
+
Supposedly the token gets refreshed with every API call you make,
|
69
|
+
but I am not convinced of this.
|
70
|
+
This call will refresh it for another 20 mins.
|
71
|
+
|
72
|
+
session_token = bf.keep_alive(session_token)
|
73
|
+
|
74
|
+
# Read-Only Betting API METHODS #
|
75
|
+
## Get All Markets ##
|
76
|
+
The API GetAllMarkets service allows you to retrieve information about all of
|
77
|
+
the markets that are currently active or suspended on the given exchange.
|
78
|
+
|
79
|
+
exchange_id = 1 # 1 == UK, 2 == AUS
|
80
|
+
event_type_ids = [1,3] # Full list here http://data.betfair.com/sportids.htm
|
81
|
+
locale = nil
|
82
|
+
countries = nil
|
83
|
+
from_date = Time.now.utc
|
84
|
+
to_date = 30.minutes.from_now.utc
|
85
|
+
|
86
|
+
markets =
|
87
|
+
bf.get_all_markets(session_token, exchange_id, event_type_ids, locale, countries, from_date, to_date)
|
88
|
+
|
89
|
+
##Get MU Bets
|
90
|
+
The API GetMUBets service allows you to retrieve information about all
|
91
|
+
your matched and unmatched bets on a particular exchange server.
|
92
|
+
|
93
|
+
exchange_id = 1
|
94
|
+
market_id = 12345
|
95
|
+
bet_status = 'MU'
|
96
|
+
start_record = 0
|
97
|
+
record_count = 200
|
98
|
+
sort_order = 'ASC'
|
99
|
+
order_by = 'PLACED_DATE'
|
100
|
+
|
101
|
+
mu_bets =
|
102
|
+
bf.get_mu_bets(session_token, exchange_id, market_id, bet_status, start_record, record_count, sort_order, order_by)
|
103
|
+
|
104
|
+
## Get Market ##
|
105
|
+
The API GetMarket service allows the customer to input a Market ID and
|
106
|
+
retrieve all static market data for the market requested.
|
107
|
+
|
108
|
+
exchange_id = 1
|
109
|
+
market_id = 12345
|
110
|
+
locale = nil
|
111
|
+
|
112
|
+
market
|
113
|
+
= bf.get_market(session_token, exchange_id, market_id, locale)
|
114
|
+
|
115
|
+
## Get Market Prices Compressed ##
|
116
|
+
The API GetMarketPricesCompressed service allows you to retrieve
|
117
|
+
dynamic market data for a given Market ID in a compressed format.
|
118
|
+
|
119
|
+
exchange_id = 1
|
120
|
+
market_id = 12345
|
121
|
+
currency_code = nil
|
122
|
+
|
123
|
+
price =
|
124
|
+
bf.get_market_prices_compressed(session_token, exchange_id, market_id, currency_code)
|
125
|
+
|
126
|
+
## Get Active Event Types ##
|
127
|
+
The API GetAllEventTypes service allows the customer to retrieve lists of all categories of sports
|
128
|
+
(Games, Event Types) that have at least one market associated with them,
|
129
|
+
regardless of whether that market is now closed for betting.
|
130
|
+
|
131
|
+
locale = nil
|
132
|
+
|
133
|
+
active_event_types =
|
134
|
+
bf.get_active_event_types(session_token, locale)
|
135
|
+
|
136
|
+
## Get Account Funds ##
|
137
|
+
The API GetAccountFunds service allows you to retrieve information
|
138
|
+
about your local wallet on a particular exchange server.
|
139
|
+
|
140
|
+
exchange_id = 1
|
141
|
+
|
142
|
+
funds =
|
143
|
+
bf.get_account_funds(session_token, exchange_id)
|
144
|
+
|
145
|
+
# Bet Placement API METHODS #
|
146
|
+
## Place Bet ##
|
147
|
+
The API PlaceBets service allows you to place multiple (1 to 60) bets on a single Market.
|
148
|
+
|
149
|
+
exchange_id = 1
|
150
|
+
market_id = 122435
|
151
|
+
selection_id = 58805
|
152
|
+
bet_type = 'B' # Or L for Lay
|
153
|
+
price = 2.0
|
154
|
+
size = 2.0
|
155
|
+
|
156
|
+
place_bet =
|
157
|
+
bf.place_bet(session_token, exchange_id, market_id, selection_id, bet_type, price, size)
|
158
|
+
|
159
|
+
## Place Multiple Bets ##
|
160
|
+
The API PlaceBets service allows you to place multiple (1 to 60) bets on a single Market.
|
161
|
+
|
162
|
+
exchange_id = 1
|
163
|
+
bets = []
|
164
|
+
bets << { market_id: 12345, runner_id: 58805, bet_type: 'B', price: 2.0, size: 2.0, asian_line_id: 0,
|
165
|
+
bet_category_type: 'E', bet_peristence_type: 'NONE', bsp_liability: 0 }
|
166
|
+
bets << { market_id: 12345, runner_id: 1234, bet_type: 'L', price: 1.5, size: 2.0, asian_line_id: 0,
|
167
|
+
bet_category_type: 'E', bet_peristence_type: 'NONE', bsp_liability: 0 }
|
168
|
+
|
169
|
+
place_multiple_bets =
|
170
|
+
bf.place_multiple_bets(session_token, exchange_id, bets)
|
171
|
+
|
172
|
+
## Update Bet ##
|
173
|
+
The API UpdateBets service allows you to edit multiple (1 to 15) bets on a single Market.
|
174
|
+
|
175
|
+
exchange_id = 1
|
176
|
+
bet_id: 1234,
|
177
|
+
new_bet_persistence_type = 'NONE'
|
178
|
+
new_price = 10.0
|
179
|
+
new_size = 10.0
|
180
|
+
old_bet_persistence_type = 'NONE'
|
181
|
+
old_price= 5.0
|
182
|
+
old_size = 5.0
|
183
|
+
|
184
|
+
update_bet =
|
185
|
+
bf.update_bet(session_token, exchange_id, bet_id, new_bet_persistence_type, new_price, new_size, old_bet_persistence_type, old_price, old_size)
|
186
|
+
|
187
|
+
## Update Multiple Bets ##
|
188
|
+
The API UpdateBets service allows you to edit multiple (1 to 15) bets on a single Market.
|
189
|
+
|
190
|
+
exchange_id = 1
|
191
|
+
bets = []
|
192
|
+
bets << { bet_id: 1234, new_bet_persistence_type: 'NONE', new_price: 10.0, new_size: 10.0,
|
193
|
+
old_bet_persistence_type: 'NONE', old_price: 5.0, old_size: 5.0 }
|
194
|
+
bets << { bet_id: 1235, new_bet_persistence_type: 'NONE', new_price: 2.0, new_size: 10.0,
|
195
|
+
old_bet_persistence_type: 'NONE', old_price: 5.0, old_size: 5.0 }
|
196
|
+
|
197
|
+
update_multiple_bets =
|
198
|
+
bf.update_multiple_bets(session_token, exchange_id, bets)
|
199
|
+
|
200
|
+
|
201
|
+
## Cancel Bet ##
|
202
|
+
The API CancelBets service allows you to cancel multiple unmatched (1 to 40) bets placed on a single Market.
|
203
|
+
|
204
|
+
exchange_id = 1
|
205
|
+
bet_id = 1235
|
206
|
+
|
207
|
+
cancel_bet =
|
208
|
+
bf.cancel_bet(session_token, exchange_id, bet_id)
|
209
|
+
|
210
|
+
## Cancel Multiple Bets ##
|
211
|
+
The API CancelBets service allows you to cancel multiple unmatched (1 to 40) bets placed on a single Market.
|
212
|
+
|
213
|
+
exchange_id = 1
|
214
|
+
bet_ids = [16939689578, 16939689579, 169396895710]
|
215
|
+
|
216
|
+
cancel_multiple_bets =
|
217
|
+
bf.cancel_multiple_bets(session_token, exchange_id, bets)
|
218
|
+
|
219
|
+
# Helpers #
|
220
|
+
There are a bunch of helper methods to help you handle the output from the various API calls.
|
221
|
+
|
222
|
+
helpers = Betfair::Helpers.new
|
223
|
+
|
224
|
+
## All Markets ##
|
225
|
+
When you call
|
226
|
+
|
227
|
+
all_markets = bf.get_all_markets(session_token, 2, [61420], nil, nil, nil, nil)
|
228
|
+
|
229
|
+
you get back a string of all the Australian Rules markets.
|
230
|
+
|
231
|
+
Pump it into this helper and you will get back a nice hash.
|
232
|
+
|
233
|
+
foo = helpers.all_markets(all_markets)
|
234
|
+
|
235
|
+
This returns a hash with the `market_id` as the key.
|
236
|
+
|
237
|
+
foo[100388290] returns
|
238
|
+
|
239
|
+
{ :market_id=>100388290, :market_name=>"Premiers 2012", :market_type=>"O", :market_status=>"ACTIVE", :event_date=>2012-03-24 16:20:00 +0800,
|
240
|
+
:menu_path=>"\\Australian Rules\\AFL 2012", :event_hierarchy=>"/61420/26759191/100388290", :bet_delay=>"0", :exchange_id=>2,
|
241
|
+
:iso3_country_code=>"AUS", :last_refresh=>2012-03-29 16:35:21 +0800, :number_of_runners=>18, :number_of_winners=>1,
|
242
|
+
:total_amount_matched=>193599.58, :bsp_market=>false, :turning_in_play=>false
|
243
|
+
}
|
244
|
+
|
245
|
+
## Split Markets String ##
|
246
|
+
This function does the same as the #all_markets method. Not sure how/why it has been
|
247
|
+
duplicated, but it has so here is how it works.
|
248
|
+
|
249
|
+
all_markets = bf.get_all_markets(session_token, 2, [61420], nil, nil, nil, nil)
|
250
|
+
foo = helpers.split_markets_string(all_markets)
|
251
|
+
|
252
|
+
The output looks a little different to the #all_markets method.
|
253
|
+
|
254
|
+
foo.first returns
|
255
|
+
|
256
|
+
{ :market_id=>100388290, :market_name=>"Premiers 2012", :market_type=>"O", :market_status=>"ACTIVE", :event_date=>2012-03-24 08:20:00 UTC,
|
257
|
+
:menu_path=>"\\Australian Rules\\AFL 2012", :event_heirachy=>"/61420/26759191/100388290", :bet_delay=>0, :exchange_id=>2,
|
258
|
+
:iso3_country_code=>"AUS", :last_refresh=>2012-03-29 09:10:12 UTC, :number_of_runners=>18, :number_of_winners=>1,
|
259
|
+
:total_amount_matched=>193657.0, :bsp_market=>false, :turning_in_play=>false
|
260
|
+
}
|
261
|
+
|
262
|
+
## Market Info ##
|
263
|
+
This helper sorts out a nice hash from the
|
264
|
+
|
265
|
+
market = bf.get_market(session_token, 2, 100388290)
|
266
|
+
foo = helpers.market_info(details)
|
267
|
+
|
268
|
+
Which returns
|
269
|
+
|
270
|
+
{ :exchange_id=>nil, :market_type_id=>nil, :market_matched=>nil, :menu_path=>"\\AFL 2012", :market_id=>"100388290", :market_name=>"Premiers 2012", :market_type_name=>"AFL 2012" }
|
271
|
+
|
272
|
+
## Prices ##
|
273
|
+
This helper cleans up the prices
|
274
|
+
|
275
|
+
prices = bf.get_market_prices_compressed(session_token, 2, 100388290)
|
276
|
+
foo = helpers.prices(prices)
|
277
|
+
|
278
|
+
## Combine ##
|
279
|
+
Use this to combine `runner_names` and prices from the #market_info and #prices helpers
|
280
|
+
|
281
|
+
market = bf.get_market(session_token, 2, 100388290)
|
282
|
+
prices = bf.get_market_prices_compressed(session_token, 2, 100388290)
|
283
|
+
foo = helpers.combine(market, prices)
|
284
|
+
|
285
|
+
foo.first returns
|
286
|
+
|
287
|
+
{ :runner_id=>39983, :runner_name=>"Collingwood Magpies", :market_id=>100388290, :market_type_id=>61420,
|
288
|
+
:prices_string=>"39983~0~89899.79~4.2~~~false~~~~|4.2~430.35~L~1~4.1~311.51~L~2~3.85~4.75~L~3~|4.4~155.46~B~1~4.6~230.69~B~2~5.9~100.3~B~3~",
|
289
|
+
:runner_matched=>89899.79, :last_back_price=>4.2, :wom=>0.6054936499440416, :b1=>4.2, :b1_available=>430.35, :b2=>4.1, :b2_available=>311.51,
|
290
|
+
:b3=>3.85, :b3_available=>4.75, :l1=>4.4, :l1_available=>155.46, :l2=>4.6, :l2_available=>230.69, :l3=>5.9, :l3_available=>100.3
|
291
|
+
}
|
292
|
+
|
293
|
+
## Details ##
|
294
|
+
Gets the `market_id`/`market_name` and the `runner_id`/`runner_name`
|
295
|
+
|
296
|
+
market = bf.get_market(session_token, 2, 100388290)
|
297
|
+
foo = helpers.details(market)
|
298
|
+
|
299
|
+
Which returns
|
300
|
+
|
301
|
+
{ :market_id=>100388290, :market_type_id=>61420,
|
302
|
+
:runners=>[{:runner_id=>39983, :runner_name=>"Collingwood Magpies"}, {:runner_id=>244664, :runner_name=>"Hawthorn Hawks"},
|
303
|
+
{:runner_id=>244663, :runner_name=>"Geelong Cats"}, {:runner_id=>244689, :runner_name=>"Carlton Blues"},
|
304
|
+
{:runner_id=>210344, :runner_name=>"West Coast Eagles"}, {:runner_id=>244666, :runner_name=>"Fremantle Dockers"},
|
305
|
+
{:runner_id=>244688, :runner_name=>"St Kilda Saints"}, {:runner_id=>244665, :runner_name=>"Sydney Swans"},
|
306
|
+
{:runner_id=>173363, :runner_name=>"Adelaide Crows"}, {:runner_id=>210343, :runner_name=>"Essendon Bombers"},
|
307
|
+
{:runner_id=>39986, :runner_name=>"Western Bulldogs"}, {:runner_id=>244667, :runner_name=>"Richmond Tigers"},
|
308
|
+
{:runner_id=>2013991, :runner_name=>"North Melbourne Kangaroos"}, {:runner_id=>39987, :runner_name=>"Melbourne Demons"},
|
309
|
+
{:runner_id=>39984, :runner_name=>"Brisbane Lions"}, {:runner_id=>217710, :runner_name=>"Port Adelaide Power"},
|
310
|
+
{:runner_id=>4997061, :runner_name=>"Gold Coast Suns"}, {:runner_id=>5149403, :runner_name=>"Greater Western Sydney Giants"}]
|
311
|
+
}
|
312
|
+
|
313
|
+
## Prices Complete ##
|
314
|
+
Helper to deal with the prices string from a market.
|
315
|
+
|
316
|
+
prices = bf.get_market_prices_compressed(session_token, 2, 100388290)
|
317
|
+
foo = helpers.prices_complete(prices)
|
318
|
+
|
319
|
+
foo.first returns
|
320
|
+
|
321
|
+
[ 39983, {:selection_id=>39983, :order_index=>0, :total_amount_matched=>89899.79, :last_price_matched=>4.2, :handicap=>0.0,
|
322
|
+
:reduction_factor=>0.0, :vacant=>false, :far_sp_price=>0.0, :near_sp_price=>0.0, :actual_sp_price=>0.0, :prices_string=>nil,
|
323
|
+
:runner_matched=>0, :last_back_price=>0, :wom=>0.5516492637413943, :b1=>4.2, :b1_available=>429.06, :b2=>4.1, :b2_available=>310.58,
|
324
|
+
:b3=>3.85, :b3_available=>4.75, :l1=>4.3, :l1_available=>20.0, :l2=>4.4, :l2_available=>355.0, :l3=>4.6, :l3_available=>230.0}
|
325
|
+
]
|
326
|
+
|
327
|
+
## Prices String ##
|
328
|
+
|
329
|
+
prices = bf.get_market_prices_compressed(session_token, 2, 100388290)
|
330
|
+
foo = helpers.price_string(prices, true)
|
331
|
+
|
332
|
+
{ :prices_string=>nil, :runner_matched=>0, :last_back_price=>0, :wom=>0.6054936499440416, :b1=>4.2, :b1_available=>430.35, :b2=>4.1, :b2_available=>311.51, :b3=>3.85,
|
333
|
+
:b3_available=>4.75, :l1=>4.4, :l1_available=>155.46, :l2=>4.6, :l2_available=>230.69, :l3=>5.9, :l3_available=>100.3
|
334
|
+
}
|
335
|
+
|
336
|
+
# Extra
|
337
|
+
## API Limits ##
|
338
|
+
[Betfair API Limits](http://bdp.betfair.com/index.php?option=com_content&task=view&id=36&Itemid=64)
|
339
|
+
|
340
|
+
## Requirements ##
|
341
|
+
* savon
|
342
|
+
|
343
|
+
## Requirements for testing ##
|
344
|
+
* savon_spec
|
345
|
+
* rspec
|
346
|
+
* rake
|
347
|
+
|
348
|
+
## To Do ##
|
349
|
+
* The WOM of money in Helpers#price_string returns 0 if either all b1,b2,b3 or l1,l2,l3 are all 0
|
350
|
+
* Add some error checking to the Betfair::Helper methods
|
351
|
+
* Finish of the mash method, to return a nice hash of all market and runner info
|
352
|
+
* Write a spec for the mashed method
|
353
|
+
|
354
|
+
## Contribute ##
|
355
|
+
I have only added the Betfair API method calls that I need.
|
356
|
+
|
357
|
+
Feel free to fork this repo, add what you need to with the relevant
|
358
|
+
RSpec tests and send me a pull request.
|
359
|
+
|
360
|
+
|
361
|
+
## License ##
|
362
|
+
(The MIT License)
|
363
|
+
|
364
|
+
Copyright (c) 2011 Luke Byrne
|
365
|
+
|
366
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
367
|
+
a copy of this software and associated documentation files (the
|
368
|
+
'Software'), to deal in the Software without restriction, including
|
369
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
370
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
371
|
+
permit persons to whom the Software is furnished to do so, subject to
|
372
|
+
the following conditions:
|
373
|
+
|
374
|
+
The above copyright notice and this permission notice shall be
|
375
|
+
included in all copies or substantial portions of the Software.
|
376
|
+
|
377
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
378
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
379
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
380
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
381
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
382
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
383
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/{README → README_OLD}
RENAMED
@@ -44,8 +44,7 @@ as the UK.
|
|
44
44
|
At the heart of the Betfair API is the `session_token`. In order to
|
45
45
|
get one of these simply call:
|
46
46
|
|
47
|
-
session_token = bf.login('username', 'password',
|
48
|
-
::Betfair::API;;PRODUCT_ID_FREE, 0, 0, nil)
|
47
|
+
session_token = bf.login('username', 'password', 82, 0, 0, nil)
|
49
48
|
|
50
49
|
Username and Password are fairly obvious. The `session_token` value
|
51
50
|
you get back responds to #success? which will tell you whether login
|
@@ -55,7 +54,7 @@ was successful or not. If `session_token.success?` returns false,
|
|
55
54
|
82 is the standard Product Id, you may have a different one depending
|
56
55
|
on the level of Betfair API access that you have.
|
57
56
|
|
58
|
-
You can ignore the rest
|
57
|
+
You can ignore the rest and leave as is, but they refer to Vendor
|
59
58
|
Software Id, Location Id, Ip Address as required by the Betfair API.
|
60
59
|
|
61
60
|
-----
|
@@ -105,6 +104,11 @@ Bet
|
|
105
104
|
bf.place_bet(session_token, 1, 104184109, 58805, 'B', 10.0, 5.0)
|
106
105
|
bf.cancel_bet(session_token, 1, 16939730542)
|
107
106
|
|
107
|
+
----------
|
108
|
+
API Limits
|
109
|
+
----------
|
110
|
+
http://bdp.betfair.com/index.php?option=com_content&task=view&id=36&Itemid=64
|
111
|
+
|
108
112
|
------------
|
109
113
|
Requirements
|
110
114
|
------------
|
data/examples/bar.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'betfair'
|
2
|
+
|
3
|
+
bf = Betfair::API.new
|
4
|
+
helpers = Betfair::Helpers.new
|
5
|
+
|
6
|
+
# Test your API limits out
|
7
|
+
|
8
|
+
1.times do |i|
|
9
|
+
session_token = bf.login('username', 'password', 264, 0, 0, nil).to_s
|
10
|
+
puts session_token
|
11
|
+
puts i
|
12
|
+
end
|
13
|
+
|
14
|
+
20.times do |i|
|
15
|
+
puts bf.get_all_markets(session_token, 2, [1,3], nil, nil, '2012-01-23', '2012-01-24').split(':')
|
16
|
+
puts i
|
17
|
+
end
|
18
|
+
|
19
|
+
40.times do |i|
|
20
|
+
details = bf.get_market(session_token, 1, 104678293)
|
21
|
+
prices = bf.get_market_prices_compressed(session_token, 1, 104678293)
|
22
|
+
puts helpers.combine(details, prices)
|
23
|
+
end
|
data/examples/foo.rb
CHANGED
@@ -30,7 +30,7 @@ markets.each do |market|
|
|
30
30
|
prices = bf.get_market_prices_compressed(session_token, 1, market_id)
|
31
31
|
|
32
32
|
# Pump the data into the helpers
|
33
|
-
|
33
|
+
bf.get_market(session_token, 1, market_id)
|
34
34
|
puts helpers.market_info(details)
|
35
35
|
puts ""
|
36
36
|
puts helpers.combine(details, prices)
|