New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ex-master/huobi

Package Overview
Dependencies
Maintainers
1
Versions
289
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ex-master/huobi - npm Package Compare versions

Comparing version 0.1.32 to 0.1.33

10

bld/client.d.ts

@@ -17,3 +17,2 @@ import { AccountBalance, ActiveOrder, Client, Dashboard, Decimal, Market, MarketData, Order, OrderType } from '@ex-master/core';

export interface HuobiClientOptions {
accountId: string;
tokens: APIToken[];

@@ -36,3 +35,3 @@ restApiBaseURL?: string;

private dashboard;
private accountId;
private accountIdMap;
private tokenRotateIndex;

@@ -42,7 +41,7 @@ private tokens;

private retryOnOrderFailure;
constructor({accountId, tokens, restApiBaseURL, retryOnOrderFailure}: HuobiClientOptions, dashboard: Dashboard);
printAccounts(): Promise<void>;
constructor({tokens, restApiBaseURL, retryOnOrderFailure}: HuobiClientOptions, dashboard: Dashboard);
getMarketDetail(market: Market): Promise<HuobiMarketDetail>;
getDepth(market: Market): Promise<DepthData>;
getAccountBalance(): Promise<Dict<AccountBalance>>;
initialize(): Promise<void>;
getAccountBalance(type?: string): Promise<Dict<AccountBalance>>;
getMarkets(): Promise<MarketData[]>;

@@ -56,2 +55,3 @@ order(market: Market, type: OrderType, price: Decimal, size: Decimal): Promise<string | undefined>;

private _getOrder(id);
private getAccountIdMap();
private tradeRequest(method, path, params, body?, noUnstableRetry?);

@@ -58,0 +58,0 @@ private tradeRequest(method, path, params, body, noUnstableRetry?);

@@ -35,7 +35,6 @@ "use strict";

class HuobiClient extends core_1.Client {
constructor({ accountId, tokens, restApiBaseURL = REST_API_BASE_URL, retryOnOrderFailure = false, }, dashboard) {
constructor({ tokens, restApiBaseURL = REST_API_BASE_URL, retryOnOrderFailure = false, }, dashboard) {
super(MAX_POWER_PER_TOKEN * tokens.length, MAX_POWER_PER_TOKEN);
this.dashboard = dashboard;
this.tokenRotateIndex = 0;
this.accountId = accountId;
if (!tokens.length) {

@@ -49,6 +48,2 @@ throw new Error('Expecting at least one pair of token');

}
async printAccounts() {
let data = await this.tradeRequest('GET', '/v1/account/accounts', {});
this.dashboard.info(JSON.stringify(data));
}
async getMarketDetail(market) {

@@ -84,4 +79,11 @@ let { ts: time, tick: { open, close, high, low, count, size, vol: volume }, } = await this.dataRequest('/market/detail', {

////////////
async getAccountBalance() {
let { list } = await this.tradeRequest('GET', `/v1/account/accounts/${this.accountId}/balance`, {});
async initialize() {
this.accountIdMap = await this.getAccountIdMap();
}
async getAccountBalance(type = 'spot') {
let accountId = this.accountIdMap.get(type);
if (!accountId) {
throw new Error(`Invalid account balance type "${type}"`);
}
let { list } = await this.tradeRequest('GET', `/v1/account/accounts/${accountId}/balance`, {});
let groupedDict = _.groupBy(list, 'currency');

@@ -125,3 +127,3 @@ return Object.keys(groupedDict).reduce((dict, key) => {

let id = await this.tradeRequest('POST', '/v1/order/orders/place', {}, {
'account-id': this.accountId,
'account-id': this.accountIdMap.get('spot'),
price: price.toString(),

@@ -207,2 +209,9 @@ amount: size.toString(),

}
async getAccountIdMap() {
let accounts = await this.tradeRequest('GET', '/v1/account/accounts', {});
return new Map(accounts.map((account) => [
account.type,
String(account.id),
]));
}
async tradeRequest(method, path, params, body, noUnstableRetry) {

@@ -209,0 +218,0 @@ let result;

{
"name": "@ex-master/huobi",
"version": "0.1.32",
"version": "0.1.33",
"main": "bld/index.js",

@@ -5,0 +5,0 @@ "types": "bld/index.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc