Socket
Socket
Sign inDemoInstall

bitmex-ws

Package Overview
Dependencies
11
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.12 to 1.1.0

lib/api/index.d.ts

2

index.d.ts

@@ -1,1 +0,1 @@

export * from './lib/bitmex-api';
export * from './lib/bitmex-ws';

@@ -6,2 +6,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./lib/bitmex-api"));
__export(require("./lib/bitmex-ws"));

@@ -1,2 +0,2 @@

export * from './fetch-rxjs';
export * from './websocket-rxjs';
export * from './util';

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./fetch-rxjs"));
__export(require("./websocket-rxjs"));
__export(require("./util"));
import { Observable } from 'rxjs';
import { ExchangeInfo, SupportFeatures, Ticker, Orderbook, Trade, CandleStick, ExchangeOptions } from './exchange-types';
import { Orderbook, Trade, Order, ExchangeOptions } from './types';
export declare abstract class ExchangeApi {
protected options: ExchangeOptions;
abstract readonly exchangeInfo: ExchangeInfo;
abstract readonly markets: string[];
abstract readonly representativeMarkets: string[];
abstract readonly supportFeatures: SupportFeatures;
constructor(options?: ExchangeOptions);
abstract fetchTicker$(pair: string): Observable<Ticker>;
abstract ticker$(pair: string): Observable<Ticker>;
abstract stopTicker(pair: string): void;
abstract fetchOrderbook$(pair: string): Observable<Orderbook>;
abstract orderbook$(pair: string): Observable<Orderbook>;
abstract stopOrderbook(pair: string): void;
abstract fetchTrades$(pair: string): Observable<Trade[]>;
abstract trade$(pair: string): Observable<Trade>;
abstract stopTrade(pair: string): void;
abstract fetchCandleStickRange$(pair: string, minutesFoot: number, start: number, end: number): Observable<CandleStick[]>;
lastCandle$(pair: string, initialLastCandle: CandleStick, minutesFoot: number): Observable<CandleStick>;
stopLastCandle(pair: string): void;
/**
* Private api
*/
abstract order$(pair: string): Observable<Order | undefined>;
abstract stopOrder(pair: string): void;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const operators_1 = require("rxjs/operators");
const helper_functions_1 = require("./helper.functions");
const exchange_default_options_1 = require("./exchange-default.options");
class ExchangeApi {
constructor(options) {
this.options = Object.assign({}, exchange_default_options_1.defaultOptions, options);
this.options = Object.assign({
apiKey: '',
apiSecret: '',
testnet: false,
}, options);
}
// realtime last candlestick using initial last candle and realtime trade (used for tradingview datafeed)
lastCandle$(pair, initialLastCandle, minutesFoot) {
return this.trade$(pair).pipe(operators_1.scan((candle, trade) => helper_functions_1.updateLastCandleWithNewTrade(candle, trade, minutesFoot), initialLastCandle));
}
stopLastCandle(pair) {
// stop listening to realtime trades
this.stopTrade(pair);
}
}
exports.ExchangeApi = ExchangeApi;

@@ -0,1 +1,2 @@

import { ExchangeOptions } from './types';
/**

@@ -8,5 +9,5 @@ * Abstract class for websocket api

export declare abstract class ExchangeWebsocket<T = any, U = any> {
private readonly endPoint;
private readonly options;
private ws;
constructor(endPoint: string);
constructor(options: ExchangeOptions);
abstract handleMessage(response: U): void;

@@ -17,2 +18,3 @@ abstract onDestroy(): void;

private initWebsocket;
private makeEndpoint;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const websocket_rxjs_1 = require("./common/websocket-rxjs");
const common_1 = require("./common");
const Endpoints = {
production: 'wss://www.bitmex.com/realtime',
testnet: 'wss://testnet.bitmex.com/realtime',
};
/**

@@ -11,4 +16,4 @@ * Abstract class for websocket api

class ExchangeWebsocket {
constructor(endPoint) {
this.endPoint = endPoint;
constructor(options) {
this.options = options;
this.ws = null;

@@ -35,3 +40,4 @@ }

}
this.ws = new websocket_rxjs_1.WebSocketRxJs(this.endPoint);
const endPoint = this.makeEndpoint();
this.ws = new websocket_rxjs_1.WebSocketRxJs(endPoint);
this.ws.message$.subscribe((response) => {

@@ -41,3 +47,10 @@ this.handleMessage(response);

}
makeEndpoint() {
let endpoint = this.options.testnet ? Endpoints.testnet : Endpoints.production;
if (this.options.apiKey && this.options.apiSecret) {
endpoint += '?' + common_1.getWSAuthQuery(this.options.apiKey, this.options.apiSecret);
}
return endpoint;
}
}
exports.ExchangeWebsocket = ExchangeWebsocket;
import { Observable } from 'rxjs';
import { ExchangeWebsocket } from '../exchange-websocket.abstract';
import { WebsocketRequest, WebsocketResponse, WebsocketData } from './types';
import { ExchangeOptions } from '../types';
export declare class BitmexWebsocket extends ExchangeWebsocket<WebsocketRequest, WebsocketResponse | WebsocketData> {
private readonly keyStreamMap;
constructor(endPoint?: string);
constructor(options: ExchangeOptions);
/**

@@ -8,0 +9,0 @@ * handle message

@@ -5,6 +5,5 @@ "use strict";

const exchange_websocket_abstract_1 = require("../exchange-websocket.abstract");
const bitmex_common_1 = require("../bitmex-common");
class BitmexWebsocket extends exchange_websocket_abstract_1.ExchangeWebsocket {
constructor(endPoint) {
super(endPoint || bitmex_common_1.wsEndpoint);
constructor(options) {
super(options);
this.keyStreamMap = new Map();

@@ -11,0 +10,0 @@ }

{
"name": "bitmex-ws",
"version": "1.0.12",
"version": "1.1.0",
"description": "An unofficial node.js wrapper for the BitMEX Bitcoin derivatives exchange websocket API",

@@ -26,4 +26,5 @@ "repository": {

"tsc": "npm run rm && tsc -p tsconfig.development.json",
"cp": "cp -r ./src/lib/common/lib/ ./dist/src/lib/common/lib/",
"tslint": "tslint --project ./tslint.json",
"test": "cross-env NODE_ENV=test mocha dist/**/*.test.js --timeout 5000 --require intelli-espower-loader"
"test": "cross-env NODE_ENV=test mocha dist/**/*.test.js --timeout 500000 --require intelli-espower-loader"
},

@@ -30,0 +31,0 @@ "dependencies": {

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc