DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.23k stars 2.04k forks source link

Bitfinex live trading not working #695

Closed dentatar closed 6 years ago

dentatar commented 6 years ago

Hello. I got an issue with live trading on Bitfinex. The bot just cant't perform any action, even manually executed orders won't work. I'm using --debug option and there is no errors, only "WebSockets: We are now fully connected and authenticated." after starting the bot. The price is also not updating.

Some additional info: -API permissions is alright, i checked them several times. Orders have write permission and everything else is readonly. -Paper mode and sim works fine. -Pair is ETH-USD. -NodeJS version is 8.8.1.

morey-tech commented 6 years ago

I'm having the same issue. In live trading, it won't make any trades even when manually telling it to buy/sell. I had run it in live with the debug option and received no errors. Making trades on Bitfinex works when using 'zenbot buy/sell'. The pair I tried is LTC-BTC. Though the price is updating fine for me.

nedievas commented 6 years ago

No issue with LTC-BTC. capture What strategy are you using?

dentatar commented 6 years ago

Im using MACD. Not working either with default options or overrided options.

nedievas commented 6 years ago

Have you refreshed products.json?

dentatar commented 6 years ago

Yes i refreshed it

nedievas commented 6 years ago

You should adjust buy_pct to no more than 90%.

dentatar commented 6 years ago

This is my current options:

{
    max_sell_loss_pct: '5',
    down_trend_threshold: -0.25,
    up_trend_threshold: 0.25,
    order_adjust_time: 5000,
    debug: true,
    strategy: 'macd',
    sell_stop_pct: 0,
    buy_stop_pct: 0,
    profit_stop_enable_pct: 0,
    profit_stop_pct: 1,
    max_slippage_pct: 5,
    buy_pct: 99,
    sell_pct: 99,
    order_poll_time: 5000,
    markup_pct: 0,
    order_type: 'maker',
    poll_trades: 30000,
    currency_capital: 1000,
    asset_capital: 0,
    rsi_periods: 25,
    avg_slippage_pct: 0.045,
    stats: true,
    mode: 'live',
    selector: 'bitfinex.ETH-USD',
    period: '1h',
    min_periods: 52,
    ema_short_period: 12,
    ema_long_period: 26,
    signal_period: 9,
    overbought_rsi_periods: 25,
    overbought_rsi: 70
}
nedievas commented 6 years ago

long period...

dentatar commented 6 years ago

But when i use paper mode I can see price updates several times in a minute and can execute sell/buy immediately. Live mode just updates the price once an hour and doesn't do anything :\

dentatar commented 6 years ago

Just tried ETH-BTC pair with no luck.

dentatar commented 6 years ago

@nedievas I tried LTC-BTC pair and it works fine lol. Checked my products.json for eth/usd:

  {
    "asset": "ETH",
    "currency": "USD",
    "min_size": "0.04",
    "max_size": "5000.0",
    "increment": "0.0001",
    "label": "ETH/USD"
  },
nedievas commented 6 years ago

It is your side issue. Sorry ;)

dentatar commented 6 years ago

Maybe, but can you give any advice? I'm not the only one with that problem :(

nedievas commented 6 years ago

search for different points: maybe it's period, 100% buy...

emseee commented 6 years ago

Having the same issue on Bitfinex. Trades perfectly fine on poloniex though. bitfinex

dentatar commented 6 years ago

Any pair works fine except eth/usd...

nedievas commented 6 years ago

refresh products.js by executing update-products.sh. Bitfinex updates minimal orders every week!

emseee commented 6 years ago

Thank you @nedievas trying to do so now but when executing ./update-products.sh I get -bash: ./update-products.sh: Permission denied Can you please advise?

Thanks

nedievas commented 6 years ago

ls -l to check permissions

emseee commented 6 years ago

@nedievas that's what I got: -rw-rw-r-- 1 myusername myusername 130 Nov 21 19:53 _codemap.js -rw-rw-r-- 1 myusername myusername 15234 Nov 21 19:53 exchange.js -rw-rw-r-- 1 myusername myusername 5520 Nov 21 19:53 products.json -rw-rw-r-- 1 myusername myusername 1037 Nov 21 19:53 update-products.sh

nedievas commented 6 years ago

chmod 744 update-products.sh

dentatar commented 6 years ago

I refreshed products and tried like 10 different pairs. Only pairs with ETH doesn't work... How could it be my side issue?

kareha commented 6 years ago

I think I found the issue: syncBalance() in engine.js will not cal the callback if you are in live mode and you have never traded that asset before.

Than, bitfinex will not give you the wallet balance for that asset (see function updateWallet (wallets) {} in exchange.js) The wallets value only has the currencies and assents you have traded before, also if the balance is zero.

The result of that is, that waitForCalc('getBalance', opts, cb) will run forever.

Maybe you can fix that with:

Split up in exchange.js:

else if (
        (ws_walletCalcDone[opts.asset] === false && ws_walletCalcDone[opts.currency] === true) ||
        (ws_walletCalcDone[opts.asset] === true && ws_walletCalcDone[opts.currency] === false)
      ) {
        return waitForCalc('getBalance', opts, cb)
      }

and put in:

else if (ws_walletCalcDone[opts.currency] === true && ws_walletCalcDone[opts.asset] === false) {
   // assume asset has never been traded before
   ws_balance[opts.asset].balance = ws_balance[opts.asset].available = 0
   ws_walletCalcDone[opts.asset] = true
}

.. in getBalance: function (opts, cb) { .. }

Paper mode is not effected because:

    function syncBalance (cb) {
      if (so.mode !== 'live') {
        return cb()
      }
...
kareha commented 6 years ago

I recognize that after I put console.log('wallets:', wallets) into function updateWallet (wallets) { .. } and all by traded assets were in the array, but not the others (and where I have issues with).

DeviaVir commented 6 years ago

Dear issue reporter,

We have slightly changed our github issue policy and would now kindly request folks that have questions that they ask them in our zenbot subreddit.

You can find it here: https://reddit.com/r/zenbot

This issue will be closed, but if you disagree with your ticket being marked as a question feel free to leave a comment defending your case.

Thanks for contributing time and effort!

Greetings, 🤖