Giter Site home page Giter Site logo

xrpl-trading-bot's Introduction

ARCHIVED

This repo is archived. Some day it will come back better :) Keep an eye on https://github.com/LimpidCrypto/xrpl-trading ๐Ÿ‘€

Warning ๐Ÿšจ

This repository is in active development and is not working yet. The bot currently requires you to put in your seed value via terminal. It is planned to use the Tangem wallet in the future so you will never be required to give away your secrets. At the current stage I would never use a bot like this, even if it should work!

- NEVER GIVE AWAY YOUR SECRETS!!!

Main tasks:

  • Get it running
      • Build trading paths
        • Spatial Arbitrage
        • Triangular Arbitrage
        • Market Maker
    • Determine which trade would be the most profitable
    • Build OfferCreate transactions
    • Sign transactions
    • Submit transactions
  • Add support for Tangem wallet
  • First release

XRPL-trading-bot

A trading bot that uses the decentralized exchange of the XRP Ledger. It uses arbitrage trading and market making to make profit.

๐Ÿ“– Basics:

  • The XRP Ledger has the world's first decentralized exchange (DEX).
  • Orders on the DEX are called Offers.
  • This bot only sends OfferCreate transactions with the Immediate or cancel flag to the ledger.
  • Offers consume other Offers in an order book. For example if you want to buy a currency you place a bid Offer that consumes an ask Offer that has the same or a better price than the bid Offer.
  • Arbitrage trading and market making are not known to make huge profits. There are known to make profits with low risk.

๐Ÿ“ˆ Trading types:

๐Ÿ’ฑ Arbitrage Trading

The arbitrage trading bot takes advantage of the price differences in different liquid order books to make profit.

Types:
Basic Spatial Arbitrage Triangular Arbitrage
1. Order: USD.r1 > BTC.r1 1. Order: USD.r1 > BTC.r1
2. Order: BTC.r2 > USD.r2 2. Order: BTC.r2 > ETH.r1
3. Order: ETH.r2 > USD.r2
Example:

The bot places an immediate or cancel offer that trades 10 USD.r1 for 9 EUR.r1. The bot then places a second immediate or cancel offer that trades 9 EUR.r2 for 11 USD.r2. The profit for this trade is 1 USD. Neither the TakerGets nor the TakerPays issuers have to be the same for both trades. All four issuers can be completely different. Doing so brings the most flexibility.
The bot only trades liquid order books and adjusts all Offer values from the lowest TakerGets balance.

๐ŸŒŠ Market Maker

Market makers provide liquidity to a market. Place a buy and a sell order on the tip of a illiquid order book. The spread the two orders has to be big enough to cover the potential transfer fees. The market maker bot only trades illiquid order books, where %1 of the orders have been consumed in the last 2 weeks.

Example:

The order books most expensive bid order has a price of 50 $ and the cheapest ask order price is 52 $, so the spread is 3.85 %2.
The bot then calculates what prices it needs to place the orders at to cover the transfer fees and still be profitable while minimize the current spread of 3.85 %. It aims to provide a spread of 0.5 %. If one or both orders are not fulfilled after a week the orders will get canceled automatically.

Footnotes

  1. not determined yet โ†ฉ

  2. quoted spread = (52 $ - 50 $) / 51 $ * 100 ((ask - bid) / midpoint * 100) โ†ฉ

xrpl-trading-bot's People

Contributors

limpidcrypto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xrpl-trading-bot's Issues

Submit transactions

There should be a async function to submit multiple transactions at once.

Get gateway fees

  • Release of #3
  • Add a function that gets the transfer rates of every gateway using [account_info](https://xrpl.org/account_info.html)

Subscribe to balance changes

Add a function that receives all balances of an account once and then subscribes to the account to receive the transactions that affect the account. After every transaction parse the final balances of the account.
The function must be threaded so it is not blocking the program.

Build trading paths

  • Release of #2.
  • Add a function that parses all order books and identifies all possible trading paths.
Basic Spatial Arbitrage Triangular Arbitrage
1. PS: USD.r1 > BTC.r1 1. PS: USD.r1 > BTC.r1
2. PS: BTC.r2 > USD.r2 2. PS: BTC.r2 > ETH.r1
3. PS: ETH.r2 > USD.r2
  • Adjust values.
    • The lowest value is the value to calculate every other value from (also take account balance in account)
  • Calculate profits after fees.
  • Generate a random memo for each trading path with a prefix for each trading type.

Subscribe to order books

Add a function to continuously parse the new order books every time a transaction affects one.
The function must be threaded so it does not block the program.

Add parse_all_order_books

  • Release of #3
  • Add a function that parses all possible order books the account could trade based on the accounts currencies.

Add async client

There should be a client that is able to run multiple requests asynchronous.
To make it easier to enter the uris there should be classes like FullHistoryNodes which have attributes containing the uris.

Add sign_trade

  • Release of #15
  • Add a function that signs all path steps of a trading path.

Add final order book parser

Add a function that takes both sides of an order book and a transaction.
The function is able to:

  • parse the final order book
  • convert amounts to XRP if wished
  • differentiate between liquid and illiquid markets
    • max spread
    • formula to calc order book depth

Fund unfunded trading paths

There has to be an algorithm that checks all possible payment paths for all currencies the account holds. So if the source currency for a trading path is not funded another currency can fund that source currency.

Support of Tangem

In the future it should only be possible to sign transactions with a Tangem card to massively improve security.
Use the Tangem library to implement this feature.

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.