CEX to DEX Arbitrage Feature Specifications May 2019

dexbot(46)
Published in
#dexbot
Words
1032
Reading
5 min
Listen
Play
7y

https://docs.google.com/document/d/1lW84tv_9k7wQncGEZN4IylspIZlanpQBdrtcJSq3i80/edit?usp=sharing

CEX to DEX Arbitrage Feature Specifications
May 2019
Permie

DEXBot will use Ccxt which allows access to 135 CEX’s in one go. Binance and most of the big ones are included.
See the full list here: https://github.com/ccxt/ccxt/blob/master/wiki/Exchange-Markets.md

Why does Bitshares want arbitrage?

Trade volume, better price discovery, tighter spreads as arb bots will take good offers and encourage market makers to have offers close to the market price on the DEX orderbooks as often as possible. The higher the volume of trading, in part increased by arb bots, allows market makers to turn over their capital more frequently thus making market making participation more attractive to traders

Why does Bitshares want to connect to other exchanges?

Arbitrage requires access to at least two separate exchanges as it relies on the price discrepancy, or lag, between prices for assets offered in two separate marketplaces.

How should the arbitrage feature on DEXBot operate? What logic should it follow?

DEXBot should have knowledge and ability to post orders on the books of at least two other exchanges.
One of those two exchanges must always be the Bitshares DEX.
(Triangle arbitrage involving 3 Exchanges, one being the DEX, can come later)

Let CEX = an arbitrary but particular CEX.
Let DEX = The Bitshares DEX.

To setup the arbitrage strategy feature the user must give certain parameters:

SELECT CEX (Drop down menu), Bitshares DEX will be automatically allocated as the second exchange required - but this may change in future so the ability to select this parameter at a later date but for the meantime be “locked” would be great).

SELECT ASSET PAIR - The asset pairs must all be available on the DEX, and available like for like on the CEX selected. Unfortunately I think this may rule out bitUSD and bitCNY for all CEX’s that don’t list them (although CoinTiger do list bitCNY - in which case arbitrage between the DEX and those CEX’s for bitCNY would be particularly important for the health of the DEX. (bitUSD is currently not listed on any 3rd party exchange).

UIA’s like GDEX. OPEN. BRIDGE. Etc are IOU’s just the same as on any other CEX, so can be compared like for like with CEX’s for the purposes of arbitrage.

FEE INPUTS - Fee listing are required in ccxt exchanges and are accessible through the API .. https://github.com/ccxt/ccxt/wiki/Requirements.

RELATIVE ORDER SIZE - What % of available capital on CEX and DEX can be used in a single arbitrage trade?

MINIMUM PROFIT OPPORTUNITY TO EXECUTE - There will be a minimum profit required to account for fees. In a hypothetical scenario where a DEXBot user is the sole arb trader in a liquid, high volume market on the DEX, and DEXBot sees an arbitrage opportunity between the DEX and the CEX as-set in the strategy config it would take offers on both the DEX and CEX simultaneously. As arbitrage traders take orders off the books in order to profit they decrease the price difference between the CEX and the DEX.

If DEXBot continuously takes even the minimum profit arb opportunities it may consume liquidity in such a way that if DEXBot had waited there would have been a bigger more profitable order placed. Impatient traders may have offered a better price a few seconds later if the bot hadn’t immediately snapped up less profitable orders.

From the standpoint of price accuracy and trade volume of the DEX it would be better to have the minimum profit as 0< so that as many offers are taken as possible, contributing to the fees paid and the trade volume of the DEX - higher trade volume is a bigger stat to use as PR to show real people use the DEX.

MAXIMUM ASSET VALUE WILLING TO HOLD ON CEX - If maximum is reached could the bot send the excess to the DEX? It is possible to do withdraw from the ccxt exchange and send coins to the bitshares dex if addresses are provided.
Holding assets on the DEX allows users control of their keys and the ability to prove ownership of a token given value by the promises of independent businesses who operate gateways on the Bitshares DEX. If even a small portion of users enable this feature that is still a trickle of assets from a CEX and onto the DEX. I don’t know how possible it would be to be able to define parameters such as capital-risk limits for each CEX that DEXBot is able to arb to. Users may trust big brand name exchanges with more of their capital than they would other smaller exchanges. The user could either complete a big list of their risk limits in a saved file, or they could be required to enter capital limits each time they setup the strategy and refer to their notes on how much they trust exchange X.

MAXIMUM INVESTABLE CAPITAL IN ARB - If the arb bot makes $XXX in hypothetical profit overnight that profit increases the capital within the arb strategy account. Can the user have the option to send funds over this limit to a designated Bitshares account?

Logic

DEXBot sees CEX and DEX price feeds for the designated market and has the ability to buy at the ask and sell at the bid on both.

If CEX has a bid price that exceeds the ask price on the DEX, DEXBot will sell ASSET.A for ASSET.B at the bid price on the CEX, while simultaneously buying ASSET.A with ASSET.B at the ask price on the DEX.

If CEX has an ask price that is lower than the bid price on the DEX, DEXBot will buy ASSET.A for ASSET.B at the ask price on the CEX, and sell ASSET.A for ASSET.B at the bid price on the DEX.

For example:
Offer to buy 1btc at 105,000 on CEX
Offer to sell 1btc at 106,000 on DEX

DEXBot BUYS this offer and pays 105k bts to recieve 1BTC, taking it off the CEX orderbook
DEXBot SELLS to this offer, selling 1btc and receiving 106k bts, taking it off the DEX orderbook

This trade results in 1k bts profit, and makes 2 trades simultaneously - one on the CEX, one on the DEX.

The profit realised and on which exchange depends on the volume of the available profitable bid/asks, the amount of assets held on the CEX and on the DEX and on the logic used by DEXBot. If the capital available to the DEXBot worker is less than the total size of the profitable bid/asks then DEXBot could be configured to designate the destination of profits realised by deciding to buy a lower amount of asset.a in order to see the profit in asset.b instead.

List of exchanges that had >0btc trading volume vs bts - In order of 24/hr Volume highest to lowest on 15/05/19:

CoinTiger https://coinmarketcap.com/exchanges/cointiger/
Available on ccxt? YES - Websocket
Market Orders permitted? YES
Please visit 【www.cointiger.com】-[Account] – [API control] – [create the new key] to create your own API Key.
Request Process
There are REST and Websocket two methods of Public Api Request; REST is the only method for Private Trading Api Request.

CoinTiger is of particular importance because it lists bitCNY, and arbitrage between CT and the DEX on bitCNY markets would be very helpful for the health of bitCNY, Bitshares’ flagship product. (CoinTiger is not #1 for bts volume but I put it at the top of the list for emphasis on the importance of bitCNY arbitrage. From now on the list is in volume order, with Lbank being 41% of the trading volume for bts (BTS vs ETH)).

Lbank https://coinmarketcap.com/exchanges/lbank/
Available on ccxt? Yes - Websocket and REST API’s
Market Orders available? - UNKNOWN - support help centre disabled and docs do not say.
https://github.com/LBank-exchange/lbank-official-api-docs/blob/master/README.md

ZB https://coinmarketcap.com/exchanges/zb-com/
Available on ccxt? Yes - Websocket and REST API’s
Marker Orders permitted? - Awaiting email support response
https://www.zb.com/i/developer

CoinEgg https://coinmarketcap.com/exchanges/coinegg/
Available on ccxt? Yes - REST ONLY
https://github.com/coinegg/api-docs/blob/master/README_EN.md

Huobi Global https://coinmarketcap.com/exchanges/huobi-global/
Available on ccxt? NO. But Huobi Pro is which I think means YES

Poloniex https://coinmarketcap.com/exchanges/poloniex/
Available on ccxt? Yes - Websocket and HTTP API’s
Market Orders permitted? - Awaiting response
https://poloniex.freshdesk.com/support/tickets/1204479
https://docs.poloniex.com/#introduction
https://github.com/askmike/gekko/issues/517 - simulating market orders using polo api

Binance https://coinmarketcap.com/exchanges/binance/
Available on ccxt? Yes - REST API ONLY - websocket streams
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md

Gate.io https://coinmarketcap.com/exchanges/gate-io/
Available on ccxt? Yes - Websocket and REST API’s
Market Orders available? - Awaiting email reply
https://www.gate.io/api2

IDAX https://coinmarketcap.com/exchanges/idax/
Available on ccxt? NO

EXX https://coinmarketcap.com/exchanges/exx/
Available on ccxt? Yes - Websocket and REST API’s
Market Orders permitted? - YES
https://www.exx.com/help/websocketApi

Bittrex https://coinmarketcap.com/exchanges/bittrex/
Available on ccxt? YES - REST API ONLY, streaming only websocket
https://bittrex.github.io/api/v1-1

Upbit https://coinmarketcap.com/exchanges/upbit/
Available on ccxt? YES - Chinese docs https://docs.upbit.com/docs/%EC%9A%94%EC%B2%AD-%EC%88%98-%EC%A0%9C%ED%95%9C

Livecoin https://coinmarketcap.com/exchanges/livecoin/
Available on ccxt? YES - HTTP API and Websocket BETA API
Market Orders permitted? - Awaiting email from support
https://www.livecoin.net/api/common

Indodax https://coinmarketcap.com/exchanges/indodax/
Available on ccxt? YES - HTTP API ONLY
https://indodax.com/downloads/BITCOINCOID-API-DOCUMENTATION.pdf

Crex24 https://coinmarketcap.com/exchanges/crex24/
Available on ccxt? YES - HTTP API ONLY
https://docs.crex24.com/trade-api/v2

RightBTC https://coinmarketcap.com/exchanges/rightbtc/
Available on ccxt? YES - API DOCS GIVE BROWSER SECURITY THREAT WARNING. ?

Huobi Korea https://coinmarketcap.com/exchanges/huobi-korea/
Available on ccxt? NO but there is huobipro - which I think means YES

LIST OF EOS DEX’s

https://www.dexeos.io/ - 3.5mil EOS 30day volume (~$20mil USD)
https://support.dexeos.io/hc/en-us/articles/360019950754-DEXEOS-Update-New-UI-and-API

https://www.eosfinex.com - Looks dead?

https://newdex.io/ - 30 day volume of exchange 11.5mil EOS (~$70mil USD)
https://github.com/newdex/api-docs
REST API ONLY, websocket “coming soon”
https://github.com/newdex/api-docs/blob/master/api/how_to_make_order.md
Have to implement own code to be able to place orders. Im not sure if this can be done universally for all DEXBot as the code must contain the private key of the EOS account used to trade on newdex.

https://eosdaq.com - 30day volume looks very low

Huobi have an EOS “DEX” in beta

CEX to DEX Arbitrage Feature Specifications May 2019 | Ecency