+ +In the current version the user must provide his secret seed value via input from the terminal. +Before the first official release the trading bot will be able to interact with the Tangem wallet. +Advantages of using Tangem: + - The user's key pair is stored safely on the Tangem wallet + - The user does not have to give away their secret seed value + +
++ +Generate the wallet using the [`Wallet`](https://github.com/XRPLF/xrpl-py/blob/master/xrpl/wallet/main.py#L12) object from the [xrpl-py](https://github.com/XRPLF/xrpl-py) library. +By doing so, we are able to access the account's classic address (r-address) and sign transactions. + +
++ +Receive all balances the account holds using the [`account_info`](https://xrpl.org/account_info.html) and the [`account_lines`](https://xrpl.org/account_lines.html#account_lines) methods once. The `account_info` method returns the `Balance` field which contains the accounts XRP values expressed in [drops](https://xrpl.org/xrp.html#xrp-properties). The `account_lines` method returns a list of all [tokens](https://xrpl.org/tokens.html) the account holds. Each object in that list contains the `acccount` field (describes the issuer of the token), the `currency` field (describes the currency code, e.g. 'USD') and the `balance` field (describes the amount the account holds of that token). These balances will be stored in the [`XRPWallet`](https://github.com/LimpidCrypto/XRPL-trading-bot/blob/main/xrpl_trading_bot/wallet/main.py#L10) object which is a child class of the [`Wallet`](https://github.com/XRPLF/xrpl-py/blob/master/xrpl/wallet/main.py#L12) object of the xrpl-py library. + +
++ +Receive a message every time a transaction affects the user's account. This message include precise information how the transaction affected the ledger and the account. + +
++ +Every time the bot receives a message (described in step 4) that a transaction affected the user's account, the bot makes use of a [transaction parser](https://github.com/XRPLF/xrpl-py/pull/342) (currently added in directly to the bot. The parser will be integrated into the xrpl-py library as soon as possible. When integrated the parser will be deleted from the bot.). The transaction parser parses the accounts final balances after the transaction happend and corrects them in the `XRPWallet` object. + +
++ +Because we now always know what currencies the account holds, we can parse all possible [currency pairs](https://www.investopedia.com/terms/c/currencypair.asp) the account could trade from them. +If we take the above example account the possible currency pairs would be the following: +- XRP/USD.Bitstamp +- XRP/USD.Gatehub +- XRP/EUR.Gatehub +- XRP/EUR.Bitstamp +- USD.Bitstamp/USD.Gatehub +- USD.Bitstamp/EUR.Gatehub +- USD.Bitstamp/EUR.Bitstamp +- USD.Gatehub/EUR.Gatehub +- USD.Gatehub/EUR.Bitstamp +- EUR.Gatehub/EUR.Bitstamp + +
++ +Receive the entire [order book](https://www.investopedia.com/terms/o/order-book.asp) for every currency pair once, using the [`subscribe`](https://xrpl.org/subscribe.html) method. The subscription will immediately be canceled after the order book is received because the bot is retreiving it from a full history node. We do not want to load them unnecessarily. The order books will be stored in the [`OrderBooks`](https://github.com/LimpidCrypto/XRPL-trading-bot/blob/main/xrpl_trading_bot/order_books/main.py#L52) object. + +
++ +Receive a message every time a transaction affects the given order book. This message include precise information how the transaction affected the ledger and the order book. + +
++ +Everytime the bot receives a new message (described in step 4) that a transaction affected an order book. The bot takes the transaction and the affected order book to see how the transaction changed the order book. It then parses the final state of the order book. To do this it uses the [`parse_final_order_book`](https://github.com/LimpidCrypto/XRPL-trading-bot/blob/main/xrpl_trading_bot/txn_parser/order_book_changes.py#L52) parser. + +
+
+
+You could say that the decentralized exchange of the XRP Ledger is nothing more than a collection of limit orders. Orders are called [`Offers`](https://xrpl.org/offers.html#offers) on the XRP Ledger. Every time the user wants to trade a currency against another he needs to find another participant, who wants to trade the exact same currencies in the other direction, at the same or better exchange rate. For Examlple:
+
Person A is willing to pay 10.70 USD in order to receive 10 EUR. To let everybody know he is willing to so he submits an [`OfferCreate`](https://xrpl.org/offercreate.html) transaction to the network. This transaction creates an [`Offer`](https://xrpl.org/offer.html#offer) object on the XRP Ledger which everybody in the network is able to see. Now Person B comes into play. Person B sees that offer of Person A and wants to trade it. So Person B is willing to pay 10 EUR in order to receive 10.70 USD. Person B now submits a `OfferCreate` transaction just as Person A did before. Because both `Offers` have the same exchange rate they are consuming each other. Person A gets 10 EUR from Person B and Person B gets 10.70 USD from Person A.
+
You can imagine that the trading bot is Person B. The bot is constantly searching for `Offers` which combined will result in profit due to price differences. If the bot combine to compare two or more `Offers` with each other this is called a *trade path*.
+
+## Examples
+### Spatial arbitrage trading
+#### Soon
+### Triangular arbitrage trading
+#### Soon
+### Market maker
+#### Soon
+
+
+ +#### Soon + +
++ +last trade TakerPays amount - first trade TakerGets amount = numeric profit/loss +(1 - (last trade TakerPays amount - first trade TakerGets amount) / first trade TakerGets amount) * 100 = percentage profit/loss + +
++ +Filter for positive numeric profit and sort by percentage profit, so the most profitable paths get executed first. + +
++ +
++ +
++ +
++ +
++ +
+