Code Monkey home page Code Monkey logo

bybit-shiprekt's Introduction

bybit-shiprekt

Inspired by Kraken Shiprekt Telegram group, but this is for Bybit.

It reports liquidation events as occurred on futures market on Bybit exchange into telegram channel group called "Bybit Shiprekt".

You can use this code to spin your own, or just subscribe to such telegram channel group as mentioned.

screenshot

Liquidation note

By subscribing to liquidation websocket of Bybit, the value computed from the data received of such position might not reflect the full total value of the original position of trader. Because Bybit applies the partial liquidation to lower the position of trader (if possible); until it is not possible then the entire position will be taken by the liquidation engine to be settled at the brankruptcy price (which is the price as notified by liquidation websocket).

Also USDT contracts (linear contract) doesn't use ADL (Auto-deleveraging), but inverse contracts do.

Read more at

  • Liquidation process (USDT contract) - article
  • Liquidation process (Inverse contract) - article
  • ADL (Auto-Deleveraging) - article

Anyhow, the lowest risk level is already huge in amount of value. Thus it should cover most of the liquidation case from traders thus reflect the true value of the position.

Set up

  • Define environment variables of the following
    • HX_BYBIT_SHIPREKT_TELEGRAM_BOT_TOKEN - telegram bot token used to relay the message to the target telegram channel
    • HX_BYBIT_SHIPREKT_TELEGRAM_CHANNEL_CHAT_ID - telegram channel's chat id to relay the liquidation messages to
  • Build and run this program in the background.

Legacy note

You can ignore this, it is kept just for historical purpose.

The legacy note extracted from old version of source code after migrated away from polling mechanism to async way through tokio-tungstenite.

/**
* Please note that I've spent much of the time trying to make mio's Poll works
* with tungstenite with "native-tls" feature to work together. Unfortunately,
* up until now, I didn't find an answer yet.
*
* See my question on Rust forum if you can help answering it:
* https://users.rust-lang.org/t/tls-websocket-how-to-make-tungstenite-works-with-mio-for-poll-and-secure-websocket-wss-via-native-tls-feature-of-tungstenite-crate/72533?u=haxpor
*
* There are also choice whether we will go with async, or sync way.
* Clearly I want to go with blocking approach, non-async, as simple as possible
* first for this program. Although you can go with tokio-tungstenite for async
* way but it's too overkill for me at this point. I would like it to be lightweight
* as much as possible (for now).
*
*/

Before the project migrated to just use tokio-tungstenite I've tried to go minimally and attempted to make tungstenite works with mio's Poll but due to the complexity of setting up stream, and its compatibility, the attempt was not success. So I have to cut out option of using mio in order to make it work in non-async way. With that we have option to set timeout of underlying stream, or make it non-blocking. Either way could work, but still it means it operates in polling way.

Anyway for now, the project is in async way.

Disclaimer

Use this program at your own risk. I take no responsibility towards damage or loss from using it as a tool to aid in the investment. Please consider this program and its source code as educational purpose that might be useful for your case and situation at hands. Please kindly do your due diligence.

License

MIT, Wasin Thonkaew

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.