Ekliptor / WolfBot

Crypto currency trading bot written in TypeScript for NodeJS
https://wolfbot.org
GNU Affero General Public License v3.0
710 stars 215 forks source link

How to execute arbitrage strategy ? #10

Closed github-sma closed 5 years ago

Ekliptor commented 5 years ago

The open source version comes with 1 sample arbitrage strategy. Copied from /src/Arbitrage/Strategies/Spread.ts

interface SpreadAction extends ArbitrageStrategyAction {
    spreadEntry: number; // 0.8% // How many % the market spread between the 2 exchanges has to be to open positions on both of them.
    spreadTarget: number; // 0.5% // Targeted profit in %. This takes trading fees into account. See the 'tradingFees' setting.
    // Positions will be closed according to this equation: spreadExit = spreadEntry - 4*fees - spreadTarget -> will usually negative, meaning prices flipped
    trailingSpreadStop: number; // 0.08% // After reaching spreadTarget, place a trailing stop to exit the market. Set this to 0 to exit immediately,
}

/**
 * Arbitrage strategy that computes the average price across exchanges.
 * If the price is x% higher/lower than avg on exchanges:
 * 1. buy at the cheaper exchange and (short) sell at the expensive exchange
 * 2. close positions after price difference moves x% closer
 */
export default class Spread extends AbstractArbitrageStrategy {

There is also an example config under /config/arbitrage/Leverage.json doing arbitrage between Bitfinex and OKEX leveraged futures using the Spread strategy mentioned above. You can adjust this file to your needs or (better) write your own arbitrage strategy for exchanges:

{
  "data": [
    {
      "exchanges": ["Bitfinex", "OKEX"],
      "marginTrading": true,
      "tradeTotalBtc": 100.0,
      "notifyTrades": true,
      "longShortRatio": 1.0,
      "maxTradeBalancePercentage": 99.0,
      "strategies": {
        "Spread": {
          "spreadEntry": 0.8,
          "spreadTarget": 0.5,
          "trailingSpreadStop": 0.08,
          "tradingFees": {
            "Bitfinex": {
              "maker": 0.1,
              "taker": 0.2
            },
            "OKEX": {
              "maker": 0.03,
              "taker": 0.05
            }
          },
          "candleSize": 1,
          "pair": "USD_BTC",
          "tradeStrategy": "",
          "enableLog": true
        }
      }
    }
  ]
}
github-sma commented 5 years ago

Thanks