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 Credentials not working #545

Closed elikjwilliams closed 7 years ago

elikjwilliams commented 7 years ago

I have created an api key. I gave it read and write with all the parameters except withdraw and I still am getting this error.

/home/user/zenbot/extensions/exchanges/bitfinex/exchange.js:202 throw new Error('please configure your Bitfinex credentials in ' + path.resolve(__dirname, 'conf.js')) ^

Error: please configure your Bitfinex credentials in /home/user/zenbot/extensions/exchanges/bitfinex/conf.js at wsClient (/home/user/zenbot/extensions/exchanges/bitfinex/exchange.js:202:15) at Object.getBalance (/home/user/zenbot/extensions/exchanges/bitfinex/exchange.js:321:25) at Object.syncBalance (/home/user/zenbot/lib/engine.js:177:18) at Object. (/home/user/zenbot/commands/trade.js:223:24) at Immediate._onImmediate (/home/user/zenbot/node_modules/sosa/api.js:15:12) at runCallback (timers.js:781:20) at tryOnImmediate (timers.js:743:5) at processImmediate [as _immediateCallback] (timers.js:714:5)

Any help here?

nedievas commented 7 years ago

where did you put these credentials?

elikjwilliams commented 7 years ago

In the config file.

elikjwilliams commented 7 years ago

config file: c.bitfinex.key = 'mykey' c.bitfinex.secret = 'mysecret'

nedievas commented 7 years ago

where is it located? and how is it called?

elikjwilliams commented 7 years ago

it is located in the main zenbot folder. I call it through the command line as follows:

zenbot trade bitfinex.OMG-BTC --config conf22.js --strategy rsi --reset_profit

Do I need to move the config file elsewhere? It works for Gdax.

elikjwilliams commented 7 years ago

/home/user/zenbot/conf22.js

nedievas commented 7 years ago

is the structure of your custom config correct?

elikjwilliams commented 7 years ago

Yes. The same config works for GDax. It's just not working for bitfinex. I'm assuming it is something with the websockets. I just couldn't figure it out.

nedievas commented 7 years ago

paste your config here (!!! WITHOUT KEYS!!!). I'll try.

elikjwilliams commented 7 years ago

var c = module.exports = {}

// mongo configuration c.mongo = {} c.mongo.host = process.env.MONGODB_PORT_27017_TCP_ADDR || 'localhost' c.mongo.port = 27017 c.mongo.db = 'zenbot4' c.mongo.username = null c.mongo.password = null // when using mongodb replication, i.e. when running a mongodb cluster, you can define your replication set here; when you are not using replication (most of the users), just set it to null (default). c.mongo.replicaSet = null

// default selector. only used if omitting [selector] argument from a command. c.selector = 'bitfinex.OMG-BTC' // name of default trade strategy c.strategy = 'rsi'

// Exchange API keys:

// to enable GDAX trading, enter your API credentials: c.gdax = {} c.gdax.key = 'key' c.gdax.b64secret = 'secret' c.gdax.passphrase = 'phrase'

// to enable Poloniex trading, enter your API credentials: c.poloniex = {} c.poloniex.key = 'YOUR-API-KEY' c.poloniex.secret = 'YOUR-SECRET' // please note: poloniex does not support market orders via the API

// to enable Kraken trading, enter your API credentials: c.kraken = {} c.kraken.key = 'YOUR-API-KEY' c.kraken.secret = 'YOUR-SECRET' // Please read API TOS on https://www.kraken.com/u/settings/api c.kraken.tosagree = 'disagree'

// to enable Bittrex trading, enter your API credentials: c.bittrex = {} c.bittrex.key = 'YOUR-API-KEY' c.bittrex.secret = 'YOUR-SECRET' // make sure to give your API key access to only: "Trade Limit" and "Read Info", // please note that this might change in the future. // please note that bittrex API is limited, you cannot use backfills or sims (paper/live trading only)

// to enable Bitfinex trading, enter your API credentials: c.bitfinex = {} c.bitfinex.key = 'key' c.bitfinex.secret = 'secret' // May use 'exchange' or 'trading' wallet balances. However margin trading may not work...read the API documentation. c.bitfinex.wallet = 'exchange'

// to enable Bitfinex trading, enter your API credentials: c.bitstamp = {} c.bitstamp.key = 'YOUR-API-KEY' c.bitstamp.secret = 'YOUR-SECRET' // A client ID is required on Bitstamp c.bitstamp.client_id = 'YOUR-CLIENT-ID'

// to enable QuadrigaCX tranding, enter your API credentials: c.quadriga = {} c.quadriga.key = 'YOUR-API-KEY';

// this is the manual secret key entered by editing the API access // and NOT the md5 hash you see in the summary c.quadriga.secret = 'YOUR-SECRET';

// replace with the client id used at login, as a string, not number c.quadriga.client_id = 'YOUR-CLIENT-ID';

// to enable BTC-e trading, enter your API credentials: c.btce = {} c.btce.key = 'YOUR-API-KEY' c.btce.secret = 'YOUR-SECRET'

// Optional stop-order triggers:

// sell if price drops below this % of bought price (0 to disable) c.sell_stop_pct = 0 // buy if price surges above this % of sold price (0 to disable) c.buy_stop_pct = 0 // enable trailing sell stop when reaching this % profit (0 to disable) c.profit_stop_enable_pct = 55 // maintain a trailing stop this % below the high-water mark of profit c.profit_stop_pct = 55

// Order execution rules:

// avoid trading at a slippage above this pct c.max_slippage_pct = 1 // buy with this % of currency balance (WARNING : sim won't work properly if you set this value to 100) c.buy_pct = 10 // sell with this % of asset balance (WARNING : sim won't work properly if you set this value to 100) c.sell_pct = 10 // ms to adjust non-filled order after c.order_adjust_time = 900 // avoid selling at a loss below this pct c.max_sell_loss_pct = 0 // ms to poll order status c.order_poll_time = 300 // ms to wait for settlement (after an order cancel) c.wait_for_settlement = 300 // % to mark up or down price for orders c.markup_pct = 0 // become a market taker (high fees) or a market maker (low fees) c.order_type = 'maker'

// Misc options:

// default # days for backfill and sim commands c.days = 14 // ms to poll new trades at c.poll_trades = 30000 // amount of currency to start simulations with c.currency_capital = 1000 // amount of asset to start simulations with c.asset_capital = 2.5 // for sim, reverse time at the end of the graph, normalizing buy/hold to 0 c.symmetrical = false // number of periods to calculate RSI at c.rsi_periods = 14 // period to record balances for stats c.balance_snapshot_period = '15m' // avg. amount of slippage to apply to sim trades c.avg_slippage_pct = 0.045

//xmpp configs

c.xmppon=0 // 0 xmpp disabled; 1 xmpp enabled (credentials should be correct)

if (c.xmppon) {

c.xmpp = require('simple-xmpp');

c.xmpp.connect({ jid : 'trader@domain.com', //xmpp account trader bot password : 'Password', //xmpp password host : 'domain.com', //xmpp domain port : 5222 //xmpp port });

c.xmppto="MeMyselfAndI@domain.com" //xmpp alert to friend } //end xmpp configs

elikjwilliams commented 7 years ago

I manually set c.bitfinex.key and c.bitfinex.secret in bitfinex's exchange.js. That has fixed my issue. exchange.js for bitfinex is not grabbing the data from the config. Looks like a bug

elikjwilliams commented 7 years ago

@DeviaVir This looks like a valid bug. Dont think the question label should be set here.

nedievas commented 7 years ago

@elikjwilliams Sorry, but it's your bug!

Your command: zenbot trade bitfinex.OMG-BTC --config conf22.js --strategy rsi --reset_profit

Correct command: zenbot trade bitfinex.OMG-BTC --conf conf22.js --strategy rsi --reset_profit

Find only one difference!

Thanks.

dghete commented 7 years ago

I get the same error. This is my command:

zenbot trade bitfinex.BTC-USD --conf conf-bitfinex.js --reset_profit

API Key & Secret are redacted, the error is with the correct ones. If placing them directly in

zenbot/extensions/exchanges/bitfinex/exchange.js where the error is thrown it works.

This is my config



// mongo configuration
c.mongo = {}
c.mongo.host = process.env.MONGODB_PORT_27017_TCP_ADDR || 'localhost'
c.mongo.port = 27017
c.mongo.db = 'zenbot4'
c.mongo.username = null
c.mongo.password = null
// when using mongodb replication, i.e. when running a mongodb cluster, you can define your replication set here; when you are not using replication (most of the users), just set it to `null` (default).
c.mongo.replicaSet = null

// default selector. only used if omitting [selector] argument from a command.
c.selector = 'bitfinex.BTC-USD'
// name of default trade strategy
c.strategy = 'macd'

// Exchange API keys:

// to enable Bitfinex trading, enter your API credentials:
c.bitfinex = {}
c.bitfinex.key = 'xxxxxx'
c.bitfinex.secret = 'xxxxxx'
// May use 'exchange' or 'trading' wallet balances. However margin trading may not work...read the API documentation.
c.bitfinex.wallet = 'exchange'

// Optional stop-order triggers:

// sell if price drops below this % of bought price (0 to disable)
c.sell_stop_pct = 0
// buy if price surges above this % of sold price (0 to disable)
c.buy_stop_pct = 0
// enable trailing sell stop when reaching this % profit (0 to disable)
c.profit_stop_enable_pct = 0
// maintain a trailing stop this % below the high-water mark of profit
c.profit_stop_pct = 1

// Order execution rules:

// avoid trading at a slippage above this pct
c.max_slippage_pct = 5
// buy with this % of currency balance (WARNING : sim won't work properly if you set this value to 100) 
c.buy_pct = 99
// sell with this % of asset balance (WARNING : sim won't work properly if you set this value to 100)
c.sell_pct = 99
// ms to adjust non-filled order after
c.order_adjust_time = 5000
// avoid selling at a loss below this pct set to 0 to ensure selling at a higher price...
c.max_sell_loss_pct = 25
// ms to poll order status
c.order_poll_time = 5000
// ms to wait for settlement (after an order cancel)
c.wait_for_settlement = 5000
// % to mark up or down price for orders
c.markup_pct = 0
// become a market taker (high fees) or a market maker (low fees)
c.order_type = 'maker'
// when supported by the exchange, use post only type orders.
c.post_only = true

// Misc options:

// default # days for backfill and sim commands
c.days = 14
// ms to poll new trades at
c.poll_trades = 30000
// amount of currency to start simulations with
c.currency_capital = 0
// amount of asset to start simulations with
c.asset_capital = 0.1
// for sim, reverse time at the end of the graph, normalizing buy/hold to 0
c.symmetrical = false
// number of periods to calculate RSI at
c.rsi_periods = 14
// period to record balances for stats
c.balance_snapshot_period = '15m'
// avg. amount of slippage to apply to sim trades
c.avg_slippage_pct = 0.045

//xmpp configs

c.xmppon=0  // 0 xmpp disabled; 1 xmpp enabled (credentials should be correct)

if (c.xmppon) {

  c.xmpp = require('simple-xmpp');

  c.xmpp.connect({
                jid                    : 'trader@domain.com', //xmpp account trader bot
                password               : 'Password',          //xmpp password
                host                   : 'domain.com',        //xmpp domain
                port                   : 5222                 //xmpp port
  });

  c.xmppto="MeMyselfAndI@domain.com" //xmpp alert to friend
}
//end xmpp configs```
dghete commented 7 years ago

It has the same behaviour if using gdax also.

If I copy conf-bitfinex.js over conf.js and run the command without --conf it works.

My impression is that the custom config gets overwritten.