dat-currency-service
v0.0.1
Published
Utility functions for working with digital asset trading pairs.
Downloads
2
Maintainers
Readme
dat-currency-service
Utility functions for working with digital asset trading pairs.
Installation
npm install dat-currency-service
Usage
Import
import { CurrencyService } from 'dat-currency-service';
Determine if a trading pair is denominated in USD
if (CurrencyService.IsDenominatedInUSD('BTC-USD'))
{
// Do something.
}
Change the default separator
if (CurrencyService.IsDenominatedInUSD('BTC|USD', '|'))
{
// Do something.
}
Get the decimal place precision based on the denomination
console.info(CurrencyService.GetDecimalPlaces('BTC-USD')); // 2
console.info(CurrencyService.GetDecimalPlaces('ETH-BTC')); // 8
Set the decimal place precision based on the denomination
let exitFillSize: num = num(0);
let stopLimitFillSize: string = '0.01265433';
let stopLossFillSize: string = '0.01234567';
exitFillSize = exitFillSize.add(stopLimitFillSize).add(stopLossFillSize);
console.info(CurrencyService.SetPrecision(exitFillSize, 'ETH-BTC')); // 0.025
Test
npm test
Build
npm run build