DeviaVir / zenbot

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

binance api, in a file that does not require changes acording to the guide #1729

Closed GeoDk closed 5 years ago

GeoDk commented 5 years ago

System information

git clone https://github.com/deviavir/zenbot.git cd zenbot npm install

git clone https://github.com/deviavir/zenbot.git cp conf-sample.js conf.js cd zenbot npm install

./zenbot.sh trade binance.ZEC-BTC --strategy=neural --buy_pct 100 --sell_pct 100 --markup_sell_pct=0.20 --markdown_buy_pct=0.20 --period=2m --max_sell_loss_pct=1 --threads=4 --momentum=0.88

Describe the problem

Describe the problem clearly here. Be sure to convey here why it's a bug in Zenbot or a feature request. When i run ./zenbot.sh trade binance.ZEC-BTC --strategy=neural --buy_pct 100 --sell_pct 100 --markup_sell_pct=0.20 --markdown_buy_pct=0.20 --period=2m --max_sell_loss_pct=1 --threads=4 --momentum=0.88

i get the error when i run ./zenbot.sh trade --paper no errors

the error is \SyntaxError: Invalid or unexpected token, falling back to conf-sample (node:26653) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect. fetching pre-roll data: (node:26653) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead. SyntaxError: Invalid or unexpected token, falling back to conf-sample (node:26666) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect. (node:26666) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead. (node:26666) DeprecationWarning: collection.save is deprecated. Use insertOne, insertMany, updateOne, or updateMany instead.

skipping 135 hrs of previously collected data

binance.ZEC-BTC saved 500 trades 1 days left . download complete!

           DATE            PRICE     DIFF       VOL     RSI                         ACTIONS                      BAL                PROFIT

------------------------------------------ INITIALIZE OUTPUT ------------------------------------------ SyntaxError: Invalid or unexpected token, falling back to conf-sample ---------------------------------------- STARTING LIVE TRADING ---------------------------------------- Press l to list available commands. /home/morten/zenbot/node_modules/mongodb/lib/utils.js:132 throw err; ^

Error: please configure your Binance credentials in /home/morten/zenbot/extensions/exchanges/binance/conf.js at authedClient (/home/morten/zenbot/extensions/exchanges/binance/exchange.js:20:15) at Object.getBalance (/home/morten/zenbot/extensions/exchanges/binance/exchange.js:127:20) at Object.syncBalance (/home/morten/zenbot/lib/engine.js:211:16) at /home/morten/zenbot/commands/trade.js:443:22 at result (/home/morten/zenbot/node_modules/mongodb/lib/utils.js:414:17) at executeCallback (/home/morten/zenbot/node_modules/mongodb/lib/utils.js:406:9) at handleCallback (/home/morten/zenbot/node_modules/mongodb/lib/utils.js:128:55) at cursor.close (/home/morten/zenbot/node_modules/mongodb/lib/operations/cursor_ops.js:211:62) at handleCallback (/home/morten/zenbot/node_modules/mongodb/lib/utils.js:128:55) at completeClose (/home/morten/zenbot/node_modules/mongodb/lib/cursor.js:893:14) at Cursor.close (/home/morten/zenbot/node_modules/mongodb/lib/cursor.js:912:10) at cursor._next (/home/morten/zenbot/node_modules/mongodb/lib/operations/cursor_ops.js:211:23) at handleCallback (/home/morten/zenbot/node_modules/mongodb-core/lib/cursor.js:203:5) at _setCursorNotifiedImpl (/home/morten/zenbot/node_modules/mongodb-core/lib/cursor.js:561:38) at self._endSession (/home/morten/zenbot/node_modules/mongodb-core/lib/cursor.js:569:46) at Cursor._endSession (/home/morten/zenbot/node_modules/mongodb-core/lib/cursor.js:194:5) at Cursor._endSession (/home/morten/zenbot/node_modules/mongodb/lib/cursor.js:226:59) at _setCursorNotifiedImpl (/home/morten/zenbot/node_modules/mongodb-core/lib/cursor.js:569:17) at setCursorNotified (/home/morten/zenbot/node_modules/mongodb-core/lib/cursor.js:561:3) at /home/morten/zenbot/node_modules/mongodb-core/lib/cursor.js:621:16 at queryCallback (/home/morten/zenbot/node_modules/mongodb-core/lib/cursor.js:289:5) at /home/morten/zenbot/node_modules/mongodb-core/lib/connection/pool.js:532:18 morten@Ubuntulaptop:~/zenbot$ (node:26683) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.

i of cource read the error. and thought i forgot my api key and security key, but in conf.js in zenbot folder. it is there. i cant find any thing in the file that need to be changed. Error: please configure your Binance credentials in /home/morten/zenbot/extensions/exchanges/binance/conf.js OBS>Morten is my computer name.

the strange thing is it works with the --paper function_ so what can i do to make it work? i also tried npm audit fix npm ERR! code E400 npm ERR! 400 Bad Request - POST https://registry.npmjs.org/-/npm/v1/security/audits

npm ERR! A complete log of this run can be found in: npm ERR! /home/morten/.npm/_logs/2018-10-05T06_27_27_847Z-debug.log

0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'audit', 'fix' ] 2 info using npm@6.4.1 3 info using node@v10.11.0 4 verbose npm-session 898192537c7631ec 5 timing audit compress Completed in 27ms 6 info audit Submitting payload of 104225 bytes 7 http fetch POST 400 https://registry.npmjs.org/-/npm/v1/security/audits 1675ms 8 verbose stack Error: 400 Bad Request - POST https://registry.npmjs.org/-/npm/v1/security/audits 8 verbose stack at res.buffer.catch.then.body (/usr/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:94:15) 8 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7) 9 verbose statusCode 400 10 verbose cwd /home/morten/zenbot 11 verbose Linux 4.15.0-29-generic 12 verbose argv "/usr/bin/node" "/usr/bin/npm" "audit" "fix" 13 verbose node v10.11.0 14 verbose npm v6.4.1 15 error code E400 16 error 400 Bad Request - POST https://registry.npmjs.org/-/npm/v1/security/audits 17 verbose exit [ 1, true ]

Shawn8901 commented 5 years ago

If you read the error, there seems to be a Syntax error in your conf.js. so it can't be parsed and then ofc, the API key is missing (can't be even parsed)

double check your conf.js.

GeoDk commented 5 years ago

sorry should have said i tried to understand the error. :s I have tried to make a new conf.js with the api key and secret key to binance and nothing new happend. i took the conf_sample.js and change it to to conf.js as save as.

but isnt the api key file it asking for in another place that don't exist?

Shawn8901 commented 5 years ago

The lookup for the folder in the error message is the following: path.resolve(__dirname, 'conf.js') Not 100% sure why the folder is wrong, as __dirname should resolve to the folder where you startup the nodejs. Anyways, the invalid syntax error is the place what you have to fix as first step.

GeoDk commented 5 years ago

but how do i do that? :)

Shawn8901 commented 5 years ago

Not seeing the conf file i personally can not help. a conf-file has to be valid js content.

edit: if posting your conf.js somewhere else, its a good to remove API-Key as otherwise other ppl would get access to your account!

What could easly break the parsing: if you have a " or ' in your api key or missing a , " or ' something like this. you can try to put it into to browser, it should also complain about syntax errors.

GeoDk commented 5 years ago

can i upload it so u can take a look at it? ofc with api key removed. there are no errors in the api key or the secret key

Shawn8901 commented 5 years ago

Feel free, to upload it.

GeoDk commented 5 years ago

var c = module.exports = {}

// mongo configuration c.mongo = {} c.mongo.db = 'zenbot4'

// Must provide EITHER c.mongo.connectionString OR c.mongo.host,port,username,password // c.mongo.connectionString = 'mongodb://u:p@host/db?params'

// The following is not needed when c.mongo.connectionString is provided: c.mongo.host = process.env.MONGODB_PORT_27017_TCP_ADDR || 'localhost' c.mongo.port = 27017 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 c.mongo.authMechanism = null

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

// Exchange API keys:

// to enable GDAX trading, enter your API credentials: c.gdax = {} c.gdax.key = 'YOUR-API-KEY' c.gdax.b64secret = 'YOUR-BASE64-SECRET' c.gdax.passphrase = 'YOUR-PASSPHRASE'

// 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 Binance trading, enter your API credentials: c.binance = {} c.binance.key = 'YOUR-API-KEY' c.binance.secret = 'YOUR-SECRET'

// 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 = 'YOUR-API-KEY' c.bitfinex.secret = 'YOUR-SECRET' // May use 'exchange' or 'margin' wallet balances c.bitfinex.wallet = 'exchange'

// to enable Bitstamp 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 CEX.IO trading, enter your API credentials: c.cexio = {} c.cexio.username = 'YOUR-CLIENT-ID' c.cexio.key = 'YOUR-API-KEY' c.cexio.secret = 'YOUR-SECRET'

// 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 WEX.NZ trading, enter your API credentials: // Note: WexNZ only supports backfilling the last ~1/4 day ATM. c.wexnz = {} c.wexnz.key = 'YOUR-API-KEY' c.wexnz.secret = 'YOUR-SECRET'

// to enable Gemini trading, enter your API credentials: c.gemini = {} c.gemini.key = 'YOUR-API-KEY' c.gemini.secret = 'YOUR-SECRET' // set to false to trade on the live platform API c.gemini.sandbox = true

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

// to enable therock trading, enter your API credentials: c.therock = {} c.therock.key = 'YOUR-API-KEY' c.therock.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 = 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 = 99 // avoid buying at a loss above this pct set to 0 to ensure buying at a lower price... c.max_buy_loss_pct = 99 // 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 down buy price for orders c.markdown_buy_pct = 0 // % to mark up sell price for orders c.markup_sell_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 // use separated fee currency such as binance's BNB. c.use_fee_asset = false

// Misc options:

// default # days for backfill and sim commands c.days = 14 // defaults to a high number of lookback periods c.keep_lookback_periods = 50000 // 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 = 0 // 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 // time to leave an order open, default to 1 day (this feature is not supported on all exchanges, currently: GDAX) c.cancel_after = 'day' // load and use previous trades for stop-order triggers and loss protection (live/paper mode only) c.use_prev_trades = false // minimum number of previous trades to load if use_prev_trades is enabled, set to 0 to disable and use trade time instead c.min_prev_trades = 0

// Notifiers: c.notifiers = {}

// xmpp config c.notifiers.xmpp = {} c.notifiers.xmpp.on = false // false xmpp disabled; true xmpp enabled (credentials should be correct) c.notifiers.xmpp.jid = 'trader@domain.com' c.notifiers.xmpp.password = 'Password' c.notifiers.xmpp.host = 'domain.com' c.notifiers.xmpp.port = 5222 c.notifiers.xmpp.to = 'MeMyselfAndI@domain.com' // end xmpp configs

// pushbullets configs c.notifiers.pushbullet = {} c.notifiers.pushbullet.on = false // false pushbullets disabled; true pushbullets enabled (key should be correct) c.notifiers.pushbullet.key = 'YOUR-API-KEY' c.notifiers.pushbullet.deviceID = 'YOUR-DEVICE-ID' // end pushbullets configs

// ifttt configs c.notifiers.ifttt = {} c.notifiers.ifttt.on = false // false ifttt disabled; true ifttt enabled (key should be correct) c.notifiers.ifttt.makerKey = 'YOUR-API-KEY' c.notifiers.ifttt.eventName = 'zenbot' // end ifttt configs

// slack config c.notifiers.slack = {} c.notifiers.slack.on = false c.notifiers.slack.webhook_url = '' // end slack config

// discord configs c.notifiers.discord = {} c.notifiers.discord.on = false // false discord disabled; true discord enabled (key should be correct) c.notifiers.discord.id = 'YOUR-WEBHOOK-ID' c.notifiers.discord.token = 'YOUR-WEBHOOK-TOKEN' c.notifiers.discord.username = '' // default "Zenbot" c.notifiers.discord.avatar_url = '' c.notifiers.discord.color = null // color as a decimal // end discord configs

// prowl configs c.notifiers.prowl = {} c.notifiers.prowl.on = false // false prowl disabled; true prowl enabled (key should be correct) c.notifiers.prowl.key = 'YOUR-API-KEY' // end prowl configs

// textbelt configs c.notifiers.textbelt = {} c.notifiers.textbelt.on = false // false textbelt disabled; true textbelt enabled (key should be correct) c.notifiers.textbelt.phone = '3121234567' c.notifiers.textbelt.key = 'textbelt' // end textbelt configs

// pushover configs c.notifiers.pushover = {} c.notifiers.pushover.on = false // false pushover disabled; true pushover enabled (keys should be correct) c.notifiers.pushover.token = 'YOUR-API-TOKEN' // create application and supply the token here c.notifiers.pushover.user = 'YOUR-USER-KEY' // this is your own user's key (not application related) c.notifiers.pushover.priority = '0' // choose a priority to send zenbot messages with, see https://pushover.net/api#priority // end pushover configs

// telegram configs c.notifiers.telegram = {} c.notifiers.telegram.on = false // false telegram disabled; true telegram enabled (key should be correct) c.notifiers.telegram.bot_token = 'YOUR-BOT-TOKEN' c.notifiers.telegram.chat_id = 'YOUR-CHAT-ID' // the id of the chat the messages should be send in // end telegram configs

// output c.output = {}

// REST API c.output.api = {} c.output.api.on = true c.output.api.ip = '0.0.0.0' // IPv4 or IPv6 address to listen on, uses all available interfaces if omitted c.output.api.port = 0 // 0 = random port, set to 17365 if you use docker

Shawn8901 commented 5 years ago

Please use code tags for further posts of such content like configurations or logs. For this output i dont see any syntax errors, could be related to your keys (as you have changed it), maybe it has a ' in it, i dont know?? For me here i dont see where to do futher assists or how to help, Sorry.

But as long as zb complains about that invalid syntax stuff, i am pretty sure, that it will not load your configuration.

GeoDk commented 5 years ago

i will try on a fresh install of ubuntu thank u

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.