Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ex-master/core

Package Overview
Dependencies
Maintainers
2
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ex-master/core - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

26

bld/library/spot-client.d.ts

@@ -6,3 +6,3 @@ /// <reference types="node" />

import { Dashboard } from './dashboard';
import { AccountBalance, Market, MarketPrecision, Order, OrderType } from './types';
import { Balance, DepthData, KLineEntry, Market, MarketPrecision, MarketQuotation, Order, OrderPaidFee, OrderType } from './types';
import { PrecisionAlignment } from './util';

@@ -36,2 +36,16 @@ export interface SpotMarketData {

}
export interface SpotDealOrder {
id: string;
market: Market;
orderId: string;
type: OrderType;
price: Decimal;
size: Decimal;
value: Decimal;
filledValue: Decimal;
filledSize: Decimal;
aggressor: boolean;
paidFee: OrderPaidFee | undefined;
timestamp: number;
}
export declare type SpotBalanceChangeType = 'order-place' | 'order-match' | 'order-cancel' | 'order-refund' | 'order-fee-deduct' | 'transfer' | 'other';

@@ -57,4 +71,8 @@ export interface SpotBalanceUpdate {

get destroyed(): boolean;
get balances(): Balance[];
constructor({ dashboard }?: SpotClientOptions);
abstract getMarkets(): Promise<SpotMarketData[]>;
abstract getMarketQuotations(): Promise<MarketQuotation[]>;
abstract getDepth(market: Market, size?: number): Promise<DepthData>;
abstract getKLine(market: Market, startTime: number, endTime?: number, interval?: number): Promise<KLineEntry[]>;
abstract order(market: Market, type: OrderType, price: Decimal, size: Decimal, options?: SpotOrderOptions): Promise<SpotOrder | undefined>;

@@ -64,8 +82,8 @@ abstract getOrder(order: SpotOrderQuery): Promise<SpotOrder>;

abstract getOpenOrders(): Promise<SpotOrder[]>;
abstract getDealOrders(market: Market | undefined, startTime: number, endTime?: number, from?: string): Promise<SpotDealOrder[]>;
abstract cancelOrder(order: SpotOrderQuery): Promise<void>;
abstract cancelOrders(orders: SpotOrderQuery[]): Promise<void>;
abstract cancelOpenOrders(): Promise<void>;
initBalance(balances: [string, AccountBalance][]): void;
getBalances(): [string, AccountBalance][];
getBalance(currency: string): AccountBalance;
abstract getBalances(): Promise<Balance[]>;
getBalance(currency: string): Balance;
getMinOrderSize(market: Market): Decimal;

@@ -72,0 +90,0 @@ getMaxOrderSize(market: Market): Decimal;

13

bld/library/spot-client.js

@@ -22,8 +22,5 @@ "use strict";

}
initBalance(balances) {
this.balanceMap = new Map(balances);
get balances() {
return Array.from(this.balanceMap.values());
}
getBalances() {
return Array.from(this.balanceMap.entries());
}
getBalance(currency) {

@@ -33,2 +30,3 @@ let balance = this.balanceMap.get(currency);

balance = {
currency,
available: new decimal_js_1.default(0),

@@ -92,2 +90,7 @@ frozen: new decimal_js_1.default(0),

return tslib_1.__awaiter(this, void 0, void 0, function* () {
let balances = yield this.getBalances();
this.balanceMap.clear();
for (let balance of balances) {
this.balanceMap.set(balance.currency, balance);
}
this.subscription.add(this.balanceUpdate$.subscribe(({ currency, available, frozen }) => {

@@ -94,0 +97,0 @@ let balance = this.getBalance(currency);

import { Decimal } from 'decimal.js';
export interface AccountBalance {
export interface Balance {
currency: string;
available: Decimal;

@@ -21,2 +22,7 @@ frozen: Decimal;

}
export interface MarketQuotation {
market: Market;
price: number;
timestamp: number;
}
export declare type DepthEntry = [

@@ -56,3 +62,3 @@ /** price */

export interface OrderPaidFee {
key: string;
currency: string;
size: Decimal;

@@ -59,0 +65,0 @@ }

{
"name": "@ex-master/core",
"version": "0.3.2",
"version": "0.3.3",
"main": "bld/library/index.js",

@@ -24,3 +24,4 @@ "types": "bld/library/index.d.ts",

"villa": "^0.3.1"
}
},
"gitHead": "7a7e8023a4aea3f9e6111abb19c7cfd3e38042b0"
}

@@ -8,6 +8,10 @@ import {EventEmitter} from 'events';

import {
AccountBalance,
Balance,
DepthData,
KLineEntry,
Market,
MarketPrecision,
MarketQuotation,
Order,
OrderPaidFee,
OrderType,

@@ -48,2 +52,17 @@ } from './types';

export interface SpotDealOrder {
id: string;
market: Market;
orderId: string;
type: OrderType;
price: Decimal;
size: Decimal;
value: Decimal;
filledValue: Decimal;
filledSize: Decimal;
aggressor: boolean;
paidFee: OrderPaidFee | undefined;
timestamp: number;
}
export type SpotBalanceChangeType =

@@ -79,3 +98,3 @@ | 'order-place'

private balanceMap!: Map<string, AccountBalance>;
private balanceMap!: Map<string, Balance>;
private symbolToMarketDataMap!: Map<string, SpotMarketData>;

@@ -87,2 +106,6 @@

get balances(): Balance[] {
return Array.from(this.balanceMap.values());
}
constructor({dashboard = defaultDashboard}: SpotClientOptions = {}) {

@@ -96,2 +119,10 @@ super();

abstract getMarkets(): Promise<SpotMarketData[]>;
abstract getMarketQuotations(): Promise<MarketQuotation[]>;
abstract getDepth(market: Market, size?: number): Promise<DepthData>;
abstract getKLine(
market: Market,
startTime: number,
endTime?: number,
interval?: number,
): Promise<KLineEntry[]>;

@@ -109,2 +140,8 @@ abstract order(

abstract getOpenOrders(): Promise<SpotOrder[]>;
abstract getDealOrders(
market: Market | undefined,
startTime: number,
endTime?: number,
from?: string,
): Promise<SpotDealOrder[]>;

@@ -115,11 +152,5 @@ abstract cancelOrder(order: SpotOrderQuery): Promise<void>;

initBalance(balances: [string, AccountBalance][]): void {
this.balanceMap = new Map(balances);
}
abstract getBalances(): Promise<Balance[]>;
getBalances(): [string, AccountBalance][] {
return Array.from(this.balanceMap.entries());
}
getBalance(currency: string): AccountBalance {
getBalance(currency: string): Balance {
let balance = this.balanceMap.get(currency);

@@ -129,2 +160,3 @@

balance = {
currency,
available: new Decimal(0),

@@ -217,2 +249,10 @@ frozen: new Decimal(0),

private async initialize(): Promise<void> {
let balances = await this.getBalances();
this.balanceMap.clear();
for (let balance of balances) {
this.balanceMap.set(balance.currency, balance);
}
this.subscription.add(

@@ -219,0 +259,0 @@ this.balanceUpdate$.subscribe(({currency, available, frozen}) => {

@@ -7,3 +7,4 @@ import {Decimal} from 'decimal.js';

export interface AccountBalance {
export interface Balance {
currency: string;
available: Decimal;

@@ -35,2 +36,8 @@ frozen: Decimal;

export interface MarketQuotation {
market: Market;
price: number;
timestamp: number;
}
export type DepthEntry = [

@@ -82,3 +89,3 @@ /** price */

export interface OrderPaidFee {
key: string;
currency: string;
size: Decimal;

@@ -85,0 +92,0 @@ }

Sorry, the diff of this file is not supported yet

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