rozzac90 / betdaq Goto Github PK
View Code? Open in Web Editor NEWPython Wrapper for Betdaq API
License: MIT License
Python Wrapper for Betdaq API
License: MIT License
Hi, as shown in the following full dependency graph of betdaq-cadenza, betdaq-cadenza requires requests * , while the installed version of requests-toolbelt(0.9.1) requires requests >=2.0.1,<3.0.0.
According to Pip's “first found wins” installation strategy, requests 2.22.0 is the actually installed version.
Although the first found package version requests 2.22.0 just satisfies the later dependency constraint (requests >=2.0.1,<3.0.0), it will lead to a build failure once developers release a newer version of requests.
betdaq-cadenza - 0.0.9
| +- python-dateutil(install version:2.8.1 version range:*)
| +- pytz(install version:2019.3 version range:*)
| +- requests(install version:2.22.0 version range:*)
| | +- certifi(install version:2019.9.11 version range:>=2017.4.17)
| | +- chardet(install version:3.0.4 version range:<3.1.0,>=3.0.2)
| | +- idna(install version:2.8 version range:>=2.5,<2.9)
| | +- urllib3(install version:1.25.7 version range:<1.26,>=1.21.1)
| +- zeep(install version:3.4.0 version range:*)
| | +- appdirs(install version:1.4.3 version range:>=1.4.0)
| | +- attrs(install version:19.3.0 version range:>=17.2.0)
| | +- cached-property(install version:1.5.1 version range:>=1.3.0)
| | +- defusedxml(install version:0.6.0 version range:>=0.4.1)
| | +- isodate(install version:0.6.0 version range:>=0.5.4)
| | | +- six(install version:1.13.0 version range:*)
| | +- lxml(install version:4.4.1 version range:>=3.1.0)
| | | +- cython(install version:0.29.14 version range:>=0.29.7)
| | +- pytz(install version:2019.3 version range:*)
| | +- requests(install version:2.22.0 version range:>=2.7.0)
| | | +- certifi(install version:2019.9.11 version range:>=2017.4.17)
| | | +- chardet(install version:3.0.4 version range:<3.1.0,>=3.0.2)
| | | +- idna(install version:2.8 version range:>=2.5,<2.9)
| | | +- urllib3(install version:1.25.7 version range:<1.26,>=1.21.1)
| | +- requests-toolbelt(install version:0.9.1 version range:>=0.7.1)
| | | +- requests(install version:2.22.0 version range:>=2.0.1,<3.0.0)
| | | | +- certifi(install version:2019.9.11 version range:>=2017.4.17)
| | | | +- chardet(install version:3.0.4 version range:<3.1.0,>=3.0.2)
| | | | +- idna(install version:2.8 version range:>=2.5,<2.9)
| | | | +- urllib3(install version:1.25.7 version range:<1.26,>=1.21.1)
| | +- six(install version:1.13.0 version range:>=1.9.0)
Thanks for your attention.
Best,
Neolith
Create proper read me with example log in and use of an endpoint.
Move from parser methods to using resources properly.
Find less hacky way of getting market meta data from nested dicts.
Hi,
Thanks for producing this fantastic module! Whilst using it, I have ran into an issue. api.marketdata.get_odds_ladder() returns:
AttributeError: 'list' object has no attribute 'get'
My understanding is that this function should return the price ladder from betdaq, and doesn't require any user-inputted parameters. Might you be able to take a look / advise me otherwise?
Thanks again
Hi. I’m having issues running the following code, which has been working flawlessly until recently:
from betdaq.apiclient import APIClient
api = APIClient('username', 'password')
sport_ids = api.marketdata.get_sports()
error:
Traceback (most recent call last):
File "C:\Users\UK\AppData\Local\Programs\Python\Python37\lib\site-packages\zeep\xsd\schema.py", line 172, in get_ns_prefix
return self._prefix_map_custom[prefix]
KeyError: 'ns0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\UK\AppData\Local\Programs\Python\Python37\lib\site-packages\zeep\xsd\schema.py", line 174, in get_ns_prefix
return self._prefix_map_auto[prefix]
KeyError: 'ns0'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\UK\Desktop\Betdaq test.py", line 2, in
api = APIClient('username', password')
File "C:\Users\UK\AppData\Local\Programs\Python\Python37\lib\site-packages\betdaq\apiclient.py", line 8, in init
super(APIClient, self).init(username, password)
File "C:\Users\UK\AppData\Local\Programs\Python\Python37\lib\site-packages\betdaq\baseclient.py", line 13, in init
self.initialise_type_factories()
File "C:\Users\UK\AppData\Local\Programs\Python\Python37\lib\site-packages\betdaq\baseclient.py", line 33, in initialise_type_factories
self.readonly_types = self.readonly_client.type_factory('ns0')
File "C:\Users\UK\AppData\Local\Programs\Python\Python37\lib\site-packages\zeep\client.py", line 238, in type_factory
return Factory(self.wsdl.types, 'type', namespace)
File "C:\Users\UK\AppData\Local\Programs\Python\Python37\lib\site-packages\zeep\client.py", line 78, in init
self._ns = types.get_ns_prefix(namespace)
File "C:\Users\UK\AppData\Local\Programs\Python\Python37\lib\site-packages\zeep\xsd\schema.py", line 176, in get_ns_prefix
raise ValueError("No such prefix %r" % prefix)
ValueError: No such prefix 'ns0'
Thanks a lot for any kind of attention.
Best regards
Jacob
Write resources and errorparsers for trading endpoints.
Hi
When i'm trying to place a bet i'm getting the error NameError: name 'BetdaqSystemError' is not defined
here is snips of the code where i'm trying to place an order
from betdaq.apiclient import APIClient
from betdaq.endpoints.account import Account
from betdaq.endpoints.marketdata import MarketData
from betdaq.endpoints.betting import Betting
from betdaq.filters import create_order
from betdaq.exceptions import *
from betdaq.enums import *
def initilise(self,username,password):
self.client = APIClient(username, password)
self.betting = Betting(self.client)
def place_bet(self,selection_id,money,odds):
orderDetails = create_order(selection_id, money, odds, 1, 0, 0, True, True, None, 2, 4, 0.0, 1)
orders = [orderDetails]
return self.betting.place_orders(orders)
Hoping someone can point me in the right direction on what is causing this error
Regards
Hi,
I'm attempting to create and place an order by running the following:
from betdaq.apiclient import APIClient
from betdaq import filters, enums
api = APIClient('*', '*')
myorder = [filters.create_order(82026914, 2.00, 2.40, enums.Polarity(1), 0, 0)]
api.betting.place_orders(myorder, receipt=True)
However, I'm being met with:
APIError: PlaceOrdersWithReceipt
Params: {
'Orders': {
'Order': [
{
'SelectionId': 82026914,
'Stake': 2.0,
'Price': 2.4,
'Polarity': <Polarity.back: 1>,
'ExpectedSelectionResetCount': 0,
'ExpectedWithdrawalSequenceNumber': 0,
'KillType': <OrderKillType.FillOrKillDontCancel: 4>,
'FillOrKillThreshold': 0.0,
'CancelOnInRunning': <Boolean.T: 'true'>,
'CancelIfSelectionReset': <Boolean.T: 'true'>,
'WithdrawalRepriceOption': <WithdrawRepriceOption.Cancel: 2>,
'ExpiresAt': None,
'RestrictOrderToBroker': None,
'ChannelTypeInfo': None,
'PunterReferenceNumber': 1
}
]
}
}
Exception: Server was unable to read request. ---> There is an error in XML document (10, 69). ---> Input string was not in a correct format.
I'm not sure how to check (10, 69) in the XML document... Do you have any idea where I'm going wrong here? Or might you have a sample of code where you're simply creating and placing an order that I could use?
Thanks a lot
Matt
Hi,
Thanks for writing such a great API.
When I get a runner book, such as the one below, what do the first elements (0, 0, 1 below) represent?
{'batb': [[0, 5.3, 46.51]], 'batl': [[0, 6.6, 60.61], [1, 6.8, 11.0]]}
Add unit testing for all methods
No error raised when incorrect username/password provided, looking at the response it looks as though the code/description detail whether the request was successful.
Hello,
The function get_markets_with_sp, returns values which are missing market type ids. e.g.
[OrderedDict([('MarketTypeIds', OrderedDict([('MarketTypeId', [1])])),
('eventId', 190538)]),
{'eventId': '190539', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '1048932', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '422497', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '4175018', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '1190579', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '5142984', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '5086725', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '5143134', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '5143088', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '5143003', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '5178822', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '3981057', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '3978116', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '3929084', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '3978114', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '4454456', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '3978115', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '3919304', 'MarketTypeIds': {'MarketTypeId': []}},
{'eventId': '4692325', 'MarketTypeIds': {'MarketTypeId': []}}]
If I debug the code, the actual response does contain market ids for all events:
b'<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetSPEnabledMarketsInformationResponse xmlns="http://www.GlobalBettingExchange.com/ExternalAPI/"><GetSPEnabledMarketsInformationResult><ReturnStatus Code="0" Description="Success" CallId="450215a4-65bb-4ce7-b7af-9fa937bf4dd6" /><Timestamp>2019-04-01T11:17:14.3366777+00:00</Timestamp><SPEnabledEvent eventId="190538"><MarketTypeIds><MarketTypeId>1</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="190539"><MarketTypeIds><MarketTypeId>1</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="1048932"><MarketTypeIds><MarketTypeId>1</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="422497"><MarketTypeIds><MarketTypeId>1</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="4175018"><MarketTypeIds><MarketTypeId>1</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="1190579"><MarketTypeIds><MarketTypeId>1</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="5142984"><MarketTypeIds><MarketTypeId>3</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="5086725"><MarketTypeIds><MarketTypeId>3</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="5143134"><MarketTypeIds><MarketTypeId>3</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="5143088"><MarketTypeIds><MarketTypeId>3</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="5143003"><MarketTypeIds><MarketTypeId>3</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="5178822"><MarketTypeIds><MarketTypeId>3</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="3981057"><MarketTypeIds><MarketTypeId>3</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="3978116"><MarketTypeIds><MarketTypeId>14</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="3929084"><MarketTypeIds><MarketTypeId>14</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="3978114"><MarketTypeIds><MarketTypeId>14</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="4454456"><MarketTypeIds><MarketTypeId>14</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="3978115"><MarketTypeIds><MarketTypeId>14</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="3919304"><MarketTypeIds><MarketTypeId>14</MarketTypeId></MarketTypeIds></SPEnabledEvent><SPEnabledEvent eventId="4692325"><MarketTypeIds><MarketTypeId>16</MarketTypeId></MarketTypeIds></SPEnabledEvent></GetSPEnabledMarketsInformationResult></GetSPEnabledMarketsInformationResponse></soap:Body></soap:Envelope>'
I have a feeling the problem might be due to the WSDL, rather than the code in this Github repo. But I am not sure. I'm therefore not sure how to produce a clean fix for this.
I will shortly push a hacky solution in my fork. I'm aware that the solution is not at all in line with the design-goals of this package, and apologise in advance.
Hello,
On my setup, downloading prices for a single market takes about 0.05 seconds.
Placing a single order takes about 0.20 seconds. i.e. it takes 4 times longer to place an order than it does to download market prices, even though there is a lot more data in market prices, though perhaps there is more CPU load on the server when I place an order.
Going through the code, it appears that the bottleneck is in zeep.transports.py:
response = self.session.post(
address,
data=message,
headers=headers,
timeout=self.operation_timeout)
I've checked that the connection is being kept alive, as the documentation says that connections are automatically kept alive. Or I can force it anyway by adding this line to zeep.transports.py:
http_headers['Connection'] = 'keep-alive'
However, adding the line above makes no difference.
I'm not sure what else to try. Do you have any suggestions?
No matter what call I am making I receive this response, which appears to be an issue with "Content-Type" but content type is not expected in the Betdaq headers. This happens if I copy-paste and run the code from the readme.
Any ideas why this is happening?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.