Implement websocket client in python with api subscription to Websocket endpoint as specified
in below definition and save received messages to mysql database.
Websocket endpoint:
wss://[login to view URL]
Channel: trade
Requirements:
- The assignment will be accepted if the client is not disconnectd and runs forever.
- Heartbeat has to be implemented
[login to view URL]
- In case client is disconnected it has to reconnect and has to report disconnect error to log.
- The mysql table definition has to be provided in DDL.
- The code has to be provided in python and work under version 3.6
Documentation for trade
[login to view URL]
Testing the data feed:
You can test subscription to undertand correctly using in chrome:
Install Simple websocket client.
In server location url: wss://[login to view URL]
in request enter:
in Message log you will see the data arrive.
When saving to database the data, the only symbol has to be saved: XBTUSD
Sample data output:
{"table":"trade","action":"insert","data":[{"timestamp":"2019-07-07T17:26:38.421Z","symbol":"XBTUSD","side":"Buy","size":1000,"price":11246,"tickDirection":"ZeroPlusTick","trdMatchID":"dde4e4d7-04ff-4ad7-1b08-22677b3064e6","grossValue":8892000,"homeNotional":0.08892,"foreignNotional":1000}]}
{"table":"trade","action":"insert","data":[{"timestamp":"2019-07-07T17:26:40.288Z","symbol":"XBTUSD","side":"Buy","size":100,"price":11246,"tickDirection":"ZeroPlusTick","trdMatchID":"d2846764-fff5-4080-2abe-e3d2b02c7377","grossValue":889200,"homeNotional":0.008892,"foreignNotional":100},{"timestamp":"2019-07-07T17:26:40.288Z","symbol":"XBTUSD","side":"Buy","size":50,"price":11246,"tickDirection":"ZeroPlusTick","trdMatchID":"3b4b2125-b6b0-eb0d-8911-55fa5921b684","grossValue":444600,"homeNotional":0.004446,"foreignNotional":50},{"timestamp":"2019-07-07T17:26:40.288Z","symbol":"XBTUSD","side":"Buy","size":7350,"price":11246,"tickDirection":"ZeroPlusTick","trdMatchID":"a1c6dc5b-7821-19b8-0e7c-12c691a13bc5","grossValue":65356200,"homeNotional":0.653562,"foreignNotional":7350}]}
{"table":"trade","action":"insert","data":[{"timestamp":"2019-07-07T17:26:40.837Z","symbol":"XBTUSD","side":"Buy","size":50,"price":11246,"tickDirection":"ZeroPlusTick","trdMatchID":"3f53bfe6-6e6d-6a8b-3d5d-a4501eefe9a1","grossValue":444600,"homeNotional":0.004446,"foreignNotional":50},{"timestamp":"2019-07-07T17:26:40.837Z","symbol":"XBTUSD","side":"Buy","size":41,"price":11246,"tickDirection":"ZeroPlusTick","trdMatchID":"fb060ea6-1d12-1357-fb98-77c46975edb5","grossValue":364572,"homeNotional":0.00364572,"foreignNotional":41},{"timestamp":"2019-07-07T17:26:40.837Z","symbol":"XBTUSD","side":"Buy","size":40,"price":11246,"tickDirection":"ZeroPlusTick","trdMatchID":"d490085d-7f5a-e80e-7729-a3d10b9843b4","grossValue":355680,"homeNotional":0.0035568,"foreignNotional":40},{"timestamp":"2019-07-07T17:26:40.837Z","symbol":"XBTUSD","side":"Buy","size":100,"price":11246,"tickDirection":"ZeroPlusTick","trdMatchID":"d390bc15-b21d-cc0f-671b-ef4658c2f090","grossValue":889200,"homeNotional":0.008892,"foreignNotional":100},