├── .editorconfig ├── LICENSE ├── README.md ├── index.js └── package.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | # Matches multiple files with brace expansion notation 8 | [*.{js,jsx,json,html,sass,go}] 9 | charset = utf-8 10 | indent_style = tab 11 | indent_size = 2 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # crypto_bot 2 | 3 | ```bash 4 | node index.js --help 5 | 6 | ____ _ _ _ 7 | / ___|_ __ _ _ _ __ | |_ ___ | |__ ___ | |_ 8 | | | | '__| | | | '_ \| __/ _ \ _____| '_ \ / _ \| __| 9 | | |___| | | |_| | |_) | || (_) |_____| |_) | (_) | |_ 10 | \____|_| \__, | .__/ \__\___/ |_.__/ \___/ \__| 11 | |___/|_| 12 | 13 | Usage: index [options] 14 | 15 | Description: Simple CLI for programmatic trading of cryptocurrencies on GDAX 16 | 17 | Options: 18 | 19 | -h, --help output usage information 20 | -V, --version output the version number 21 | -i, --id [number] Get Account ID 22 | -l, --logs Get account raw logs [history/ledger] 23 | -b, --buy [price] [units] BUY: Buy crypto [price] [units] 24 | -s, --sell [price] [units] SELL: Sell crypto [price] [units] 25 | -d, --destroy DESTROY: Cancel all orders 26 | 27 | ``` 28 | 29 | ToDo: Documentation and bug fixes. Additional functionality in the works :) 30 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Node CLI for programmatic trading on GDAX 2 | 3 | const figlet = require('figlet'); 4 | const chalk = require('chalk'); 5 | const clear = require('clear'); 6 | const Gdax = require('gdax'); 7 | const fs = require('fs'); 8 | const _ = require('lodash'); 9 | const program = require('commander'); 10 | 11 | clear(); 12 | 13 | // title 14 | 15 | console.log( 16 | chalk.white( 17 | figlet.textSync( 18 | '\nCrypto-bot\n', {horizontalLayout: 'default'} 19 | ) 20 | ) 21 | ); 22 | 23 | // commander CLI 24 | 25 | program 26 | .version('0.0.1') 27 | .description('Description: Simple CLI for programmatic trading of cryptocurrencies on GDAX') 28 | .option('-i, --id [number]', 'Get Account ID') 29 | .option('-l, --logs', 'Get account raw logs [history/ledger]') 30 | .option('-b, --buy [price] [units]', 'BUY: Buy crypto [price] [units]') 31 | .option('-s, --sell [price] [units]', 'SELL: Sell crypto [price] [units]') 32 | .option('-d, --destroy', 'DESTROY: Cancel all orders') 33 | program.parse(process.argv); 34 | 35 | // create api [private] 36 | // config link: https://www.gdax.com/settings/api 37 | // FILL IN 38 | 39 | let key = ''; 40 | let b64secret = ''; 41 | let passphrase = ''; 42 | let apiURI = 'https://api.gdax.com'; 43 | let sandboxURI = 'https://api-public.sandbox.gdax.com'; 44 | 45 | // account IDs 46 | // FILL IN 47 | 48 | const eth_id = ''; // ethereum wallet address 49 | const usd_id = ''; // us dollar '' 50 | const btc_id = ''; // bitcoin '' 51 | 52 | // define callback specific to command 53 | 54 | let callback = function(err, response, data) { 55 | if (program.logs) { 56 | console.log(data); 57 | } else if (program.sell) { 58 | console.log(data); 59 | } else if (program.buy) { 60 | console.log(data); 61 | } else if (program.destroy) { 62 | console.log(data); 63 | } else if (program.id === 3) { 64 | let accountID = data[3]['id']; 65 | console.log(`ETH ID: ${accountID}`); 66 | } else if (program.id === 2) { 67 | let accountID = data[2]['id']; 68 | console.log(`USD ID: ${accountID}`); 69 | } else if (program.id === 1) { 70 | let accountID = data[1]['id']; 71 | console.log(`BTC ID: ${accountID}`); 72 | } else if (err) { // need fix 73 | console.error(err); 74 | } else { 75 | console.log(data); 76 | } 77 | } 78 | 79 | 80 | // private api 81 | 82 | const authedClient = new Gdax.AuthenticatedClient(key, b64secret, passphrase, apiURI); 83 | 84 | // logic 85 | // need additional logic to quickly switch between accounts 86 | 87 | if (program.logs) { 88 | authedClient.getAccountHistory(eth_id, callback); 89 | } else if (program.buy) { 90 | let buyParams = { 91 | 'price': process.argv[3], 92 | 'size': process.argv[4], 93 | 'product_id': 'ETH-USD' 94 | }; 95 | authedClient.buy(buyParams, callback); 96 | } else if (program.sell) { 97 | let sellParams = { 98 | 'price': process.argv[3], 99 | 'size': process.argv[4], 100 | 'product_id': 'ETH-USD' 101 | }; 102 | authedClient.sell(sellParams, callback); 103 | } else if (program.destroy) { 104 | authedClient.cancelAllOrders({product_id: 'ETH-USD'}, callback); 105 | } else if (program.id) { 106 | authedClient.getAccounts(callback); 107 | } else { 108 | console.log('Awaiting instructions..'); 109 | } 110 | 111 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "crypto_bot", 3 | "version": "1.0.0", 4 | "description": "CLI for programmatic trading of cryptocurrencies on GDAX", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "cryptocurrency", 11 | "gdax" 12 | ], 13 | "repository": "crypto_bot", 14 | "author": "waymobetta", 15 | "license": "MIT", 16 | "dependencies": { 17 | "chalk": "^1.1.3", 18 | "clear": "0.0.1", 19 | "commander": "^2.9.0", 20 | "figlet": "^1.2.0", 21 | "fs": "0.0.1-security", 22 | "gdax": "^0.3.1", 23 | "lodash": "^4.17.4", 24 | "request": "^2.81.0" 25 | } 26 | } 27 | --------------------------------------------------------------------------------