@pipedream/coincatch 0.0.1 → 0.1.0
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/actions/get-candle-data/get-candle-data.mjs +74 -0
- package/actions/get-depth/get-depth.mjs +54 -0
- package/actions/get-history-funding-rate/get-history-funding-rate.mjs +57 -0
- package/actions/get-history-orders/get-history-orders.mjs +70 -0
- package/actions/get-open-orders/get-open-orders.mjs +46 -0
- package/actions/get-position-tier/get-position-tier.mjs +43 -0
- package/actions/get-single-account/get-single-account.mjs +52 -0
- package/actions/get-single-symbol-ticker/get-single-symbol-ticker.mjs +42 -0
- package/actions/get-symbol-mark-price/get-symbol-mark-price.mjs +42 -0
- package/actions/list-symbols/list-symbols.mjs +33 -0
- package/coincatch.app.mjs +214 -5
- package/common/constants.mjs +106 -0
- package/package.json +4 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
import constants from "../../common/constants.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "coincatch-get-candle-data",
|
|
6
|
+
name: "Get Candle Data",
|
|
7
|
+
description: "Gets candle data. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-candle-data)",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: true,
|
|
14
|
+
},
|
|
15
|
+
props: {
|
|
16
|
+
coincatch,
|
|
17
|
+
productType: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
coincatch,
|
|
20
|
+
"productType",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
symbol: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
coincatch,
|
|
26
|
+
"symbol",
|
|
27
|
+
({ productType }) => ({
|
|
28
|
+
productType,
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
granularity: {
|
|
33
|
+
type: "string",
|
|
34
|
+
label: "Granularity",
|
|
35
|
+
description: "The type of candlestick interval",
|
|
36
|
+
options: constants.GRANULARITIES,
|
|
37
|
+
},
|
|
38
|
+
startTime: {
|
|
39
|
+
propDefinition: [
|
|
40
|
+
coincatch,
|
|
41
|
+
"startTime",
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
endTime: {
|
|
45
|
+
propDefinition: [
|
|
46
|
+
coincatch,
|
|
47
|
+
"endTime",
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
limit: {
|
|
51
|
+
type: "integer",
|
|
52
|
+
label: "Limit",
|
|
53
|
+
description: "The maximum number of candlesticks to return",
|
|
54
|
+
optional: true,
|
|
55
|
+
min: 1,
|
|
56
|
+
default: 100,
|
|
57
|
+
max: 1000,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
async run({ $ }) {
|
|
61
|
+
const response = await this.coincatch.getCandleData({
|
|
62
|
+
$,
|
|
63
|
+
params: {
|
|
64
|
+
symbol: this.symbol,
|
|
65
|
+
granularity: this.granularity,
|
|
66
|
+
startTime: new Date(this.startTime).getTime(),
|
|
67
|
+
endTime: new Date(this.endTime).getTime(),
|
|
68
|
+
limit: this.limit,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
$.export("$summary", `Successfully retrieved ${response?.length} candle data points for \`${this.symbol}\``);
|
|
72
|
+
return response;
|
|
73
|
+
},
|
|
74
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
import constants from "../../common/constants.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "coincatch-get-depth",
|
|
6
|
+
name: "Get Depth",
|
|
7
|
+
description: "Gets depth data. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-depth)",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "action",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: true,
|
|
14
|
+
},
|
|
15
|
+
props: {
|
|
16
|
+
coincatch,
|
|
17
|
+
productType: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
coincatch,
|
|
20
|
+
"productType",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
symbol: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
coincatch,
|
|
26
|
+
"symbol",
|
|
27
|
+
({ productType }) => ({
|
|
28
|
+
productType,
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
limit: {
|
|
33
|
+
type: "string",
|
|
34
|
+
label: "Limit",
|
|
35
|
+
description: "The maximum number of depth data to return. Default: `100`",
|
|
36
|
+
optional: true,
|
|
37
|
+
options: constants.MARKET_DEPTH_LIMITS,
|
|
38
|
+
default: "100",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
async run({ $ }) {
|
|
42
|
+
const response = await this.coincatch.getDepth({
|
|
43
|
+
$,
|
|
44
|
+
params: {
|
|
45
|
+
symbol: this.symbol,
|
|
46
|
+
limit: this.limit
|
|
47
|
+
? parseInt(this.limit)
|
|
48
|
+
: undefined,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
$.export("$summary", `Successfully retrieved depth data for \`${this.symbol}\``);
|
|
52
|
+
return response;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "coincatch-get-history-funding-rate",
|
|
5
|
+
name: "Get History Funding Rate",
|
|
6
|
+
description: "Get history funding rate. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-history-funding-rate)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
coincatch,
|
|
16
|
+
productType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
coincatch,
|
|
19
|
+
"productType",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
symbol: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
coincatch,
|
|
25
|
+
"symbol",
|
|
26
|
+
({ productType }) => ({
|
|
27
|
+
productType,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
pageSize: {
|
|
32
|
+
propDefinition: [
|
|
33
|
+
coincatch,
|
|
34
|
+
"pageSize",
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
pageNumber: {
|
|
38
|
+
propDefinition: [
|
|
39
|
+
coincatch,
|
|
40
|
+
"pageNumber",
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
async run({ $ }) {
|
|
45
|
+
const response = await this.coincatch.getHistoryFundingRate({
|
|
46
|
+
$,
|
|
47
|
+
params: {
|
|
48
|
+
productType: this.productType,
|
|
49
|
+
symbol: this.symbol,
|
|
50
|
+
pageSize: this.pageSize,
|
|
51
|
+
pageNo: this.pageNumber,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
$.export("$summary", `Successfully retrieved history funding rate for ${this.symbol}`);
|
|
55
|
+
return response;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "coincatch-get-history-orders",
|
|
5
|
+
name: "Get History Orders",
|
|
6
|
+
description: "Gets history orders. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-history-orders)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
coincatch,
|
|
16
|
+
productType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
coincatch,
|
|
19
|
+
"productType",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
symbol: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
coincatch,
|
|
25
|
+
"symbol",
|
|
26
|
+
({ productType }) => ({
|
|
27
|
+
productType,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
startTime: {
|
|
32
|
+
propDefinition: [
|
|
33
|
+
coincatch,
|
|
34
|
+
"startTime",
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
endTime: {
|
|
38
|
+
propDefinition: [
|
|
39
|
+
coincatch,
|
|
40
|
+
"endTime",
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
pageSize: {
|
|
44
|
+
propDefinition: [
|
|
45
|
+
coincatch,
|
|
46
|
+
"pageSize",
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
lastEndId: {
|
|
50
|
+
type: "string",
|
|
51
|
+
label: "Last End ID",
|
|
52
|
+
description: "last end ID of last query. This is used to paginate the results.",
|
|
53
|
+
optional: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
async run({ $ }) {
|
|
57
|
+
const response = await this.coincatch.getHistoryOrders({
|
|
58
|
+
$,
|
|
59
|
+
params: {
|
|
60
|
+
symbol: this.symbol,
|
|
61
|
+
startTime: new Date(this.startTime).getTime(),
|
|
62
|
+
endTime: new Date(this.endTime).getTime(),
|
|
63
|
+
pageSize: this.pageSize,
|
|
64
|
+
lastEndId: this.lastEndId,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
$.export("$summary", `Successfully retrieved history orders for \`${this.symbol}\``);
|
|
68
|
+
return response;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "coincatch-get-open-orders",
|
|
5
|
+
name: "Get Open Orders",
|
|
6
|
+
description: "Get pending order list on one symbol. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-open-order)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
coincatch,
|
|
16
|
+
productType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
coincatch,
|
|
19
|
+
"productType",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
symbol: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
coincatch,
|
|
25
|
+
"symbol",
|
|
26
|
+
({ productType }) => ({
|
|
27
|
+
productType,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
async run({ $ }) {
|
|
33
|
+
const response = await this.coincatch.getOpenOrders({
|
|
34
|
+
$,
|
|
35
|
+
params: {
|
|
36
|
+
symbol: this.symbol,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (response.data?.orderList?.length) {
|
|
40
|
+
$.export("$summary", `Successfully retrieved ${response.data.orderList.length} pending orders for ${this.symbol}`);
|
|
41
|
+
} else {
|
|
42
|
+
$.export("$summary", "No pending orders found");
|
|
43
|
+
}
|
|
44
|
+
return response;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "coincatch-get-position-tier",
|
|
5
|
+
name: "Get Position Tier",
|
|
6
|
+
description: "Gets position tier. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-position-tier)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
coincatch,
|
|
16
|
+
productType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
coincatch,
|
|
19
|
+
"productType",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
symbol: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
coincatch,
|
|
25
|
+
"symbol",
|
|
26
|
+
({ productType }) => ({
|
|
27
|
+
productType,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
async run({ $ }) {
|
|
33
|
+
const response = await this.coincatch.getPositionTier({
|
|
34
|
+
$,
|
|
35
|
+
params: {
|
|
36
|
+
symbol: this.symbol,
|
|
37
|
+
productType: this.productType,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
$.export("$summary", `Successfully retrieved position tier for \`${this.symbol}\``);
|
|
41
|
+
return response;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "coincatch-get-single-account",
|
|
5
|
+
name: "Get Single Account",
|
|
6
|
+
description: "Gets a single account. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-single-account)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
coincatch,
|
|
16
|
+
productType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
coincatch,
|
|
19
|
+
"productType",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
symbol: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
coincatch,
|
|
25
|
+
"symbol",
|
|
26
|
+
({ productType }) => ({
|
|
27
|
+
productType,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
marginCoin: {
|
|
32
|
+
propDefinition: [
|
|
33
|
+
coincatch,
|
|
34
|
+
"marginCoin",
|
|
35
|
+
({ productType }) => ({
|
|
36
|
+
productType,
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
async run({ $ }) {
|
|
42
|
+
const response = await this.coincatch.getSingleAccount({
|
|
43
|
+
$,
|
|
44
|
+
params: {
|
|
45
|
+
symbol: this.symbol,
|
|
46
|
+
marginCoin: this.marginCoin,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
$.export("$summary", "Successfully retrieved account details");
|
|
50
|
+
return response;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "coincatch-get-single-symbol-ticker",
|
|
5
|
+
name: "Get Single Symbol Ticker",
|
|
6
|
+
description: "Gets single symbol ticker. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-single-symbol-ticker)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
coincatch,
|
|
16
|
+
productType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
coincatch,
|
|
19
|
+
"productType",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
symbol: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
coincatch,
|
|
25
|
+
"symbol",
|
|
26
|
+
({ productType }) => ({
|
|
27
|
+
productType,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
async run({ $ }) {
|
|
33
|
+
const response = await this.coincatch.getSingleSymbolTicker({
|
|
34
|
+
$,
|
|
35
|
+
params: {
|
|
36
|
+
symbol: this.symbol,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
$.export("$summary", `Successfully retrieved single symbol ticker for \`${this.symbol}\``);
|
|
40
|
+
return response;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "coincatch-get-symbol-mark-price",
|
|
5
|
+
name: "Get Symbol Mark Price",
|
|
6
|
+
description: "Get symbol mark price. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-symbol-mark-price)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
coincatch,
|
|
16
|
+
productType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
coincatch,
|
|
19
|
+
"productType",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
symbol: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
coincatch,
|
|
25
|
+
"symbol",
|
|
26
|
+
({ productType }) => ({
|
|
27
|
+
productType,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
async run({ $ }) {
|
|
33
|
+
const response = await this.coincatch.getSymbolMarkPrice({
|
|
34
|
+
$,
|
|
35
|
+
params: {
|
|
36
|
+
symbol: this.symbol,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
$.export("$summary", `Successfully retrieved symbol mark price for ${this.symbol}`);
|
|
40
|
+
return response;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import coincatch from "../../coincatch.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "coincatch-list-symbols",
|
|
5
|
+
name: "List Symbols",
|
|
6
|
+
description: "List all symbols. [See the documentation](https://coincatch.github.io/github.io/en/mix/#get-all-symbols)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
coincatch,
|
|
16
|
+
productType: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
coincatch,
|
|
19
|
+
"productType",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
async run({ $ }) {
|
|
24
|
+
const response = await this.coincatch.listSymbols({
|
|
25
|
+
$,
|
|
26
|
+
params: {
|
|
27
|
+
productType: this.productType,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
$.export("$summary", `Successfully retrieved ${response?.data?.length} symbols`);
|
|
31
|
+
return response;
|
|
32
|
+
},
|
|
33
|
+
};
|
package/coincatch.app.mjs
CHANGED
|
@@ -1,11 +1,220 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
import crypto from "crypto";
|
|
3
|
+
import constants from "./common/constants.mjs";
|
|
4
|
+
|
|
1
5
|
export default {
|
|
2
6
|
type: "app",
|
|
3
7
|
app: "coincatch",
|
|
4
|
-
propDefinitions: {
|
|
8
|
+
propDefinitions: {
|
|
9
|
+
productType: {
|
|
10
|
+
type: "string",
|
|
11
|
+
label: "Product Type",
|
|
12
|
+
description: "Product type",
|
|
13
|
+
options: constants.PRODUCT_TYPES,
|
|
14
|
+
},
|
|
15
|
+
marginCoin: {
|
|
16
|
+
type: "string",
|
|
17
|
+
label: "Margin Coin",
|
|
18
|
+
description: "Margin coin",
|
|
19
|
+
async options({ productType }) {
|
|
20
|
+
const { data } = await this.listAccounts({
|
|
21
|
+
params: {
|
|
22
|
+
productType,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return data.map(({ marginCoin }) => marginCoin);
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
symbol: {
|
|
29
|
+
type: "string",
|
|
30
|
+
label: "Symbol",
|
|
31
|
+
description: "Symbol (Must be capitalized)",
|
|
32
|
+
async options({ productType }) {
|
|
33
|
+
const { data } = await this.listSymbols({
|
|
34
|
+
params: {
|
|
35
|
+
productType,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return data.map(({ symbol }) => symbol);
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
pageSize: {
|
|
42
|
+
type: "integer",
|
|
43
|
+
label: "Page Size",
|
|
44
|
+
description: "Page size",
|
|
45
|
+
default: 100,
|
|
46
|
+
min: 1,
|
|
47
|
+
max: 100,
|
|
48
|
+
},
|
|
49
|
+
pageNumber: {
|
|
50
|
+
type: "integer",
|
|
51
|
+
label: "Page Number",
|
|
52
|
+
description: "Page number",
|
|
53
|
+
default: 1,
|
|
54
|
+
},
|
|
55
|
+
startTime: {
|
|
56
|
+
type: "string",
|
|
57
|
+
label: "Start Time",
|
|
58
|
+
description: "The start time to use. Example: `2025-01-01T00:00:00Z`",
|
|
59
|
+
},
|
|
60
|
+
endTime: {
|
|
61
|
+
type: "string",
|
|
62
|
+
label: "End Time",
|
|
63
|
+
description: "The end time to use. Example: `2025-01-01T00:00:00Z`",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
5
66
|
methods: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
67
|
+
createSignedHeaders({
|
|
68
|
+
method,
|
|
69
|
+
requestPath,
|
|
70
|
+
queryString = "",
|
|
71
|
+
body = "",
|
|
72
|
+
}) {
|
|
73
|
+
const accessKey = this.$auth.access_key;
|
|
74
|
+
const secretKey = this.$auth.secret_key;
|
|
75
|
+
const passphrase = this.$auth.passphrase;
|
|
76
|
+
const timestamp = Date.now().toString();
|
|
77
|
+
const upperMethod = method.toUpperCase();
|
|
78
|
+
|
|
79
|
+
// Build content to sign
|
|
80
|
+
let contentToSign = timestamp + upperMethod + requestPath;
|
|
81
|
+
if (queryString) {
|
|
82
|
+
contentToSign += "?" + queryString;
|
|
83
|
+
}
|
|
84
|
+
if (body) {
|
|
85
|
+
contentToSign += body;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Generate signature
|
|
89
|
+
const hmac = crypto.createHmac("sha256", secretKey);
|
|
90
|
+
hmac.update(contentToSign);
|
|
91
|
+
const signature = hmac.digest("base64");
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
timestamp,
|
|
95
|
+
method: upperMethod,
|
|
96
|
+
requestPath,
|
|
97
|
+
queryString,
|
|
98
|
+
body,
|
|
99
|
+
contentToSign,
|
|
100
|
+
signature,
|
|
101
|
+
headers: {
|
|
102
|
+
"ACCESS-KEY": accessKey,
|
|
103
|
+
"ACCESS-SIGN": signature,
|
|
104
|
+
"ACCESS-TIMESTAMP": timestamp,
|
|
105
|
+
"ACCESS-PASSPHRASE": passphrase,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
cleanObject(o) {
|
|
110
|
+
for (const k in o || {}) {
|
|
111
|
+
if (typeof o[k] === "undefined") {
|
|
112
|
+
delete o[k];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
makeRequest({
|
|
117
|
+
$ = this, method = "GET", path, params, data,
|
|
118
|
+
}) {
|
|
119
|
+
if (params) {
|
|
120
|
+
this.cleanObject(params);
|
|
121
|
+
}
|
|
122
|
+
if (data) {
|
|
123
|
+
this.cleanObject(data);
|
|
124
|
+
}
|
|
125
|
+
const resp = this.createSignedHeaders({
|
|
126
|
+
method,
|
|
127
|
+
requestPath: path,
|
|
128
|
+
queryString: params
|
|
129
|
+
? new URLSearchParams(params).toString()
|
|
130
|
+
: undefined,
|
|
131
|
+
body: data
|
|
132
|
+
? JSON.stringify(data)
|
|
133
|
+
: undefined,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const url = `https://api.coincatch.com${resp.requestPath}${resp.queryString
|
|
137
|
+
? "?" + resp.queryString
|
|
138
|
+
: ""
|
|
139
|
+
}`;
|
|
140
|
+
|
|
141
|
+
if (data) {
|
|
142
|
+
resp.headers["Content-Type"] = "application/json";
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Make the API request
|
|
146
|
+
return axios($, {
|
|
147
|
+
method: resp.method,
|
|
148
|
+
url,
|
|
149
|
+
headers: resp.headers,
|
|
150
|
+
data: resp.body || undefined,
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
listAccounts(opts = {}) {
|
|
154
|
+
return this.makeRequest({
|
|
155
|
+
path: "/api/mix/v1/account/accounts",
|
|
156
|
+
...opts,
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
listSymbols(opts = {}) {
|
|
160
|
+
return this.makeRequest({
|
|
161
|
+
path: "/api/mix/v1/market/contracts",
|
|
162
|
+
...opts,
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
getSingleAccount(opts = {}) {
|
|
166
|
+
return this.makeRequest({
|
|
167
|
+
path: "/api/mix/v1/account/account",
|
|
168
|
+
...opts,
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
getHistoryFundingRate(opts = {}) {
|
|
172
|
+
return this.makeRequest({
|
|
173
|
+
path: "/api/mix/v1/market/history-fundRate",
|
|
174
|
+
...opts,
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
getSymbolMarkPrice(opts = {}) {
|
|
178
|
+
return this.makeRequest({
|
|
179
|
+
path: "/api/mix/v1/market/mark-price",
|
|
180
|
+
...opts,
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
getOpenOrders(opts = {}) {
|
|
184
|
+
return this.makeRequest({
|
|
185
|
+
path: "/api/mix/v1/order/current",
|
|
186
|
+
...opts,
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
getCandleData(opts = {}) {
|
|
190
|
+
return this.makeRequest({
|
|
191
|
+
path: "/api/mix/v1/market/candles",
|
|
192
|
+
...opts,
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
getDepth(opts = {}) {
|
|
196
|
+
return this.makeRequest({
|
|
197
|
+
path: "/api/mix/v1/market/depth",
|
|
198
|
+
...opts,
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
getHistoryOrders(opts = {}) {
|
|
202
|
+
return this.makeRequest({
|
|
203
|
+
path: "/api/mix/v1/order/history",
|
|
204
|
+
...opts,
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
getPositionTier(opts = {}) {
|
|
208
|
+
return this.makeRequest({
|
|
209
|
+
path: "/api/mix/v1/market/queryPositionLever",
|
|
210
|
+
...opts,
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
getSingleSymbolTicker(opts = {}) {
|
|
214
|
+
return this.makeRequest({
|
|
215
|
+
path: "/api/mix/v1/market/ticker",
|
|
216
|
+
...opts,
|
|
217
|
+
});
|
|
9
218
|
},
|
|
10
219
|
},
|
|
11
|
-
};
|
|
220
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const PRODUCT_TYPES = [
|
|
2
|
+
{
|
|
3
|
+
value: "UMCBL",
|
|
4
|
+
label: "USDT perpetual contract",
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
value: "DMCBL",
|
|
8
|
+
label: "Universal margin perpetual contract",
|
|
9
|
+
},
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const GRANULARITIES = [
|
|
13
|
+
{
|
|
14
|
+
value: "1m",
|
|
15
|
+
label: "1 minute",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: "3m",
|
|
19
|
+
label: "3 minutes",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: "5m",
|
|
23
|
+
label: "5 minutes",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
value: "15m",
|
|
27
|
+
label: "15 minutes",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
value: "30m",
|
|
31
|
+
label: "30 minutes",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: "1H",
|
|
35
|
+
label: "1 hour",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
value: "2H",
|
|
39
|
+
label: "2 hours",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
value: "4H",
|
|
43
|
+
label: "4 hours",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
value: "6H",
|
|
47
|
+
label: "6 hours",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
value: "12H",
|
|
51
|
+
label: "12 hours",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
value: "1D",
|
|
55
|
+
label: "1 day",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: "3D",
|
|
59
|
+
label: "3 days",
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: "1W",
|
|
63
|
+
label: "1 week",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: "1M",
|
|
67
|
+
label: "1 month",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: "6Hutc",
|
|
71
|
+
label: "6 hours UTC",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
value: "12Hutc",
|
|
75
|
+
label: "12 hours UTC",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
value: "1Dutc",
|
|
79
|
+
label: "1 day UTC",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
value: "3Dutc",
|
|
83
|
+
label: "3 days UTC",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
value: "1Wutc",
|
|
87
|
+
label: "1 week UTC",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
value: "1Mutc",
|
|
91
|
+
label: "1 month UTC",
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const MARKET_DEPTH_LIMITS = [
|
|
96
|
+
"5",
|
|
97
|
+
"15",
|
|
98
|
+
"50",
|
|
99
|
+
"100",
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
export default {
|
|
103
|
+
PRODUCT_TYPES,
|
|
104
|
+
GRANULARITIES,
|
|
105
|
+
MARKET_DEPTH_LIMITS,
|
|
106
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/coincatch",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pipedream CoinCatch Components",
|
|
5
5
|
"main": "coincatch.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -11,5 +11,8 @@
|
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^3.1.1"
|
|
14
17
|
}
|
|
15
18
|
}
|