Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d340bb1

Browse filesBrowse files
committed
📝 (README.md): update code examples and add async websocket usage
Clarify the need for LMAX support to enable demo access for WebSocket. Add examples for both synchronous and asynchronous WebSocket clients, highlighting the potential issues with the sync version and suggesting the async version for better reliability. This improves the documentation by providing more comprehensive usage examples and addressing potential issues users might face.
1 parent 1283ff8 commit d340bb1
Copy full SHA for d340bb1

1 file changed

+18-4Lines changed: 18 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+18-4Lines changed: 18 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Not implemented.
2626
Here are some examples of how to use these modules. For more depth take a look at the [docs page.](https://adradr.github.io/lmax-python-sdk/)
2727

2828
### REST API
29-
```
29+
```python
3030
import os
3131
import lmax_python_sdk
3232

@@ -69,9 +69,11 @@ lmax_client.get_instrument_data_symbol("EUR/USD")
6969
```
7070

7171
### Websocket
72-
During testing it did not work with a demo access (`INSUFFICIENT_PERMISSIONS`), not sure if it needs to be enabled but it has been tested with the production access and worked perfectly.
73-
```
74-
ws = lax_python_sdk.ws_client.LMAXWebSocketClient(
72+
During testing it did not work with a demo access (`INSUFFICIENT_PERMISSIONS`), it needs to be enabled by LMAX support. The production access and worked perfectly.
73+
Websocket has been implemented in both sync and async. The sync version uses `threading` and `websocket` while the async mode uses the newer `websockets` and `asyncio` libraries to implement concurrency. During testing it seems that the sync version misses messages, which is not yet clear why happening, therefore the async version is to be tested if it works better and more reliably.
74+
75+
```python
76+
ws = lax_python_sdk.ws_client_sync.LMAXWebSocketClient(
7577
client_key_id=os.getenv("LMAX_API_KEY"),
7678
secret=os.getenv("LMAX_API_SECRET"),
7779
base_url=lmax_python_sdk.ClientBaseURLType.MARKET_DATA_LONDON_PROFESSIONAL,
@@ -80,3 +82,15 @@ ws = lax_python_sdk.ws_client.LMAXWebSocketClient(
8082
ws.subscribe({"name": "TRADE", "instruments": ["eur-usd"]})
8183
ws.connect()
8284
```
85+
86+
87+
```python
88+
ws = lax_python_sdk.ws_client_async.LMAXWebSocketClient(
89+
client_key_id=os.getenv("LMAX_API_KEY"),
90+
secret=os.getenv("LMAX_API_SECRET"),
91+
base_url=lmax_python_sdk.ClientBaseURLType.MARKET_DATA_LONDON_PROFESSIONAL,
92+
verbose=True
93+
)
94+
await ws.subscribe({"name": "TRADE", "instruments": ["eur-usd"]})
95+
await ws.connect()
96+
```

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.