This repository has been archived by the owner on Feb 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New command "zenbot balance <selector>" (#243)
* Add files via upload * Delete exchanges.md * Create exchanges.md * Delete exchanges.md * Create developers.md * Update developers.md * Update developers.md * New command "zenbot balance <selector>" Introduces a new comand: "zenbot balance <selector>" Sample output: BTC-USD Asset: 9.87654321. Currency: 1.23 * New command "zenbot balance <selector>"
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var minimist = require('minimist') | ||
, n = require('numbro') | ||
, colors = require('colors') | ||
|
||
module.exports = function container (get, set, clear) { | ||
var c = get('conf') | ||
return function (program) { | ||
program | ||
.command('balance [selector]') | ||
.allowUnknownOption() | ||
.description('get asset and currency balance from the exchange') | ||
//.option('--all', 'output all balances') | ||
.option('--debug', 'output detailed debug info') | ||
.action(function (selector, cmd) { | ||
var s = {options: minimist(process.argv)} | ||
s.selector = get('lib.normalize-selector')(selector || c.selector) | ||
var exch = s.selector.split('.')[0] | ||
s.exchange = get('exchanges.' + exch) | ||
s.product_id = s.selector.split('.')[1] | ||
s.asset = s.product_id.split('-')[0] | ||
s.currency = s.product_id.split('-')[1] | ||
var so = s.options | ||
delete so._ | ||
Object.keys(c).forEach(function (k) { | ||
if (typeof cmd[k] !== 'undefined') { | ||
so[k] = cmd[k] | ||
} | ||
}) | ||
so.debug = cmd.debug | ||
function balance () { | ||
s.exchange.getBalance(s, function (err, balance) { | ||
if (err) return cb(err) | ||
var bal = s.product_id + ' Asset: ' + balance.asset + ' Currency: ' + balance.currency | ||
console.log(bal) | ||
process.exit() | ||
}) | ||
} | ||
balance() | ||
}) | ||
} | ||
} |