Closed petedmarsh closed 9 years ago
This looks good, but I proposed a few additional changes in https://github.com/petedmarsh/betfair.py/pull/1. Feedback welcome. Thanks for your help!
I've amended the commits to remove the HTTP header stuff and include the whitespace/spelling changes from https://github.com/petedmarsh/betfair.py/pull/1. To be honest I don't think it's worth having code that generates the prices: they don't changefamouslastwords and they'll just be computed over and over every time someone loads the module for the first time, so I've left those changes out :)
I forgot to add - I'm in two minds as to whether the prices should be Decimal
s, on the one hand the accuracy is desirable but if they're used here they should really be used everywhere, i.e. the models should convert numbers from API response to Decimal
, otherwise you can get type errors, e.g.:
Decimal('100') + 0.1
>>> TypeError: unsupported operand type(s) for +: 'Decimal' and 'float'
I went ahead and merged my revisions to the price
module. I'm more concerned about code reuse and developer efficiency than the cycles we might save by not computing prices on import. Plus, it takes about 100 μs to build PRICES
, and it's cached on import, so I'm not worried about performance :racehorse:.
Thanks again for the feature!
I just saw that you merged a couple of my open PRs, thanks! I have done some further work which I hadn't yet raised a PR for, here it is!
Changes:
nearest_price
,ticks_difference
andprice_ticks_away
The individual commit message themselves have more detailed information in. One thing I should add: the
nearest_price
method is based on an implementation from: https://github.com/AlgoTrader/betfair-sports-api/blob/master/lib/betfair_price.js that code is under the MIT license, and so a copyright notice might need to be added ("The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software." - I'm not sure if this counts as a copy or "substantial portion").