npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bterjs

v0.1.5

Published

bter.com unofficial library for nodejs

Downloads

1

Readme

bterjs

bter.com 的非官方库

Install

npm install bterjs -save

Market

const Market=require('bterjs').Market;

Market包含的静态方法用于获取交易所行情

  • 返回所有系统支持的交易对:Market.getPairs()
  • 交易市场订单参数:Market.getMarketInfo()
  • 交易市场详细行情:Market.getMarketList()
  • 所有交易行情:Market.getTickers()
  • 所有市场深度:Market.getOrderBooks()
  • 根据交易对获取交易行情:Market.getPairTicker(pair)
  • 根据交易对获取市场深度:Market.getPairOrderBook(pair)
  • 根据交易对获取历史成交记录:Market.getPairHistory(pair)

Trade

const Trade=require('bterjs').Trade;
const trade = new Trade('YOUR_API_KEY', 'YOUR_API_SECRET');

Trade可以进行账号资金查询,下单交易,取消挂单。

  • 获取帐号资金余额:trade.getBalance()

  • 获取充值地址:trade.getDepositAddress(currency)

  • 获取充值提现历史:trade.getDepositsAndWithdrawalsHistory()

  • 下单交易买入:trade.orderBuy(currencyPair, rate, amount)

  • 下单交易卖出:trade.orderSell(currencyPair, rate, amount)

  • 取消下单:trade.cancelOrder(currencyPair, orderNumber)

  • 取消多个下单:trade.cancelOrders(ordersArray)

  • 取消所有下单:trade.cancelAllOrder(type, currencyPair)

  • 获取下单状态:trade.getOrderStatus(currencyPair, orderNumber)

  • 获取我的当前挂单列表:trade.getOrdersList()

  • 获取我的24小时内成交记录:trade.getTradeHistory(currencyPair, orderNumber = null)

  • 提现:trade.withdraw(currency, amount, address)

Example

获取账户余额并且计算出当前资金估值;

const Trade=require('bterjs').Trade;
const Market=require('bterjs').Market;

const trade = new Trade('YOUR_API_KEY', 'YOUR_API_SECRET');
let amount = 0;
console.time('request');
Market.getTickers().then(tickerList => {
    trade.getBalance().then(resp => {
        console.timeEnd('request');
        const available = resp.available;
        for (const key in available) {
            if (!available.hasOwnProperty(key)) {
                continue;
            }
            if (key === 'CNY') {
                amount += parseFloat(available[key]);
                continue;
            }
            const tickerKey = (`${key}_cny`).toLowerCase();
            if (!tickerList.hasOwnProperty(tickerKey)) {
                console.error(`Can not find pair ${tickerKey}`);
                continue;
            }
            amount += parseFloat(tickerList[tickerKey].last) * parseFloat(available[key]);
        }
        console.log(amount);
    }, err => {
        console.log(err);
    });
}, err => {
    console.log(err);
});