@stacksavings/poloniex-client
v1.1.31
Published
Poloniex Client
Downloads
15
Keywords
Readme
Stacksavings - Poloniex Client
Hemos creado un paquete "@stacksavings/poloniex-client" para poder usar los metodos de Public y Trading API de Poloniex.
Table of contents
Getting Started
Installing
Para poder instalar el cliente solo basta con ejecutar el comando:
npm i @stacksavings/poloniex-client
Usage
Para empezar a usarlo solo debe de incluirlo en tu código asi:
const client = require('@stacksavings/poloniex-client')
Public API Methods
- currenciesAvailable:
const logger = require('@stacksavings/utils').log()
const client = require(@stacksavings/poloniex-client)
const currencies = client.currenciesAvailable()
currencies.then(data => {
logger.info(data);
}, err => {
logger.error(err);
})
Output:
{
"1CR":{
"maxDailyWithdrawal":10000,
"txFee":0.01,
"minConf":3,
"disabled":0
},
"ABY":{
"maxDailyWithdrawal":10000000,
"txFee":0.01,
"minConf":8,
"disabled":0
},
...
}
- returnChartData:
const logger = require('@stacksavings/utils').log()
const client = require('./poloniex-client')
const TimeStamp = require('@stacksavings/utils')
let parameters = {
currencyPair: "BTC_LTC",
period: 14400,
start: TimeStamp.toTimeStampUnix(20171218),
end: TimeStamp.toTimeStampUnix(20171219)
}
const ChartData = client.returnChartData(parameters)
ChartData.then(data => {
logger.info(data);
}, err => {
logger.error(err);
})
Output:
[
{
"date":1405699200,
"high":0.0045388,
"low":0.00403001,
"open":0.00404545,
"close":0.00427592,
"volume":44.11655644,
"quoteVolume":10259.29079097,
"weightedAverage":0.00430015
},
...
]
Trading API Methods
Estos métodos requieren el "Key" y "Secret" asociado a la organización Stacksavings.
- buy:
Example to call it:
const logger = require('@stacksavings/utils').log()
const client = require(@stacksavings/poloniex-client)
let parameters = {
currencyPair: 'BTC_ETH',
amount: 0.008,
rate: 0.058,
}
let credentials = {
key: 'KEY STRING',
secret: 'SECRET STRING'
}
const buyer = client.buy(parameters,credentials)
buyer.then(data => {
logger.info(data);
}, err => {
logger.error(err);
})
Output:
{
"orderNumber":31226040,
"resultingTrades":[
{
"amount":"338.8732",
"date":"2014-10-18 23:03:21",
"rate":"0.00000173",
"total":"0.00058625",
"tradeID":"16164",
"type":"buy"
}
]
}
- sell:
Example to call it:
const logger = require('@stacksavings/utils').log()
const client = require(@stacksavings/poloniex-client)
let parameters = {
currencyPair: 'BTC_ETH',
amount: 0.008,
rate: 0.058,
}
let credentials = {
key: 'KEY STRING',
secret: 'SECRET STRING'
}
const seller = client.sell(parameters,credentials)
seller.then(data => {
logger.info(data);
}, err => {
logger.error(err);
})
Output:
{
"orderNumber":31226040,
"resultingTrades":[
{
"amount":"338.8732",
"date":"2014-10-18 23:03:21",
"rate":"0.00000173",
"total":"0.00058625",
"tradeID":"16164",
"type":"sell"
}
]
}
- returnBalances:
Example to call it:
const logger = require('@stacksavings/utils').log()
const client = require(@stacksavings/poloniex-client)
let credentials = {
key: 'KEY STRING',
secret: 'SECRET STRING'
}
const balances = client.returnBalances(credentials)
balances.then(data => {
logger.info(data);
}, err => {
logger.error(err);
})
Output:
{
"BTC":"0.59098578",
"LTC":"3.31117268",
...
}
- returnCompleteBalances:
Example to call it:
const logger = require('@stacksavings/utils').log()
const client = require(@stacksavings/poloniex-client)
let credentials = {
key: 'KEY STRING',
secret: 'SECRET STRING'
}
const balances = client.returnCompleteBalances(credentials)
balances.then(data => {
logger.info(data);
}, err => {
logger.error(err);
})
Output:
{
"LTC":
{
"available":"5.015",
"onOrders":"1.0025",
"btcValue":"0.078"
},
"NXT:{...}
...
}
Creators
Stacksavings
- https://site.stacksavings.com
David Molina
- https://dmolina101.github.io