Coder Social home page Coder Social logo

bfpy's Introduction

BfPy is a Python library to communicate wit the Betfair Betting Exchange
using the Betfair API (see <http://bdp.betfair.com>)

Copyright (C) 2010 Daniel Rodriguez (aka Daniel Rodriksson)
Copyright (C) 2011 Sensible Odds Ltd.

You can learn more and contact the author at:

    http://code.google.com/p/bfpy/

BfPy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

ByPy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with BfPy. If not, see <http://www.gnu.org/licenses/>.

-----
BfPy uses suds as the underlying WSDL/SOAP engine. suds is distributed
under the terms of the LGPL. No copy of the LGPL license is distributed
along with suds, so one is include in the LICENSE file.

You may also visit, see <http://www.gnu.org/licenses/>.

bfpy's People

Contributors

mementum avatar

Stargazers

Paschal Maduhu avatar

Watchers

James Cloos avatar  avatar

bfpy's Issues

Extended PlaceBets (re-placement of failed Keep In-Play bets) restored

What steps will reproduce the problem?
1. Place bet in a market like Total Goals (which doesn't support persistence)

What is the expected output? What do you see instead?
Bet re-placed after it fails with "INVALID_PERSISTENCE"

Bet is re-placed but it is failing with INTERNAL_ERROR.

The descriptors need special __copy__ support to enable replicating the 
original bet.


Original issue reported on code.google.com by [email protected] on 22 Apr 2011 at 7:51

getMarketPricesCompressed throttling

hi, now i have personal api activated (and changed productId) but it still 
seems to be throttling there. first ~16 markets are checked at full speed, but 
than there is huge slow down. library doesn't throw exceptions & in every 
response is errorCode = "OK", minorErrorCode = None. 

v1.10

self.bfc = bfclient.BfClient( fullDirect=True )
self.bfc.login( username = self.c_bf_user, password = self.c_bf_pass, productId 
= self.c_bf_product_id )
r = self.bfc.getMarketPricesCompressed( bfpy.ExchangeUK, marketId = id )

Original issue reported on code.google.com by [email protected] on 21 May 2011 at 8:59

Problem with getting removedRunners

price_data = bf.getCompleteMarketPricesCompressed(bfpy.ExchangeUK, marketId=id)
for removed_runner in prices_data.completeMarketPrices.removedRunners:
     print removed_runner.selectionName

Two problems with this code . One is that sometimes (don`t know when exactly) 
bfpy  says 
'CompleteMarketPrices' object has no attribute 'removedRunners'

And the second problem is that selectionName doesn`t exist. And as i see 
removed_runner is a string with "R" value. Thats all. Maybe i use  it wrong? 
How should it be used?


Original issue reported on code.google.com by [email protected] on 27 Sep 2011 at 9:30

Error: 'NoneType' object has no attribute 'runners' on getMarket call

When i do api call  
bf.getMarket(bfpy.ExchangeUK,marketId=market.market_id)

Instead of market data i get this exception:
Call  Error: getMarket - Error: 'NoneType' object has no attribute 'runners'
It`s not consistent. It appear from time to time. At bf++ if i click markets - 
horse racing today card - and then click markets i will get this error from 
time to time too.
I use latest version of bfpy and bp++.

Original issue reported on code.google.com by [email protected] on 8 Jun 2011 at 8:28

Share Login credentials if a BfClient or BfApi instance is cloned before login

1. This will avoid to wait until the first login to clone the objects
2. Making it easier to prepare threads for different actions

Before the following was needed

import bfpy
bf = bfpy.BfClient()

bf1 = bf.clone()
bf.login(username='xx', password='yy')
bf2 = bf.clone

print bf2.username
>> 'xx'
print bf1.username
>> Error (exception thrown because bf1 doesn't have a username, because it was 
cloned before login)

With this feature:

import bfpy
bf = bfpy.BfClient(shareLogin=True)

bf1 = bf.clone()
bf.login(username='xx', password='yy')
bf2 = bf.clone

print bf2.username
>> 'xx'
print bf1.username
>> 'xx'

Original issue reported on code.google.com by [email protected] on 23 Apr 2011 at 7:46

Unable install this module on Python2.7.6 and win8-x64bit

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?
Unable install this module on Python2.7.6 and win8-x64bit

What version of the product are you using? On what operating system?
Unable install this module on Python2.7.6 and win8-x64bit

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 28 Mar 2014 at 6:56

Attachments:

getEvents returns empty marketItems.

What steps will reproduce the problem?
1. call getEvents i.e. events = bfClient.getEvents()
2. print events.marketItems is empty.

What is the expected output? What do you see instead?
We should be able to pass the eventTypeId i.e. 13 for Today's horse racing, and 
marketItems should show all of the races on Today's card.

What version of the product are you using? On what operating system?
1.13, Ubuntu 10.10

Please provide any additional information below.
If there is another way to find all the races on Today's Card, then this is not 
necessary, but please post the solution.

Original issue reported on code.google.com by [email protected] on 8 Sep 2011 at 6:01

getAllMarkets only seems to bring back football matches, regardless of the eventTypeId.

What steps will reproduce the problem?
1.create bfpy object.
2.use getAllMarkets with different eventTpyeIds
3.See that the output always only contains football matches.

What is the expected output? What do you see instead?
I'm looking ofr Ice Hockey, instead I get football.

What version of the product are you using? On what operating system?

Latest on windows 7.
Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 18 Mar 2012 at 10:08

bfpy does work on python3

The first line in the "Project Home" webpage here in code.google.com says:
"Python (>= 2.6.3/2.7.x) library to communicate with the Betfair Betting 
Exchange"
This is not true. bfpy does not work in python3
IMO the best solution is to correct the line in the webpage. The second 
solution is to make bfpy work on both python2.7 and python3, but I don't know 
if thats a good idea.

What steps will reproduce the problem?
1. open python3
2. import bfpy

What is the expected output?
The expected output is to see a clean import.

What do you see instead?
$ python3
Python 3.2.3 (default, Oct 19 2012, 20:10:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bfpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "bfpy/__init__.py", line 33, in <module>
    from bfglobals import *
ImportError: No module named bfglobals

What version of the product are you using? On what operating system?
1.13
Ubuntu 12.04.1 LTS


Original issue reported on code.google.com by [email protected] on 21 Dec 2012 at 4:49

Return Virtual Prices

As described in:

The API return the raw prices and amounts that are in the market, whilst the 
web site displays the so called "Virtual Prices" which show the best price that 
you can get matched at and the available amounts, given that lay prices and 
back prices are interchangeable.

http://bdp.betfair.com/index.php?option=com_content&task=view&id=237&Itemid=62




Original issue reported on code.google.com by [email protected] on 23 Apr 2011 at 8:02

createXXXX object lost with the removal of Suds

What steps will reproduce the problem?
1. Use one of the createXXXX (createMarket) functions
2. An exception is raised (KeyError)

The object should be created.

To be solved by creating named subclasses of EmptyObject and then instances if 
one of this functions is called


Original issue reported on code.google.com by [email protected] on 3 Jun 2011 at 7:03

getMarket not returning the time adjusted to local time zone

What steps will reproduce the problem?
1. Call getMarket for any market with well known time
2. See the marketTime


What is the expected output? What do you see instead?
The time adjusted to the local time zone.

But the market is only adjusted to compensate for DST but not to the local 
timezone




Original issue reported on code.google.com by [email protected] on 22 Apr 2011 at 5:33

Memory leak or feature?

Hello.
Thank you for very good library!!! I apologize in advance for my bad english.
I make betfair bot using bfby, all library function works fine, but my 
application grows in memory. For example, after 10 minutes run it 100 MB, after 
12 hours it about 900 MB (depending on the number of active markets).
After testing application with objgraph i found that most common types is dict, 
APIRequestHeader and GetMarketPricesCompressedReq:

dict                         655694
APIRequestHeader             628679
GetMarketPricesCompressedReq 305505
GetMUBetsReq                 305457
list                         66497
Price                        32278
UpdateBets                   7657
UpdateBetsReq                7657
function                     7102
RunnerPrices                 6482

As can be seen from the table objects dict, APIRequestHeader and 
GetMarketPricesCompressedReq takes more amount of memory.

After i try to find memory leaks in dict type. One example in attachment.
Also i tried find backreferences with objgraph/guppy. Most of APIRequestHeader 
and GetMarketPricesCompressedReq has references to instaceval dict.

If you had something to help me in solving this problem, I was very pleased.

Thanks in advance.

Original issue reported on code.google.com by [email protected] on 29 Oct 2012 at 8:45

Attachments:

login raises BfPythonError (OverflowError)

Hi,

thanks for this nice Python library. I came across the following bug during 
login:

What steps will reproduce the problem?

import bfpy
bf = bfpy.BfClient()
bfresp = bf.login(username='***', password='***')

What is the expected output? What do you see instead?

BfPythonError: ('login', OverflowError('date value out of range',), 'date value 
out of range', ('date value out of range',))

What version of the product are you using? On what operating system?

BfPy 1.13 on Windows Vista

Please provide any additional information below.

Same error with bfplusplus 1.05

Thanks

BG

Original issue reported on code.google.com by [email protected] on 2 May 2012 at 7:25

bf.getInPlayMarkets ERROR!!!! Why

What steps will reproduce the problem?

import sys

import bfpy
import bfpy.bfclient as bfclient

print 'Creating a Betfair Client'
bf = bfclient.BfClient()
print 'Created a Betfair Client'

#loginInfo = sys.modules['__main__'].loginInfo

response = bf.login(username='xxxxxxxx', password='xxxxxxxx')
print response

response2 = bf.getInPlayMarkets(bfpy.Exchange)
print response2

response3 = bf.getAllMarkets(bfpy.ExchangeUK)
print response3

response4 = bf.getPrivateMarkets(bfpy.ExchangeUK, eventTypeId=1)
print response4


What is the expected output? What do you see instead?

The expected output are allInPlayMarkets, instead of:

Creating a Betfair Client
Created a Betfair Client
(LoginResp){
   errorCode = "OK"
   (...)
 }
Traceback (most recent call last):
  File "C:\Users\xpta153\Dropbox\Eclipse\WebTests\src\tests\allmarkets.py", line 52, in <module>
    response2 = bf.getInPlayMarkets(bfpy.Exchange)
  File "C:\Users\xpta153\Dropbox\Eclipse\WebTests\src\bfpy\bfservice.py", line 253, in __call__
    request, self.skipErrorCodes)
  File "C:\Users\xpta153\Dropbox\Eclipse\WebTests\src\bfpy\bfapi.py", line 448, in invoke
    raise bferror.BfApiError(methodName, response, str(response), response.header.errorCode)
bfpy.bferror.BfApiError: ('getInPlayMarkets', <bfpy.bfutil.GetInPlayMarketsResp 
object at 0x01F3FC10>, '(GetInPlayMarketsResp){\n   errorCode = "API_ERROR"\n   
header = \n      (APIResponseHeader){\n         errorCode = 
"SERVICE_NOT_AVAILABLE_IN_PRODUCT"\n         timestamp = 2014-05-06 
12:56:57.232000\n         minorErrorCode = None\n         sessionToken = 
"7hjWMR5+4oai4597wDFOoYJQ1SEYhrq6MZXtDyon9cY="\n      }\n   marketData = None\n 
  minorErrorCode = None\n }', 'SERVICE_NOT_AVAILABLE_IN_PRODUCT')


What version of the product are you using? On what operating system?

 BfPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

windows operating system



Original issue reported on code.google.com by [email protected] on 6 May 2014 at 12:00

Arbitrary float input values (several decimal places) not handled properly for bet placement

What steps will reproduce the problem?
1. placeBets with a bet size, which has more than two decimal places, like 
2.3232323

What is the expected output? What do you see instead?
IMHO the API should handle these inputs in a way BF can treat them, i.e. round 
them properly and send them to BF then

BF returns INVALID_SIZE, if the floats are not processed properly. As far as I 
know, there are no inputs to the API, which would require more than two decimal 
places, so my suggestion would be, to handle float inputs in bftypes.py like 
that:

        if isinstance(value, (int, long, basestring)):
            pattern = str(value)
        elif isinstance(value, float):
            pattern = "%.2f" % value



Original issue reported on code.google.com by [email protected] on 17 Jun 2011 at 3:42

getCompleteMarketPricesCompressed

What steps will reproduce the problem?

Perfom a getCompleteMarketPrices request on a market with BSP enabled (e.g. a 
UK horse race)

What is the expected output? What do you see instead?

The returned object mixes up the BSP fields.

  totalBspBackAmount actually contains totalBspLayAmount
  totalBspLayAmount actually contains totalBspBackAmount
  nearBSP actually contains farBSP (pre-off at least)
  actualBSP actually contains nearBSP (pre-off at least)


What version of the product are you using? On what operating system?

HEAD version from a few days ago.

Original issue reported on code.google.com by [email protected] on 19 Aug 2011 at 9:30

Virtual prices still fail to fully merge all bets

What steps will reproduce the problem?
1. Under some price combinations a price will be repeated in a back/lay line


What is the expected output? What do you see instead?
Individual prices in each cell

Virtual bets may fail to be merged with the original bets of the same price or 
with virtual bets of the same price

Original issue reported on code.google.com by [email protected] on 3 Jun 2011 at 10:40

Implementation of New Features (createBet Utility Methods)

I've implemented some utility methods for the bfpy.bfclient.BfClient class. 
They greatly ease the process of creating bets (very much so in the case of 
starting price bets).

I have introduced a couple of new constants in the bfpy.bfglobals module and 6 
new methods in the bfpy.bfclient.BfClient class. They are:

    createExchangeBet
    createExchangeBackBet
    createExchangeLaybet
    createStartingPriceBet
    createStartingPriceBackbet
    createStartingPriceLayBet

I have a attached a patch, and I would very much like you to consider accepting 
this new code. I would be very happy to make changes if you so require.

Original issue reported on code.google.com by [email protected] on 28 Aug 2011 at 10:38

Attachments:

Informative Error Message on missing ExchangeId on Exchange calls

What steps will reproduce the problem?
1. Make an exchange call (like getMarket)
2. Do not pass "exchangeId" as the 1st unnamed parameter
3. The error message is about "tuples"

What is the expected output? What do you see instead?
An error message telling the user that he forgot to pass "exchangeId"


Original issue reported on code.google.com by [email protected] on 20 May 2011 at 1:05

Typo in bftimezone.py causes getAccountStatement to fail if called without parameters.

What steps will reproduce the problem?
1. Call getAccountStatement without parameters.

What is the expected output? What do you see instead?
Should return the most recent statement item.

What version of the product are you using? On what operating system?
1.13 but also checked the latest version in the repo.

Please provide any additional information below.
I have tracked the problem to the following segment of code.
In bftimezone.py from line 221 
The typo is on line 227 bfGlobals should be bfglobals

def getDateTimeNow():
    '''
    Returns the current time either in local time or utc
    according to the preferences in bfglobals. This datetime
    object is meant to be sent to the API servers
    '''
    if bfglobals.timeUtc or bfGlobals.timeUtcOut: #<-----Typo here
        return datetime.utcnow()

    return datetime.now()

Original issue reported on code.google.com by [email protected] on 2 Jul 2012 at 11:40

Front page

You write

except bfpy.BfErrror, e:

One r too many

except bfpy.BfError, e:

Original issue reported on code.google.com by [email protected] on 20 Mar 2013 at 3:50

Named returned objects

What steps will reproduce the problem?
Currently the parsed objects from the soap answer are from type "EmptyObject" 
(just a placeholder to hold attributes)

The objects could use the names provided in the soap answer (or inferred after 
parsing compressed answers) for better human readability during the learning 
process or debugging

Original issue reported on code.google.com by [email protected] on 3 Jun 2011 at 12:09

getAllMarkets returns a list of empty objects

What steps will reproduce the problem?
1. Create bfClient
2. Login
3. getEvents
4. markets = betfairClient.getAllMarkets(bfpy.ExchangeUK,eventTypeIds=7)

What is the expected output? What do you see instead?
Expected: marketData[] is filled with marketItems
Actual: A list of empty objects i.e. <bfpy.util.EmptyObject object at 
0x10781ce10>

What version of the product are you using? On what operating system?
0.81.  OSX with python 2.6.1

Please provide any additional information below.
Perhaps my usage is incorrect? Didn't see

Thanks!

Original issue reported on code.google.com by [email protected] on 30 Jan 2011 at 9:41

getSubscriptionInfo (vendor) collides with getSubscriptionInfo (Global)

What steps will reproduce the problem?
1. Try to call getSubscriptioInfo

What is the expected output? What do you see instead?
The expected output of the "global" call

But the "vendor" call is executed

The "vendor" call will be accessible as "getSubscriptionInfoVendor" to avoid 
name collision

Original issue reported on code.google.com by [email protected] on 24 May 2011 at 4:28

HttxsConnection no attribute '_tunnel_host'

What steps will reproduce the problem?
Following a example in httxlib:
1.from httxlib import *
2.manager = HttxManager()
3.request = HttxRequest('http://www.gmail.com')
4.try:
5.     response = manager.urlopen(request)
6.except RedirectError, e:
7.     print "Exception"
8.     print e

What is the expected output? What do you see instead?
I see this error:
AttributeError: HttxsConnection instance has no attribute '_tunnel_host'


What version of the product are you using? On what operating system?
The latest version. OS: Mac OS X, 10.5.8 with python 2.6

Please provide any additional information below.
The stack of errors: (I'm using a virtualenv but outputs the same error either 
way)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/Users/kikofernandezreyes/Documents/workspace/django-projects/gridbet-middleware
/src/gridBet/<ipython console> in <module>()

/Users/kikofernandezreyes/.virtualenvs/gridbet/lib/python2.6/site-packages/httxl
ib/httxbase.pyc in urlopen(self, httxreq)
    209 
    210         while True:
--> 211             response = self.getresponse(sock)
    212 
    213             # getresponse may have returned but still be active because a


/Users/kikofernandezreyes/.virtualenvs/gridbet/lib/python2.6/site-packages/httxl
ib/httxmanager.pyc in getresponse(self, sock)
    190 
    191         # get the actual response

--> 192         response = httxnetlocation.getresponse(sock)
    193 
    194         # Check if the response is active (authenticating or redirecting)


/Users/kikofernandezreyes/.virtualenvs/gridbet/lib/python2.6/site-packages/httxl
ib/httxnetlocation.pyc in getresponse(self, sock)
    189             self.inopcache.add(httxconn)
    190 
--> 191         response = httxconn.getresponse(sock)
    192 
    193         # Put it back into the connection queue unless not ready


/Users/kikofernandezreyes/.virtualenvs/gridbet/lib/python2.6/site-packages/httxl
ib/httxconnection.pyc in getresponse(self, sock)
    292 
    293             # Get the response from the redirecting connection

--> 294             response = self.auxhttx.getresponse(sock)
    295 
    296             # Remove the redirection unless the process is not over


/Users/kikofernandezreyes/.virtualenvs/gridbet/lib/python2.6/site-packages/httxl
ib/httxconnection.pyc in getresponse(self, sock)
    331         # Check for REDIRection

    332         if response.isredir():
--> 333             return self.redirect(response)
    334 
    335         return response

/Users/kikofernandezreyes/.virtualenvs/gridbet/lib/python2.6/site-packages/httxl
ib/httxconnection.pyc in redirect(self, response)
    487 
    488         # create a new connection with the redirection count increased

--> 489         auxhttx = self.__class__(auxhttxurl, redircount=self.redircount 
+ 1, options=self.options)
    490 
    491         # Create a clone of the request with the new url


/Users/kikofernandezreyes/.virtualenvs/gridbet/lib/python2.6/site-packages/httxl
ib/httxconnection.pyc in __init__(self, url, **kwargs)
    115         self.lastreq = None
    116         self.auxhttx = None
--> 117         self.createconnection(url)
    118 
    119 

/Users/kikofernandezreyes/.virtualenvs/gridbet/lib/python2.6/site-packages/httxl
ib/httxconnection.pyc in createconnection(self, url)
    205         # Force HTTPConnection to connect to have the sock object available

    206         try:
--> 207             self.conn.connect()
    208         except SocketError, e:
    209             raise SocketException(*e.args)

/Users/kikofernandezreyes/.virtualenvs/gridbet/lib/python2.6/site-packages/httxl
ib/httxs.pyc in connect(self)
     96             '''
     97             sock = socket.create_connection((self.host, self.port), self.timeout)
---> 98             if self._tunnel_host:
     99                 self.sock = sock
    100                 self._tunnel()

AttributeError: HttxsConnection instance has no attribute '_tunnel_host'



Original issue reported on code.google.com by [email protected] on 29 Jun 2011 at 10:38

Error on compressed market prices

What steps will reproduce the problem?
1.running the test script marketprices.py
2.
3.

What is the expected output? What do you see instead?
(GetMarketPricesCompressedResp){
   header = 
      (APIResponseHeader){
         errorCode = "OK"
         minorErrorCode = None
         sessionToken = "EAV3t4WEUbP19oeLS5MUNQN8B1qm/pyIqdF2VQSRbqM="
         timestamp = 2011-04-07 10:22:45.000026
      }
   errorCode = "OK"
   marketPrices = <bfpy.util.EmptyObject object at 0x024C6AF0>
   minorErrorCode = None
 }

What version of the product are you using? On what operating system?
latest version 1.02 though i got same error with old version

Please provide any additional information below.
Love the project so far!!

Original issue reported on code.google.com by [email protected] on 7 Apr 2011 at 10:26

DirectAPI should send datetime objects adjusted to UTC

What steps will reproduce the problem?
1. datetime objects are sent directly translated
2. what can create a small offset with regards to the requested time
3.

What is the expected output? What do you see instead?
UTC adjusted time. Local time.

To be resolved in version 1.11


Original issue reported on code.google.com by [email protected] on 29 Apr 2011 at 5:43

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.