Skip to content

Commit

Permalink
Merge branch 'release/1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
benmarten committed Dec 25, 2017
2 parents 9f736a8 + 4eba386 commit 70050c0
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ CryptoETF has API integrations with the following exchanges:
- Bittrex. Join Here: https://www.bittrex.com
- Binance. Join Here: https://www.binance.com/?ref=12278261
- HitBTC. Join Here: https://hitbtc.com/?ref_id=5a3596f643b9e
- Bitfinex. Join Here: https://www.bitfinex.com

With these exchanges, you can easily build yourself your own CryptoETF.

Expand Down
201 changes: 188 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"dependencies": {
"babel-preset-es2015": "^6.24.1",
"binance": "^1.1.0",
"bitfinex": "^1.0.3",
"coinbase": "^2.0.6",
"node-bittrex-api": "^0.8.1",
"poloniex-api-node": "^1.6.5",
Expand Down
6 changes: 6 additions & 0 deletions settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
"apiKey": "",
"apiSecret": ""
}
],
"bitfinex": [
{
"apiKey": "",
"apiSecret": ""
}
]
},
"symbolMapping": {
Expand Down
39 changes: 39 additions & 0 deletions src/model/integrations/BitfinexWallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import PromiseUtils from '../../PromiseUtils'
import Coin from '../Coin'
// noinspection NpmUsedModulesInstalled
import Bitfinex from 'bitfinex'

const settings = require('../../../settings.json')

export default class BitfinexWallet {
static getBalance() {
return PromiseUtils.forEachPromise(settings.accounts.bitfinex, this._getBalanceForCredential)
}

/**
* Returns the balances for a Bitfinex account.
* @param credential The Bitfinex api credentials.
* @return {Promise} The account balances.
* @prop account The accounts for given credentials.
* @prop account.balance The balance of the account.
* @prop data.asset The currency.
* @prop data.free The amount.
*/
static _getBalanceForCredential(credential) {
return new Promise((resolve, reject) => {
const {apiKey, apiSecret} = credential
const bitfinex = new Bitfinex(apiKey, apiSecret)

bitfinex.wallet_balances((err, balances) => {
if (err) {
return reject(err)
}

const result = balances.map(({currency, amount}) => new Coin(currency.toUpperCase(), amount, 'Bitfinex'))

resolve(result)
})
}
)
}
}
9 changes: 9 additions & 0 deletions test/model/integrations/testBitfinexWallet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import BitfinexWallet from '../../../src/model/integrations/BitfinexWallet'
import assert from 'assert'

describe('Testing Bitfinex integration', () => {
it('Testing initial connection and balances', async () => {
let wallet = await BitfinexWallet.getBalance()
assert(wallet.length > 0)
})
})

0 comments on commit 70050c0

Please sign in to comment.