@volare.finance/nestjs.plugins 1.0.3 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/binance/binance.service.d.ts +27 -4
- package/dist/binance/binance.service.js +9 -27
- package/dist/binance/binance.service.js.map +1 -1
- package/dist/coingecko/coingecko.config.d.ts +2 -0
- package/dist/coingecko/coingecko.service.d.ts +1 -0
- package/dist/coingecko/coingecko.service.js +11 -8
- package/dist/coingecko/coingecko.service.js.map +1 -1
- package/dist/lbank/lbank.service.d.ts +4 -3
- package/dist/lbank/lbank.service.js +22 -25
- package/dist/lbank/lbank.service.js.map +1 -1
- package/dist/mexc/mexc.service.d.ts +23 -10
- package/dist/mexc/mexc.service.js +9 -44
- package/dist/mexc/mexc.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
import { BinanceConfig } from './binance.config';
|
|
7
7
|
export declare class BinanceService {
|
|
8
8
|
private readonly constant;
|
|
9
|
+
private readonly instance;
|
|
9
10
|
constructor(constant: BinanceConfig);
|
|
10
11
|
/**
|
|
11
12
|
* Market Data - Current Average Price
|
|
12
13
|
* @param symbol e.g. BTCUSDT
|
|
13
14
|
* @see https://binance-docs.github.io/apidocs/spot/en/#current-average-price
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
avgPrice(symbol: string): Promise<{
|
|
16
17
|
mins: number;
|
|
17
18
|
price: string;
|
|
18
19
|
}>;
|
|
@@ -21,7 +22,29 @@ export declare class BinanceService {
|
|
|
21
22
|
* @param symbol e.g. BTCUSDT
|
|
22
23
|
* @see https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
ticker(symbol: string): Promise<{
|
|
26
|
+
symbol: string;
|
|
27
|
+
priceChange: string;
|
|
28
|
+
priceChangePercent: string;
|
|
29
|
+
weightedAvgPrice: string;
|
|
30
|
+
prevClosePrice: string;
|
|
31
|
+
lastPrice: string;
|
|
32
|
+
lastQty: string;
|
|
33
|
+
bidPrice: string;
|
|
34
|
+
bidQty: string;
|
|
35
|
+
askPrice: string;
|
|
36
|
+
askQty: string;
|
|
37
|
+
openPrice: string;
|
|
38
|
+
highPrice: string;
|
|
39
|
+
lowPrice: string;
|
|
40
|
+
volume: string;
|
|
41
|
+
quoteVolume: string;
|
|
42
|
+
openTime: number;
|
|
43
|
+
closeTime: number;
|
|
44
|
+
firstId: number;
|
|
45
|
+
lastId: number;
|
|
46
|
+
count: number;
|
|
47
|
+
}>;
|
|
25
48
|
/**
|
|
26
49
|
* Market Data - Kline/Candlestick Data
|
|
27
50
|
* @param symbol e.g. BTCUSDT
|
|
@@ -31,14 +54,14 @@ export declare class BinanceService {
|
|
|
31
54
|
* @param limit e.g. 500
|
|
32
55
|
* @see https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
|
|
33
56
|
*/
|
|
34
|
-
|
|
57
|
+
klines(symbol: string, interval: '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '6h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M', startTime?: string | number, endTime?: string | number, limit?: number): Promise<[number, string, string, string, string, string, number, string, number, string, string, string][]>;
|
|
35
58
|
/**
|
|
36
59
|
* Market Data - Order Book
|
|
37
60
|
* @param symbol e.g. BTCUSDT
|
|
38
61
|
* @param limit e.g. 500
|
|
39
62
|
* @see https://binance-docs.github.io/apidocs/spot/en/#order-book
|
|
40
63
|
*/
|
|
41
|
-
|
|
64
|
+
depth(symbol: string, limit?: number): Promise<{
|
|
42
65
|
lastUpdateId: number;
|
|
43
66
|
bids: [string, string][];
|
|
44
67
|
asks: [string, string][];
|
|
@@ -12,24 +12,20 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
|
12
12
|
let BinanceService = class BinanceService {
|
|
13
13
|
constructor(constant) {
|
|
14
14
|
this.constant = constant;
|
|
15
|
-
|
|
15
|
+
this.instance = axios_1.default.create({ baseURL: this.constant.binance.url });
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Market Data - Current Average Price
|
|
19
19
|
* @param symbol e.g. BTCUSDT
|
|
20
20
|
* @see https://binance-docs.github.io/apidocs/spot/en/#current-average-price
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
avgPrice(symbol) {
|
|
23
23
|
var _a;
|
|
24
24
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
if (!((_a = this.constant.binance) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
26
26
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
27
27
|
}
|
|
28
|
-
return (yield (
|
|
29
|
-
method: 'GET',
|
|
30
|
-
url: this.constant.binance.url + '/api/v3/avgPrice',
|
|
31
|
-
params: { symbol },
|
|
32
|
-
})).data;
|
|
28
|
+
return (yield this.instance.get('/api/v3/avgPrice', { params: { symbol } })).data;
|
|
33
29
|
});
|
|
34
30
|
}
|
|
35
31
|
/**
|
|
@@ -37,19 +33,13 @@ let BinanceService = class BinanceService {
|
|
|
37
33
|
* @param symbol e.g. BTCUSDT
|
|
38
34
|
* @see https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics
|
|
39
35
|
*/
|
|
40
|
-
|
|
36
|
+
ticker(symbol) {
|
|
41
37
|
var _a;
|
|
42
38
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
39
|
if (!((_a = this.constant.binance) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
44
40
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
45
41
|
}
|
|
46
|
-
return (yield (
|
|
47
|
-
method: 'GET',
|
|
48
|
-
url: this.constant.binance.url + '/api/v3/ticker/24hr',
|
|
49
|
-
params: {
|
|
50
|
-
symbol,
|
|
51
|
-
},
|
|
52
|
-
})).data;
|
|
42
|
+
return (yield this.instance.get('/api/v3/ticker/24hr', { params: { symbol } })).data;
|
|
53
43
|
});
|
|
54
44
|
}
|
|
55
45
|
/**
|
|
@@ -61,17 +51,13 @@ let BinanceService = class BinanceService {
|
|
|
61
51
|
* @param limit e.g. 500
|
|
62
52
|
* @see https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
|
|
63
53
|
*/
|
|
64
|
-
|
|
54
|
+
klines(symbol, interval, startTime, endTime, limit) {
|
|
65
55
|
var _a;
|
|
66
56
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
67
57
|
if (!((_a = this.constant.binance) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
68
58
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
69
59
|
}
|
|
70
|
-
return (yield (
|
|
71
|
-
method: 'GET',
|
|
72
|
-
url: this.constant.binance.url + '/api/v3/klines',
|
|
73
|
-
params: { symbol, interval, startTime, endTime, limit },
|
|
74
|
-
})).data;
|
|
60
|
+
return (yield this.instance.get('/api/v3/klines', { params: { symbol, interval, startTime, endTime, limit } })).data;
|
|
75
61
|
});
|
|
76
62
|
}
|
|
77
63
|
/**
|
|
@@ -80,17 +66,13 @@ let BinanceService = class BinanceService {
|
|
|
80
66
|
* @param limit e.g. 500
|
|
81
67
|
* @see https://binance-docs.github.io/apidocs/spot/en/#order-book
|
|
82
68
|
*/
|
|
83
|
-
|
|
69
|
+
depth(symbol, limit) {
|
|
84
70
|
var _a;
|
|
85
71
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
86
72
|
if (!((_a = this.constant.binance) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
87
73
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
88
74
|
}
|
|
89
|
-
return (yield (
|
|
90
|
-
method: 'GET',
|
|
91
|
-
url: this.constant.binance.url + '/api/v3/depth',
|
|
92
|
-
params: { symbol, limit },
|
|
93
|
-
})).data;
|
|
75
|
+
return (yield this.instance.get('/api/v3/depth', { params: { symbol, limit } })).data;
|
|
94
76
|
});
|
|
95
77
|
}
|
|
96
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binance.service.js","sourceRoot":"","sources":["../../src/binance/binance.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"binance.service.js","sourceRoot":"","sources":["../../src/binance/binance.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,0DAA6C;AAItC,IAAM,cAAc,GAApB,MAAM,cAAc;IAGzB,YAAwD,QAAuB;QAAvB,aAAQ,GAAR,QAAQ,CAAe;QAC7E,IAAI,CAAC,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACvE,CAAC;IAED;;;;OAIG;IACG,QAAQ,CAAC,MAAc;;;YAC3B,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,0CAAE,OAAO,CAAA,EAAE;gBACnC,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aAClF;YACD,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;;KACnF;IAED;;;;OAIG;IACG,MAAM,CAAC,MAAc;;;YAuBzB,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,0CAAE,OAAO,CAAA,EAAE;gBACnC,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aAClF;YACD,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,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private readonly instance;
|
|
9
10
|
constructor(constant: CoinGeckoConfig);
|
|
10
11
|
/**
|
|
11
12
|
* supported coins price, market cap, volume, and market related data
|
|
@@ -12,7 +12,11 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
|
12
12
|
let CoinGeckoService = class CoinGeckoService {
|
|
13
13
|
constructor(constant) {
|
|
14
14
|
this.constant = constant;
|
|
15
|
-
|
|
15
|
+
const config = { baseURL: this.constant.coingecko.url };
|
|
16
|
+
if (this.constant.coingecko.apiKey) {
|
|
17
|
+
config.params = { [this.constant.coingecko.isPro ? 'x_cg_pro_api_key' : 'x_cg_api_key']: this.constant.coingecko.apiKey };
|
|
18
|
+
}
|
|
19
|
+
this.instance = axios_1.default.create(config);
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* supported coins price, market cap, volume, and market related data
|
|
@@ -26,13 +30,12 @@ let CoinGeckoService = class CoinGeckoService {
|
|
|
26
30
|
if (!((_a = this.constant.coingecko) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
27
31
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
28
32
|
}
|
|
29
|
-
const response = yield (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return response.data[0];
|
|
33
|
+
const response = yield this.instance.get('/api/v3/coins/markets', { params: { ids, vs_currency } });
|
|
34
|
+
if (response.status === common_1.HttpStatus.OK) {
|
|
35
|
+
if (response.data.length) {
|
|
36
|
+
return response.data[0];
|
|
37
|
+
}
|
|
38
|
+
throw new common_1.HttpException('No Data', common_1.HttpStatus.NOT_FOUND);
|
|
36
39
|
}
|
|
37
40
|
throw new common_1.HttpException(response.statusText, response.status);
|
|
38
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coingecko.service.js","sourceRoot":"","sources":["../../src/coingecko/coingecko.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AA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AAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACzB;gBACD,MAAM,IAAI,sBAAa,CAAC,SAAS,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC;aAC1D;YACD,MAAM,IAAI,sBAAa,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;;KAC/D;CACF,CAAA;AA5DY,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAIE,mBAAA,IAAA,eAAM,EAAC,mBAAmB,CAAC,CAAA;GAH7B,gBAAgB,CA4D5B;AA5DY,4CAAgB"}
|
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
import { LBankConfig } from './lbank.config';
|
|
7
7
|
export declare class LBankService {
|
|
8
8
|
private readonly constant;
|
|
9
|
+
private readonly instance;
|
|
9
10
|
constructor(constant: LBankConfig);
|
|
10
11
|
/**
|
|
11
12
|
* Common - Query current Market Data (new)
|
|
12
13
|
* @param symbol e.g. btc_usdt
|
|
13
14
|
* @see https://www.lbank.com/en-US/docs/index.html#query-current-market-data-new
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
ticker(symbol: string): Promise<{
|
|
16
17
|
symbol: string;
|
|
17
18
|
ticker: {
|
|
18
19
|
high: string;
|
|
@@ -32,14 +33,14 @@ export declare class LBankService {
|
|
|
32
33
|
* @param size e.g. 500
|
|
33
34
|
* @see https://www.lbank.com/en-US/docs/index.html#query-k-bar-data
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
+
klines(symbol: string, type: 'minute1' | 'minute5' | 'minut15' | 'minute30' | 'hour1' | 'hour4' | 'hour8' | 'hour12' | 'day1' | 'week1', time: string | number, size: number): Promise<[number, number, number, number, number, number][]>;
|
|
36
37
|
/**
|
|
37
38
|
* Common - Query Market Depth
|
|
38
39
|
* @param symbol e.g. btc_usdt
|
|
39
40
|
* @param size e.g. 500
|
|
40
41
|
* @see https://www.lbank.com/en-US/docs/index.html#query-market-depth
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
depth(symbol: string, size: number): Promise<{
|
|
43
44
|
asks: [string, string][];
|
|
44
45
|
bids: [string, string][];
|
|
45
46
|
timestamp: number;
|
|
@@ -12,26 +12,25 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
|
12
12
|
let LBankService = class LBankService {
|
|
13
13
|
constructor(constant) {
|
|
14
14
|
this.constant = constant;
|
|
15
|
-
|
|
15
|
+
this.instance = axios_1.default.create({ baseURL: this.constant.lbank.url });
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Common - Query current Market Data (new)
|
|
19
19
|
* @param symbol e.g. btc_usdt
|
|
20
20
|
* @see https://www.lbank.com/en-US/docs/index.html#query-current-market-data-new
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
ticker(symbol) {
|
|
23
23
|
var _a, _b, _c, _d;
|
|
24
24
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
if (!((_a = this.constant.lbank) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
26
26
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
27
27
|
}
|
|
28
|
-
const response = yield (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return response.data.data[0];
|
|
28
|
+
const response = yield this.instance.get('/v2/ticker/24hr.do', { params: { symbol } });
|
|
29
|
+
if (response.status === common_1.HttpStatus.OK) {
|
|
30
|
+
if (((_b = response.data) === null || _b === void 0 ? void 0 : _b.result) === 'true' && ((_d = (_c = response.data) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.length) > 0) {
|
|
31
|
+
return response.data.data[0];
|
|
32
|
+
}
|
|
33
|
+
throw new common_1.HttpException(response.data.result, common_1.HttpStatus.BAD_REQUEST);
|
|
35
34
|
}
|
|
36
35
|
throw new common_1.HttpException(response.statusText, response.status);
|
|
37
36
|
});
|
|
@@ -44,19 +43,18 @@ let LBankService = class LBankService {
|
|
|
44
43
|
* @param size e.g. 500
|
|
45
44
|
* @see https://www.lbank.com/en-US/docs/index.html#query-k-bar-data
|
|
46
45
|
*/
|
|
47
|
-
|
|
46
|
+
klines(symbol, type, time, size) {
|
|
48
47
|
var _a, _b;
|
|
49
48
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
50
49
|
if (!((_a = this.constant.lbank) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
51
50
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
52
51
|
}
|
|
53
|
-
const response = yield (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return response.data.data;
|
|
52
|
+
const response = yield this.instance.get('/v2/kline.do', { params: { symbol, type, time, size } });
|
|
53
|
+
if (response.status === common_1.HttpStatus.OK) {
|
|
54
|
+
if (((_b = response.data) === null || _b === void 0 ? void 0 : _b.result) === 'true') {
|
|
55
|
+
return response.data.data;
|
|
56
|
+
}
|
|
57
|
+
throw new common_1.HttpException(response.data.result, common_1.HttpStatus.BAD_REQUEST);
|
|
60
58
|
}
|
|
61
59
|
throw new common_1.HttpException(response.statusText, response.status);
|
|
62
60
|
});
|
|
@@ -67,19 +65,18 @@ let LBankService = class LBankService {
|
|
|
67
65
|
* @param size e.g. 500
|
|
68
66
|
* @see https://www.lbank.com/en-US/docs/index.html#query-market-depth
|
|
69
67
|
*/
|
|
70
|
-
|
|
68
|
+
depth(symbol, size) {
|
|
71
69
|
var _a, _b;
|
|
72
70
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
73
71
|
if (!((_a = this.constant.lbank) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
74
72
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
75
73
|
}
|
|
76
|
-
const response = yield (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return response.data.data;
|
|
74
|
+
const response = yield this.instance.get('/v2/depth.do', { params: { symbol, size } });
|
|
75
|
+
if (response.status === common_1.HttpStatus.OK) {
|
|
76
|
+
if (((_b = response.data) === null || _b === void 0 ? void 0 : _b.result) === 'true') {
|
|
77
|
+
return response.data.data;
|
|
78
|
+
}
|
|
79
|
+
throw new common_1.HttpException(response.data.result, common_1.HttpStatus.BAD_REQUEST);
|
|
83
80
|
}
|
|
84
81
|
throw new common_1.HttpException(response.statusText, response.status);
|
|
85
82
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lbank.service.js","sourceRoot":"","sources":["../../src/lbank/lbank.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"lbank.service.js","sourceRoot":"","sources":["../../src/lbank/lbank.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,0DAA6C;AAItC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEvB,YAAsD,QAAqB;QAArB,aAAQ,GAAR,QAAQ,CAAa;QACzE,IAAI,CAAC,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACG,MAAM,CAAC,MAAc;;;YAKzB,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,0CAAE,OAAO,CAAA,EAAE;gBACjC,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aAClF;YACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,oBAAoB,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;YACvF,IAAI,QAA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AAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;;KAC/D;IAED;;;;;OAKG;IACG,KAAK,CAAC,MAAc,EAAE,IAAY;;;YACtC,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,0CAAE,OAAO,CAAA,EAAE;gBACjC,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aAClF;YACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YACvF,IAAI,QAAQ,CAAC,MAAM,KAAK,mBAAU,CAAC,EAAE,EAAE;gBACrC,IAAI,CAAA,MAAA,QAAQ,CAAC,IAAI,0CAAE,MAAM,MAAK,MAAM,EAAE;oBACpC,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;iBAC3B;gBACD,MAAM,IAAI,sBAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aACvE;YACD,MAAM,IAAI,sBAAa,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;;KAC/D;CACF,CAAA;AA3EY,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGE,mBAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;GAFzB,YAAY,CA2ExB;AA3EY,oCAAY"}
|
|
@@ -6,19 +6,14 @@
|
|
|
6
6
|
import { MexcConfig } from './mexc.config';
|
|
7
7
|
export declare class MexcService {
|
|
8
8
|
private readonly constant;
|
|
9
|
+
private readonly instance;
|
|
9
10
|
constructor(constant: MexcConfig);
|
|
10
|
-
/**
|
|
11
|
-
* Market Data - Ticker Information
|
|
12
|
-
* @param symbol e.g. BTC_USDC
|
|
13
|
-
* @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#ticker-information
|
|
14
|
-
*/
|
|
15
|
-
marketTicker(symbol: string): Promise<any>;
|
|
16
11
|
/**
|
|
17
12
|
* Market Data - Current Average Price
|
|
18
13
|
* @param symbol e.g. BTCUSDT
|
|
19
14
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#current-average-price
|
|
20
15
|
*/
|
|
21
|
-
|
|
16
|
+
avgPrice(symbol: string): Promise<{
|
|
22
17
|
mins: number;
|
|
23
18
|
price: string;
|
|
24
19
|
}>;
|
|
@@ -27,7 +22,25 @@ export declare class MexcService {
|
|
|
27
22
|
* @param symbol e.g. BTCUSDT
|
|
28
23
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
|
29
24
|
*/
|
|
30
|
-
|
|
25
|
+
ticker(symbol: string): Promise<{
|
|
26
|
+
symbol: string;
|
|
27
|
+
priceChange: string;
|
|
28
|
+
priceChangePercent: string;
|
|
29
|
+
prevClosePrice: string;
|
|
30
|
+
lastPrice: string;
|
|
31
|
+
bidPrice: string;
|
|
32
|
+
bidQty: string;
|
|
33
|
+
askPrice: string;
|
|
34
|
+
askQty: string;
|
|
35
|
+
openPrice: string;
|
|
36
|
+
highPrice: string;
|
|
37
|
+
lowPrice: string;
|
|
38
|
+
volume: string;
|
|
39
|
+
quoteVolume: string;
|
|
40
|
+
openTime: number;
|
|
41
|
+
closeTime: number;
|
|
42
|
+
count: number;
|
|
43
|
+
}>;
|
|
31
44
|
/**
|
|
32
45
|
* Market Data - Kline/Candlestick Data
|
|
33
46
|
* @param symbol e.g. BTCUSDT
|
|
@@ -37,14 +50,14 @@ export declare class MexcService {
|
|
|
37
50
|
* @param limit e.g. 500
|
|
38
51
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data
|
|
39
52
|
*/
|
|
40
|
-
|
|
53
|
+
klines(symbol: string, interval: '1m' | '5m' | '15m' | '30m' | '60m' | '4h' | '1d' | '1M', startTime?: string | number, endTime?: string | number, limit?: number): Promise<[number, string, string, string, string, string, number, string][]>;
|
|
41
54
|
/**
|
|
42
55
|
* Market Data - Order Book
|
|
43
56
|
* @param symbol e.g. BTCUSDT
|
|
44
57
|
* @param limit e.g. 500
|
|
45
58
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
|
|
46
59
|
*/
|
|
47
|
-
|
|
60
|
+
depth(symbol: string, limit?: number): Promise<{
|
|
48
61
|
lastUpdateId: number;
|
|
49
62
|
bids: [string, string][];
|
|
50
63
|
asks: [string, string][];
|
|
@@ -12,43 +12,20 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
|
12
12
|
let MexcService = class MexcService {
|
|
13
13
|
constructor(constant) {
|
|
14
14
|
this.constant = constant;
|
|
15
|
-
|
|
15
|
+
this.instance = axios_1.default.create({ baseURL: this.constant.mexc.url });
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Market Data - Ticker Information
|
|
19
|
-
* @param symbol e.g. BTC_USDC
|
|
20
|
-
* @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#ticker-information
|
|
21
|
-
*/
|
|
22
|
-
marketTicker(symbol) {
|
|
23
|
-
var _a;
|
|
24
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
26
|
-
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
27
|
-
}
|
|
28
|
-
return (yield (0, axios_1.default)({
|
|
29
|
-
method: 'GET',
|
|
30
|
-
url: this.constant.mexc.url + '/open/api/v2/market/ticker',
|
|
31
|
-
params: { symbol },
|
|
32
|
-
})).data;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
// ----- v3 -----
|
|
36
17
|
/**
|
|
37
18
|
* Market Data - Current Average Price
|
|
38
19
|
* @param symbol e.g. BTCUSDT
|
|
39
20
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#current-average-price
|
|
40
21
|
*/
|
|
41
|
-
|
|
22
|
+
avgPrice(symbol) {
|
|
42
23
|
var _a;
|
|
43
24
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
25
|
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
45
26
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
46
27
|
}
|
|
47
|
-
return (yield (
|
|
48
|
-
method: 'GET',
|
|
49
|
-
url: this.constant.mexc.url + '/api/v3/avgPrice',
|
|
50
|
-
params: { symbol },
|
|
51
|
-
})).data;
|
|
28
|
+
return (yield this.instance.get('/api/v3/avgPrice', { params: { symbol } })).data;
|
|
52
29
|
});
|
|
53
30
|
}
|
|
54
31
|
/**
|
|
@@ -56,17 +33,13 @@ let MexcService = class MexcService {
|
|
|
56
33
|
* @param symbol e.g. BTCUSDT
|
|
57
34
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
|
58
35
|
*/
|
|
59
|
-
|
|
36
|
+
ticker(symbol) {
|
|
60
37
|
var _a;
|
|
61
38
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
62
39
|
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
63
40
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
64
41
|
}
|
|
65
|
-
return (yield (
|
|
66
|
-
method: 'GET',
|
|
67
|
-
url: this.constant.mexc.url + '/api/v3/ticker/24hr',
|
|
68
|
-
params: { symbol },
|
|
69
|
-
})).data;
|
|
42
|
+
return (yield this.instance.get('/api/v3/ticker/24hr', { params: { symbol } })).data;
|
|
70
43
|
});
|
|
71
44
|
}
|
|
72
45
|
/**
|
|
@@ -78,17 +51,13 @@ let MexcService = class MexcService {
|
|
|
78
51
|
* @param limit e.g. 500
|
|
79
52
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data
|
|
80
53
|
*/
|
|
81
|
-
|
|
54
|
+
klines(symbol, interval, startTime, endTime, limit) {
|
|
82
55
|
var _a;
|
|
83
56
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
84
57
|
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
85
58
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
86
59
|
}
|
|
87
|
-
return (yield (
|
|
88
|
-
method: 'GET',
|
|
89
|
-
url: this.constant.mexc.url + '/api/v3/klines',
|
|
90
|
-
params: { symbol, interval, startTime, endTime, limit },
|
|
91
|
-
})).data;
|
|
60
|
+
return (yield this.instance.get('/api/v3/klines', { params: { symbol, interval, startTime, endTime, limit } })).data;
|
|
92
61
|
});
|
|
93
62
|
}
|
|
94
63
|
/**
|
|
@@ -97,17 +66,13 @@ let MexcService = class MexcService {
|
|
|
97
66
|
* @param limit e.g. 500
|
|
98
67
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
|
|
99
68
|
*/
|
|
100
|
-
|
|
69
|
+
depth(symbol, limit) {
|
|
101
70
|
var _a;
|
|
102
71
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
103
72
|
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
104
73
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
105
74
|
}
|
|
106
|
-
return (yield (
|
|
107
|
-
method: 'GET',
|
|
108
|
-
url: this.constant.mexc.url + '/api/v3/depth',
|
|
109
|
-
params: { symbol, limit },
|
|
110
|
-
})).data;
|
|
75
|
+
return (yield this.instance.get('/api/v3/depth', { params: { symbol, limit } })).data;
|
|
111
76
|
});
|
|
112
77
|
}
|
|
113
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mexc.service.js","sourceRoot":"","sources":["../../src/mexc/mexc.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"mexc.service.js","sourceRoot":"","sources":["../../src/mexc/mexc.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,0DAA6C;AAItC,IAAM,WAAW,GAAjB,MAAM,WAAW;IAEtB,YAAqD,QAAoB;QAApB,aAAQ,GAAR,QAAQ,CAAY;QACvE,IAAI,CAAC,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACG,QAAQ,CAAC,MAAc;;;YAC3B,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,0CAAE,OAAO,CAAA,EAAE;gBAChC,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aAClF;YACD,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;;KACnF;IAED;;;;OAIG;IACG,MAAM,CAAC,MAAc;;;YAmBzB,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,0CAAE,OAAO,CAAA,EAAE;gBAChC,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aAClF;YACD,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;;KACtF;IAED;;;;;;;;OAQG;IACG,MAAM,CACV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