Coder Social home page Coder Social logo

matthewdowney / ftx-socket-msgs Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 2.0 1.62 MB

A lightweight client for the FTX WebSocket API which keeps an eye on the difference between the timestamp reported in the message and the local system time, keeping a log of messages and timestamps.

V 100.00%

ftx-socket-msgs's Introduction

ftx-socket-msgs

A lightweight client for the FTX WebSocket API which keeps an eye on the difference between the timestamp reported in the message and the local system time, keeping a log of messages and timestamps.

Written in V because, why not? Very fast and compiles to a compact 1.9M binary.

Build

Install the V compiler:

git clone https://github.com/vlang/v
cd v
make
sudo ./v symlink

Then clone this repository and build the source file:

git clone https://github.com/matthewdowney/ftx-socket-msgs
cd ftx-socket-msgs
v ftx.v -o ftx-socket-msgs

Use

Specify which order book channels to connect to by passing any number of markets as arguments:

./ftx-socket-msgs BTC/USD ETH/USD TSLA/USD
2021-07-10 13:41:27 [INFO ] connecting to host wss://ftx.com/ws/
2021-07-10 13:41:28 [INFO ] successfully connected to host wss://ftx.com/ws/
2021-07-10 13:41:28 [INFO ] Writing socket message log to ftx.log...
2021-07-10 13:41:28 [INFO ] Subscribing to 3 books...
2021-07-10 13:41:28 [INFO ] Started all processes. Enter a blank line to exit.
2021-07-10 13:41:28 [INFO ] Starting client listener, server(false)...
2021-07-10 13:41:28 [INFO ] Scheduling first message summary in 1844ms
2021-07-10 13:41:30 [INFO ] Average latency of 0.163s across 37 msgs (no stale msgs)
2021-07-10 13:42:00 [INFO ] Average latency of 0.166s across 894 msgs (no stale msgs)

The connection opens and you get a summary of message number and latency every 30 seconds, with detailed info for each message written to ftx.log.

Alternatively, to connect to many markets, it's be convenient to list them out in a file and use xargs to pass them as arguments. Just don't forget the -o option which gives control of stdin back to the ftx-socket-msgs process.

cat resources/markets.txt | tr '\n' '\0' | xargs -o -0 ./ftx-socket-msgs

image of a running process

Console output on the left, a running tail of the ftx.log file on the right.

ftx-socket-msgs's People

Contributors

matthewdowney avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.