nefertiti-node
Version:
ES module to work with Nefertiti crypto trade bot.
38 lines (34 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = filterMarketsByCurrency;
var _getAvailableMarkets = _interopRequireDefault(require("./getAvailableMarkets.js"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @function filterMarketsByCurrency
* @description Filter all of the markets that match a string
* @param {string} exchangeCode - Can be exchange code (KUCN)or full name
* @param {string} filterCurrency - Case-sensitive market to search
* Can be used as a quote currency with a hyphen in the correct place ('-BTC')
* @returns an array of market objects that contain a string including @filterCurrency
* @example
* const gdaxEthMarkets = filtermarketsByCurrency('gdax', 'ETH-')
* console.log(gdaxEthMarkets)
*[
* { name: 'ETH-USDT' },
* { name: 'ETH-GBP' },
* { name: 'ETH-EUR' },
* { name: 'ETH-DAI' },
* { name: 'ETH-BTC' },
* { name: 'ETH-USDC' },
* { name: 'ETH-USD' }
*]
*
*/
function filterMarketsByCurrency(exchangeCode, filterCurrency) {
const array = (0, _getAvailableMarkets.default)(exchangeCode);
const results = array.filter(markets => Object.values(markets).toString().includes(filterCurrency.toUpperCase()) // eslint-disable-next-line function-paren-newline
);
return results;
}