Giter VIP home page Giter VIP logo

matchbook's People

Contributors

rozzac90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

matchbook's Issues

Mistake in "guide on how to use"

Dear Rozzac,

I found out a small mistake in the "README.md" file on the guide on how to use the package. In the last line, please fix marketdata to market_data, i.e.:
tennis_events = api.market_data.get_events(sport_ids=[9])

matchbook.utils.check_call_complete does not work for large responses

I found calls to APIClient.market_data.get_events() were not working when the API was returning a large number (> 500) events. The method call appears to get stuck in an infinite loop. Debugging showed that matchbook.utils.check_call_complete was the culprit.

Yesterday (23/11/18), a GET on https://www.matchbook.com/edge/rest/events returned:

<events-response>
<offset>0</offset>
<per-page>20</per-page>
<total>544</total>
<events>
<event>
....

Looking at check_call_complete:

def check_call_complete(response):
    return response.get('total', 0) < response.get('per-page', 20)

the test does not work because 544 < 500 (the default value of per_page for get_events()) always returns False, therefore the request loop for further pages continues indefinitely.

I believe the test should actually be:

def my_check_call_complete(response):
    return response.get('total', 0) < response.get('offset', 0) + response.get('per-page', 20)

or perhaps more straight-forwardly:

def my_check_call_complete(response):
    return  response.get('offset', 0) + response.get('per-page', 20) > response.get('total', 0)

i.e when the starting offset plus the current request's item count is greater than the total we are on the final page.

This issue was not apparent because the default value for per_page is 500 for the get_events() method. The number of live events on Matchbook is often less than 500.

Error with reporting

I'm having some problems getting settled bets / reports from the API. The code below throws an error:

from matchbook import APIClient

# Login
mb = APIClient(username, pwd)
mb.login()


# Reporting
mb.reporting.get_settled_bets(per_page=50)

This throws the error:

Traceback (most recent call last):

  File "<ipython-input-19-d14197edc14c>", line 1, in <module>
    mb.reporting.get_settled_bets(per_page=50)

  File "C:\Users\hstge\Anaconda3\envs\racing_env\lib\site-packages\matchbook\endpoints\reporting.py", line 156, in get_settled_bets
    'GET', self.client.urn_edge, 'reports/v1/bets/settled', params=params, target='bets', session=session

  File "C:\Users\hstge\Anaconda3\envs\racing_env\lib\site-packages\matchbook\endpoints\baseendpoint.py", line 31, in request
    check_status_code(response)

  File "C:\Users\hstge\Anaconda3\envs\racing_env\lib\site-packages\matchbook\utils.py", line 61, in check_status_code
    raise ApiError(response)

ApiError: ['resource.error.not.found']

Any way to fix this?

Authorisation error

from matchbook.apiclient import APIClient
api = APIClient('username', 'password')

"api.market_data" and "api.reference_data" work fine like this.

I get "matchbook.exceptions.ApiError: ['You are not authorised to access this resource. Login to continue.']" for these endpoints: reporting, account, betting.

Why is that?

Missing module mbapi

Dear Rozzac90,

I have been interested in the Matchbook API wrapper you are writing for matchbooks. I couldn't have it installed due to the following error:
Traceback (most recent call last): File "setup.py", line 3, in <module> from matchbook import __version__ File "C:\Users\Mostafa\Documents\matchbook\matchbook\__init__.py", line 2, in <module> from mbapi.exceptions import MBError ModuleNotFoundError: No module named 'mbapi'

Is it a python package provided to you by matchbook themselves?

Get settled bets returns and empty list.

I have tried to get settled bets function working on the reporting endpoint but there seems to be a bug. It produces and empty list.

from matchbook.apiclient import APIClient

def get_settled_bets():
 
   api = APIClient('username123', 'password123')
   r = api.reporting.get_settled_bets(offset=0, per_page=500)
   print(r)

get_settled_bets()



Broken on python 3.8

Modifying a dict while iterating over it has always been a bug, but Python 3.8 enforces this break clean_locals in utils.py

clean_params = dict((k, v) for k, v in params.items() if v is not None and k != 'self' and k != 'session')
for k, v in clean_params.items():
if '' in k:
new_key = k.replace('
', '-')
clean_params[new_key] = v
clean_params.pop(k)
return clean_params

How to handle long polling of auth endpoints?

I'm using the following code to auth and poll for long periods, more than 6 hours.

from matchbook.apiclient import APIClient
MATCHBOOK_USER =
MATCHBOOK_PW =
api = APIClient('MATCHBOOK_USER', MATCHBOOK_PW)

def get_client():
if not api.session_token:
api.login()
logger.warning(f'login has been called{api}')
return api

def get_orders(self):

api = get_client()
r = api.betting.get_orders()

Get orders is polled for long periods of time but after 6 hours I'm unable to access resource since my session token has expired.

how do you use the wrapper to create a new session after 6 hours?
I tried to use keep_alive but I ended up being blocked from the api.

It would be great if there could be some documentation of how keep_alive works.
Thanks

cannot import name 'APIClient'

pip3 install matchbook

from matchbook.apiclient import APIClient

I'm getting this error (version 0.0.5 on python3.6):

ImportError: cannot import name 'APIClient'

Reporting Errors

api = APIClient(user, password)
api.login()
api.reporting.get_current_bets() # returns empty list
api.reporting.get_settled_bets() # returns empty list
api.reporting.get_current_offers(per_page=50) # doesn't return anything within a few minutes

My account has current bets, live bets and current offers so should return something.

I used a debugger trying to find the code piece where the error occurs. I think it is in baseendpoint.py lines 33 or BaseEndpoint.request(...):

resp_data = response.json().get(target, [])

response._content has all the data but that line returns an empty list for resp_data. target is 'bets'.

This is a part from response.content:

"bets":[{"matched-bet-id":829296724400146,"matched-at":"2018-06-13T10:42:23.870Z","status":"OPEN","in-play":false,"odds":1.01000,"stake":0.87766,"exposure":0.00878,"potential-profit":0.87766,"adjustments":[],"offer-id":828688615560046}]}]}]},{"event-id":617664073170013,"name":"FIFA World Cup 2018","sport-id":15,"sport-url":"soccer","sport-name":"Soccer","start-time":"2018-06-14T13:55:00.000Z","markets":[{"market-id":617680635230012,"name":"Outright Winner","stake":8.12634,"exposure":8.12634,"potential-profit":636.34433,"selections":[{"selection-id":"617680635300012_back","runner-id":617680635300012,"name":"Germany","side":"BACK","odds":6.10000,"stake":7.12634,"exposure":7.12634,"potential-profit":36.34433,

Is there an easy fix for this?

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.