Architecture and Design Workflow
On top of DeriBit api wrappers and classes implemented a program which establishes connection to the exchange and retrieves, stores data with extensive multi layer log inormation.
Here are the completed steps in the program:
- Create a test deribit class (on top of websocket) for auxiliary data retrieval.
- Send a test response to see if the connection is working.
- Send a time responce to sync time with the exchange and get the diff.*
- Get available future instruments for ETH and BTC
- Create list of websockets, 1 per instument.**
- Create Dictionary objects which contains bid/ask data as well as shared memory***
- Initialize websockets and create callback function to subscribe to orderbook updates.
- Get real-time quotes and print them in the console.
- Send subscribe requests for all the instruments and update the underlying shared memory.****
** Needs a researchL maybe 1 socket per insrument is not effective and they can be batched *** Bid/Ask are being saved in a sorted dictionary and then being serialized into raw memory which is being written into the shared MemoryMappedFile object. Check to make for not exceeding 20 elements while if there are less than 20, those are in advance initialized with 0. **** Subscibtion to raw interval didn't work for me, so i subscribed to 100ms one
- Since i have subscribed to 100ms interval, i will perform separate timing tests for exchange and local timestamps and separate one for measuring the time needed to write data into shared memory. Both can be found in the log.
Future work:
- Create unit tests for all the available and applicable functions
- Create documentation for the internal data structures and classes
- Better handling of writing into shared memory files
- Create external processes that will try to extract real-time data from shared memory files
- Apply multithreading wherever applicable in the main program loop
- Proper testing of memory leaks and release of shared memory map objects
References and re-used Safe WebSocket apis: https://github.com/tekr/DeribitDotNet/