Skip to content

Commit

Permalink
Initial version of the AAPI & GBEi protocols implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
vayesy committed Aug 22, 2023
1 parent da1428a commit df22e07
Show file tree
Hide file tree
Showing 43 changed files with 3,786 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
# betdaq
# sportech-exchange-betdaq-stream-server
Implementation of Betdaq protocols (AAPI, GBEi) using Python language.

## Description
Betdaq exchange offers different services to its clients.
`AAPI` & `GBEi` protocols are few of them to help clients operate with exchange data more efficiently.
`AAPI` - built on top of WS, is used to receive exchange information about upcoming events and their details. Main goal is to quickly receive odds updates.
`GBEi` - built on top of TCP, is used to efficiently process client orders to place bets.
Repo implements those protocols in respective modules under `src` directory.
Further usage and extension relies on the specific project which consumes those protocols.

### Installation
Requires python 3.7 or higher.
```bash
pip install -r requirements.txt
```
For testing:
```bash
pip install -r test-requiremenets.txt
```

### Running
Run AAPI base cient:
```bash
python -m betdaq.aapi
```

## Configuration:
All below configs can be provided via environment variables.

### AAPI
- ***BETDAQ_AAPI_STREAM_URL*** - url of Betdaq AAPI service.
- ***BETDAQ_AAPI_USERNAME*** - username to connect with. If not specified, anonymous session is established (if it's allowed on the server side).
- ***BETDAQ_AAPI_PASSWORD*** - password to connect with, related to the username config.
- ***BETDAQ_AAPI_REFRESH_PERIOD*** - frequency (in seconds) of price (odds) updates, sent by the server.
- ***BETDAQ_AAPI_META_REFRESH_PERIOD*** - frequency (in seconds) of metadata (like event lists, start times etc.) updates.
- ***BETDAQ_AAPI_PRICES_NUMBER*** - Number of best back/lay prices to receive.

### GBEi
- ***BETDAQ_GBEI_URL*** - url of Betdaq GBEi service.
- ***BETDAQ_GBEI_PUNTER_ID*** - punter id (or username) to connect to the service. Anonymous connection is not allowed.
- ***BETDAQ_GBEI_PUNTER_SESSION_KEY*** - session key, related to given user.

### Tests
Tests are written with pytest library.
To run tests, use next command:
```bash
python -m pytest
```
10 changes: 10 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[pytest]
addopts =
--cov=src/betdaq
testpaths =
tests
env =
BETDAQ_AAPI_STREAM_URL=1
BETDAQ_GBEI_URL=
BETDAQ_GBEI_PUNTER_ID=
BETDAQ_GBEI_PUNTER_SESSION_KEY=
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
environs==9.5.0
aiohttp==3.8.5
pytz==2023.3
Empty file added src/betdaq/__init__.py
Empty file.
1 change: 1 addition & 0 deletions src/betdaq/aapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.0'
15 changes: 15 additions & 0 deletions src/betdaq/aapi/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import asyncio
import logging
import sys
from betdaq.aapi.client import BetdaqAsyncClient


async def main():
logging.basicConfig(level='DEBUG', format='[%(asctime)s %(levelname)s %(name)s] %(message)s')

loop = asyncio.get_event_loop()
cli = BetdaqAsyncClient(loop)
await cli.run_receive()


sys.exit(asyncio.run(main()))
Loading

0 comments on commit df22e07

Please sign in to comment.