ctubio / Krypto-trading-bot

Self-hosted crypto trading bot (automated high frequency market making) written in C++
https://127.0.0.1:3000
Other
3.37k stars 823 forks source link

GDAX invalid API key #47

Closed VictorStastra closed 7 years ago

VictorStastra commented 7 years ago

let me first thank you guys for publishing this bot! However, I spent 2 nights getting it to work but to no avail. I keep getting the error message: "invalid API key" when trying to use the bot with GDAX. I double checked the passphrase, key and secret (with and without ==) but no luck. Also tried 2 different requested API keys for GDAX. Trying to trade ETH/EUR.

Maybe it has to do with Stunnel, however from the readme I gathered that no specific actions has to be taken for launching stunnel. I have installed stunnel on my host (windows 10) pc.

Hopefully someone can help me, thanks in advance!

Full log below:

warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms 05:20:51.402 main Requiring authentication to web client 05:20:51.436 main Listening to admins on port 3000 05:20:52.065 broker Exchange details { exchange: 'Coinbase', pair: 'ETH/EUR', minTick: 0.01, minSize: 0.01, makeFee: 0, takeFee: 0, hasSelfTradePrevention: true } 05:20:52.084 coinbase FIX Initiator Start 05:20:52.087 coinbase FIX Logon Disconnected 05:20:52.521 coinbase Unable to read Coinbase positions { message: 'Invalid API Key' } 05:20:52.631 main Unhandled exception! Failed to load orderbook: 404 05:20:52.632 main Attempting to cancel all open orders, please wait.. 05:20:52.639 main Unhandled exception! { Error: socket hang up at createHangUpError (_http_client.js:302:15) at TLSSocket.socketOnEnd (_http_client.js:394:23) at emitNone (events.js:91:20) at TLSSocket.emit (events.js:188:7) at endReadableNT (_stream_readable.js:975:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNRESET' } 05:20:52.640 main Attempting to cancel all open orders, please wait.. 05:20:52.641 main Attempting to cancel all open orders, please wait.. 05:20:52.640 main Unhandled exception! TypeError: Cannot read property 'aborted' of null at ClientRequest._req.on (/K/node_modules/ws/lib/WebSocket.js:639:18) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:191:7) at TLSSocket.socketCloseListener (_http_client.js:334:9) at emitOne (events.js:101:20) at TLSSocket.emit (events.js:191:7) at _handle.close (net.js:511:12) at TCP.done [as _onclose] (_tls_wrap.js:332:7) 05:20:53.074 stdev Unable to compute value 05:20:54.076 stdev Unable to compute value 05:20:54.632 main Exit code 0 error: Forever detected script exited with code: 0 error: Script restart attempt #1 05:20:55.136 main Requiring authentication to web client 05:20:55.155 main Listening to admins on port 3000 05:20:55.755 broker Exchange details { exchange: 'Coinbase', pair: 'ETH/EUR', minTick: 0.01, minSize: 0.01, makeFee: 0, takeFee: 0, hasSelfTradePrevention: true } 05:20:55.776 coinbase FIX Initiator Start 05:20:55.777 coinbase FIX Logon Disconnected 05:20:56.211 coinbase Unable to read Coinbase positions { message: 'Invalid API Key' } 05:20:56.331 main Unhandled exception! Failed to load orderbook: 404 05:20:56.332 main Attempting to cancel all open orders, please wait.. 05:20:56.360 main Attempting to cancel all open orders, please wait.. 05:20:56.359 main Unhandled exception! { Error: socket hang up at createHangUpError (_http_client.js:302:15) at TLSSocket.socketOnEnd (_http_client.js:394:23) at emitNone (events.js:91:20) at TLSSocket.emit (events.js:188:7) at endReadableNT (_stream_readable.js:975:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNRESET' } 05:20:56.363 main Attempting to cancel all open orders, please wait.. 05:20:56.361 main Unhandled exception! TypeError: Cannot read property 'aborted' of null at ClientRequest._req.on (/K/node_modules/ws/lib/WebSocket.js:639:18) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:191:7) at TLSSocket.socketCloseListener (_http_client.js:334:9) at emitOne (events.js:101:20) at TLSSocket.emit (events.js:191:7) at _handle.close (net.js:511:12) at TCP.done [as _onclose] (_tls_wrap.js:332:7) 05:20:56.765 stdev Unable to compute value 05:20:57.766 stdev Unable to compute value 05:20:58.332 main Exit code 0 error: Forever detected script exited with code: 0 error: Script restart attempt #2 05:20:58.831 main Requiring authentication to web client 05:20:58.848 main Listening to admins on port 3000 05:20:59.501 broker Exchange details { exchange: 'Coinbase', pair: 'ETH/EUR', minTick: 0.01, minSize: 0.01, makeFee: 0, takeFee: 0, hasSelfTradePrevention: true } 05:20:59.521 coinbase FIX Initiator Start 05:20:59.522 coinbase FIX Logon Disconnected 05:21:00.112 coinbase Unable to read Coinbase positions { message: 'Invalid API Key' } 05:21:00.180 main Unhandled exception! Failed to load orderbook: 404 05:21:00.181 main Attempting to cancel all open orders, please wait.. 05:21:00.182 main Unhandled exception! { Error: socket hang up at createHangUpError (_http_client.js:302:15) at TLSSocket.socketOnEnd (_http_client.js:394:23) at emitNone (events.js:91:20) at TLSSocket.emit (events.js:188:7) at endReadableNT (_stream_readable.js:975:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNRESET' } 05:21:00.184 main Attempting to cancel all open orders, please wait.. 05:21:00.186 main Attempting to cancel all open orders, please wait.. 05:21:00.185 main Unhandled exception! TypeError: Cannot read property 'aborted' of null at ClientRequest._req.on (/K/node_modules/ws/lib/WebSocket.js:639:18) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:191:7) at TLSSocket.socketCloseListener (_http_client.js:334:9) at emitOne (events.js:101:20) at TLSSocket.emit (events.js:191:7) at _handle.close (net.js:511:12) at TCP.done [as _onclose] (_tls_wrap.js:332:7) 05:21:00.510 stdev Unable to compute value 05:21:01.510 stdev Unable to compute value 05:21:02.182 main Exit code 0 error: Forever detected script exited with code: 0 error: Script restart attempt #3 05:21:02.677 main Requiring authentication to web client 05:21:02.695 main Listening to admins on port 3000 05:21:03.471 broker Exchange details { exchange: 'Coinbase', pair: 'ETH/EUR', minTick: 0.01, minSize: 0.01, makeFee: 0, takeFee: 0, hasSelfTradePrevention: true } 05:21:03.490 coinbase FIX Initiator Start 05:21:03.492 coinbase FIX Logon Disconnected 05:21:04.068 coinbase Unable to read Coinbase positions { message: 'Invalid API Key' } 05:21:04.245 main Unhandled exception! Failed to load orderbook: 404 05:21:04.246 main Attempting to cancel all open orders, please wait.. 05:21:04.262 main Attempting to cancel all open orders, please wait.. 05:21:04.261 main Unhandled exception! { Error: socket hang up at createHangUpError (_http_client.js:302:15) at TLSSocket.socketOnEnd (_http_client.js:394:23) at emitNone (events.js:91:20) at TLSSocket.emit (events.js:188:7) at endReadableNT (_stream_readable.js:975:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) code: 'ECONNRESET' } 05:21:04.265 main Attempting to cancel all open orders, please wait.. 05:21:04.262 main Unhandled exception! TypeError: Cannot read property 'aborted' of null at ClientRequest._req.on (/K/node_modules/ws/lib/WebSocket.js:639:18) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:191:7) at TLSSocket.socketCloseListener (_http_client.js:334:9) at emitOne (events.js:101:20) at TLSSocket.emit (events.js:191:7) at _handle.close (net.js:511:12) at TCP.done [as _onclose] (_tls_wrap.js:332:7) 05:21:04.480 stdev Unable to compute value 05:21:05.481 stdev Unable to compute value 05:21:06.247 main Exit code 0 error: Forever detected script exited with code: 0 error: Script restart attempt #4

Dockerfile: RUN apt-get install -y git sudo

Feel free to choose the branch you want to build:

RUN git clone -b master https://github.com/ctubio/Krypto-trading-bot.git K

WORKDIR K

Remove the ssl certificate (GUI accessible over plain HTTP, not recommended):

RUN npm install --unsafe-perm

EXPOSE 3000 5000

General config properties. Replace with your own exchange account information:

ENV BotIdentifier autodev_bot ENV EXCHANGE coinbase ENV TradedPair ETH/EUR ENV WebClientUsername xxxxx ENV WebClientPassword xxxx ENV WebClientListenPort 3000 ENV MatryoshkaUrl https://

Set options only for your desired EXCHANGE:

Coinbase GDAX

ENV CoinbaseRestUrl https://api-public.sandbox.gdax.com ENV CoinbaseWebsocketUrl wss://ws-feed-public.sandbox.gdax.com ENV CoinbasePassphrase xxxxxx ENV CoinbaseApiKey xxxxxxx ENV CoinbaseSecret xxxxxxx ENV CoinbaseOrderDestination Coinbase

OkCoin

ENV OkCoinWsUrl wss://real.okcoin.com:10440/websocket/okcoinapi ENV OkCoinHttpUrl https://www.okcoin.com/api/v1/ ENV OkCoinApiKey NULL ENV OkCoinSecretKey NULL ENV OkCoinOrderDestination OkCoin

Bitfinex

ENV BitfinexHttpUrl https://api.bitfinex.com/v1 ENV BitfinexWebsocketUrl wss://api.bitfinex.com/ws/2 ENV BitfinexKey NULL ENV BitfinexSecret NULL ENV BitfinexOrderDestination Bitfinex

Poloniex

ENV PoloniexHttpUrl https://poloniex.com ENV PoloniexWebsocketUrl wss://api.poloniex.com ENV PoloniexApiKey NULL ENV PoloniexSecretKey NULL ENV PoloniexOrderDestination Poloniex

Korbit

ENV KorbitHttpUrl https://api.korbit.co.kr/v1 ENV KorbitApiKey NULL ENV KorbitSecretKey NULL ENV KorbitUsername NULL ENV KorbitPassword NULL ENV KorbitOrderDestination Korbit

HitBtc

ENV HitBtcPullUrl http://demo-api.hitbtc.com ENV HitBtcOrderEntryUrl ws://demo-api.hitbtc.com:8080 ENV HitBtcMarketDataUrl ws://demo-api.hitbtc.com:80 ENV HitBtcSocketIoUrl https://demo-api.hitbtc.com:8081 ENV HitBtcApiKey NULL ENV HitBtcSecret NULL ENV HitBtcOrderDestination HitBtc

Quoting Parameters

ENV delayUI 3

CMD ["node_modules/.bin/forever", "K.js"]

ctubio commented 7 years ago

the api key may be invalid, did you try to create a new key or to edit the permissions of the current key?

i would suggest to contact gdax support if you still get this error of invalid api key (at https://support.gdax.com/customer/portal/emails/new)

ctubio commented 7 years ago

if the key is encoded in base64, the last symbols of == are part of the encoded content; removing them effectively brakes the base64 encoded content (the api key)

VictorStastra commented 7 years ago

Thanks for your reply! I added the double == at the end of the secret, and tried it with a new API key. I now get the following log:

warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms K.linux.51 DB 3.6.2 loaded OK UI ready over HTTPS on external port 3000 14:10:38.508 main Error THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END IS NEVER THE END 14:10:38.495 main Unhandled rejection! Error: Unable to connect to Coinbase, seems currently offline. Please retry once is online. at Object. (/K/app/server/gateways/coinbase.js:520:19) at Generator.next () at fulfilled (/K/app/server/gateways/coinbase.js:4:58) at process._tickCallback (internal/process/next_tick.js:109:7) Promise {

Error: Unable to connect to Coinbase, seems currently offline. Please retry once is online. at Object. (/K/app/server/gateways/coinbase.js:520:19) at Generator.next () at fulfilled (/K/app/server/gateways/coinbase.js:4:58) at process._tickCallback (internal/process/next_tick.js:109:7) } 14:10:40.512 main Exit code 0 error: Forever detected script exited with code: 0 error: Script restart attempt #1

I tried to fix this by running: "npm run test-stunnel" in the docker toolbox terminal (MINGW64) from the folder where my Dockerfile is. I then get the following error:

0 info it worked if it ends with ok 1 verbose cli [ 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Users\USER NAME\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'test-stunnel' ] 2 info using npm@5.1.0 3 info using node@v7.10.0 4 verbose run-script [ 'pretest-stunnel', 'test-stunnel', 'posttest-stunnel' ] 5 info lifecycle K.js@3.0.0~pretest-stunnel: K.js@3.0.0 6 info lifecycle K.js@3.0.0~test-stunnel: K.js@3.0.0 7 verbose lifecycle K.js@3.0.0~test-stunnel: unsafe-perm in lifecycle true 8 verbose lifecycle K.js@3.0.0~test-stunnel: PATH: C:\Users\USER NAME\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;E:\crypto\K\node_modules.bin;C:\Users\USER NAME\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\USER NAME\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Java\jdk1.8.0_121\bin;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\system32\wbem;C:\windows\system32\windowspowershell\v1.0;C:\program files\miktex 2.9\miktex\bin\x64;D:\data science\anaconda3;D:\data science\anaconda3\scripts;D:\data science\anaconda3\library\bin;C:\program files (x86)\graphviz2.38\bin;C:\users\USER NAME\appdata\local\microsoft\windowsapps;C:\adb;C:\Program Files (x86)\Skype\Phone;C:\Program Files\MATLAB\R2016b\bin;C:\Program Files\Cloud Foundry;C:\Program Files\CMake\bin;C:\Users\USER NAME.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Users\USER NAME\caffe\python;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Git\cmd;C:\Users\USER NAME\AppData\Roaming\npm;C:\Program Files\nodejs;C:\Anaconda3;C:\Anaconda3\Scripts;C:\Anaconda3\Library\bin;C:\Program Files (x86)\Graphviz2.38\bin;C:\Users\USER NAME\AppData\Local\Microsoft\WindowsApps;C:\Users\USER NAME\AppData\Local\Microsoft\WindowsApps;C:\Program Files\nodejs;C:\Users\USER NAME\AppData\Roaming\npm;C:\Program Files\Docker Toolbox;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl 9 verbose lifecycle K.js@3.0.0~test-stunnel: CWD: E:\crypto\K 10 silly lifecycle K.js@3.0.0~test-stunnel: Args: [ '/d /s /c', 10 silly lifecycle 'test -z "$SKIP_STUNNEL$(ps axu | grep stunnel | grep -v grep)" && exec stunnel dist/K-stunnel.conf || :' ] 11 silly lifecycle K.js@3.0.0~test-stunnel: Returned: code: 1 signal: null 12 info lifecycle K.js@3.0.0~test-stunnel: Failed to exec test-stunnel script 13 verbose stack Error: K.js@3.0.0 test-stunnel: test -z "$SKIP_STUNNEL$(ps axu | grep stunnel | grep -v grep)" && exec stunnel dist/K-stunnel.conf || : 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (C:\Users\USER NAME\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:289:16) 13 verbose stack at emitTwo (events.js:106:13) 13 verbose stack at EventEmitter.emit (events.js:194:7) 13 verbose stack at ChildProcess. (C:\Users\USER NAME\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14) 13 verbose stack at emitTwo (events.js:106:13) 13 verbose stack at ChildProcess.emit (events.js:194:7) 13 verbose stack at maybeClose (internal/child_process.js:899:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) 14 verbose pkgid K.js@3.0.0 15 verbose cwd E:\crypto\K\build 16 verbose Windows_NT 10.0.15063 17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\USER NAME\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "test-stunnel" 18 verbose node v7.10.0 19 verbose npm v5.1.0 20 error code ELIFECYCLE 21 error errno 1 22 error K.js@3.0.0 test-stunnel: test -z "$SKIP_STUNNEL$(ps axu | grep stunnel | grep -v grep)" && exec stunnel dist/K-stunnel.conf || : 22 error Exit status 1 23 error Failed at the K.js@3.0.0 test-stunnel script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

I also tried to run "npm run test-stunnel" inside the container by "docker-machine ssh" and then running the command, but then I get:

-sh: npm: not found.

Hope you can help me out and thanks again!

VictorStastra commented 7 years ago

Oh and I checked that coinbase/gdax was in fact Online when trying above. Previously I used Docker for Windows, but now trying it with Docker Toolbox, this to make sure docker is running on the docker machine 'default'.