coinrayjs 1.9.11 → 2.0.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/dist/coinrayjs.es.js +13082 -0
- package/dist/coinrayjs.es.js.map +1 -0
- package/dist/coinrayjs.js +52 -0
- package/dist/coinrayjs.js.map +1 -0
- package/package.json +50 -81
- package/dist/candles-cache.d.ts +0 -7
- package/dist/candles-cache.js +0 -57
- package/dist/candles-cache.js.map +0 -1
- package/dist/coinray-cache.d.ts +0 -47
- package/dist/coinray-cache.js +0 -255
- package/dist/coinray-cache.js.map +0 -1
- package/dist/coinray.d.ts +0 -183
- package/dist/coinray.js +0 -1118
- package/dist/coinray.js.map +0 -1
- package/dist/crypto.d.ts +0 -1
- package/dist/crypto.js +0 -57
- package/dist/crypto.js.map +0 -1
- package/dist/current-market.d.ts +0 -62
- package/dist/current-market.js +0 -285
- package/dist/current-market.js.map +0 -1
- package/dist/errors.d.ts +0 -25
- package/dist/errors.js +0 -50
- package/dist/errors.js.map +0 -1
- package/dist/event-emitter.d.ts +0 -9
- package/dist/event-emitter.js +0 -36
- package/dist/event-emitter.js.map +0 -1
- package/dist/exchange.d.ts +0 -55
- package/dist/exchange.js +0 -167
- package/dist/exchange.js.map +0 -1
- package/dist/i18n/locales.d.ts +0 -21
- package/dist/i18n/locales.js +0 -21
- package/dist/i18n/locales.js.map +0 -1
- package/dist/i18n.d.ts +0 -4
- package/dist/i18n.js +0 -16
- package/dist/i18n.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -10
- package/dist/index.js.map +0 -1
- package/dist/lru.d.ts +0 -26
- package/dist/lru.js +0 -93
- package/dist/lru.js.map +0 -1
- package/dist/market.d.ts +0 -65
- package/dist/market.js +0 -162
- package/dist/market.js.map +0 -1
- package/dist/orders/base.d.ts +0 -29
- package/dist/orders/base.js +0 -47
- package/dist/orders/base.js.map +0 -1
- package/dist/orders/index.d.ts +0 -6
- package/dist/orders/index.js +0 -7
- package/dist/orders/index.js.map +0 -1
- package/dist/orders/limit-ladder.d.ts +0 -87
- package/dist/orders/limit-ladder.js +0 -229
- package/dist/orders/limit-ladder.js.map +0 -1
- package/dist/orders/limit.d.ts +0 -47
- package/dist/orders/limit.js +0 -86
- package/dist/orders/limit.js.map +0 -1
- package/dist/orders/market.d.ts +0 -37
- package/dist/orders/market.js +0 -60
- package/dist/orders/market.js.map +0 -1
- package/dist/orders/oco.d.ts +0 -54
- package/dist/orders/oco.js +0 -70
- package/dist/orders/oco.js.map +0 -1
- package/dist/orders/stop-limit.d.ts +0 -42
- package/dist/orders/stop-limit.js +0 -33
- package/dist/orders/stop-limit.js.map +0 -1
- package/dist/orders/validate.d.ts +0 -2
- package/dist/orders/validate.js +0 -6
- package/dist/orders/validate.js.map +0 -1
- package/dist/types.d.ts +0 -213
- package/dist/types.js +0 -59
- package/dist/types.js.map +0 -1
- package/dist/util.d.ts +0 -48
- package/dist/util.js +0 -407
- package/dist/util.js.map +0 -1
package/dist/orders/limit.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import BaseOrder from "./base";
|
|
2
|
-
import { BalanceLimit, OrderType } from "../types";
|
|
3
|
-
import BigNumber from "bignumber.js";
|
|
4
|
-
import { correctNumberPrecision, safeBigNumber } from "../util";
|
|
5
|
-
import Coinray from "../coinray";
|
|
6
|
-
export default class LimitOrder extends BaseOrder {
|
|
7
|
-
constructor(params, updateAmounts = true) {
|
|
8
|
-
super(params);
|
|
9
|
-
this.orderType = OrderType.LIMIT;
|
|
10
|
-
this.price = safeBigNumber(params.price || "0");
|
|
11
|
-
this.lockedOn = params.lockedOn;
|
|
12
|
-
this.baseAmount = safeBigNumber(params.baseAmount);
|
|
13
|
-
this.quoteAmount = safeBigNumber(params.quoteAmount);
|
|
14
|
-
if (updateAmounts) {
|
|
15
|
-
if (this.quoteAmount.gt(0) && this.lockedOn === "quoteAmount") {
|
|
16
|
-
this.updateQuoteAmount(this.quoteAmount);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
this.updateBaseAmount(this.baseAmount);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
constraints() {
|
|
24
|
-
let maxBase = undefined;
|
|
25
|
-
let maxQuote = undefined;
|
|
26
|
-
if (this.balanceLimit === BalanceLimit.QUOTE) {
|
|
27
|
-
maxQuote = this.balances.quote || 0;
|
|
28
|
-
}
|
|
29
|
-
else if (this.balanceLimit === BalanceLimit.BASE) {
|
|
30
|
-
maxBase = this.balances.base || 0;
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
baseAmount: {
|
|
34
|
-
bigNumericality: {
|
|
35
|
-
greaterThanOrEqualTo: this.minBase.toNumber(),
|
|
36
|
-
notGreaterThanOrEqualTo: `^${Coinray.I18n.t("validation.notGreaterThanOrEqualTo", { min: correctNumberPrecision(this.precisionBase, this.minBase) })}`,
|
|
37
|
-
lessThanOrEqualTo: maxBase ? maxBase.toNumber() : undefined,
|
|
38
|
-
notLessThanOrEqualTo: `^${Coinray.I18n.t("validation.insufficientFunds")}`,
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
quoteAmount: {
|
|
42
|
-
bigNumericality: {
|
|
43
|
-
greaterThanOrEqualTo: this.minQuote.toNumber(),
|
|
44
|
-
notGreaterThanOrEqualTo: `^${Coinray.I18n.t("validation.notGreaterThanOrEqualTo", { min: correctNumberPrecision(this.precisionQuote, this.minQuote) })}`,
|
|
45
|
-
lessThanOrEqualTo: maxQuote ? maxQuote.toNumber() : undefined,
|
|
46
|
-
notLessThanOrEqualTo: `^${Coinray.I18n.t("validation.insufficientFunds")}`,
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
price: {
|
|
50
|
-
bigNumericality: {
|
|
51
|
-
greaterThan: 0,
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
updateBaseAmount(baseAmount) {
|
|
57
|
-
this.baseAmount = baseAmount;
|
|
58
|
-
this.quoteAmount = this.price.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote > 0 ? this.precisionQuote : 0, BigNumber.ROUND_DOWN);
|
|
59
|
-
this.validate();
|
|
60
|
-
}
|
|
61
|
-
updateQuoteAmount(quoteAmount) {
|
|
62
|
-
this.quoteAmount = quoteAmount;
|
|
63
|
-
this.baseAmount = quoteAmount.dividedBy(this.price).decimalPlaces(this.precisionBase > 0 ? this.precisionBase : 0, BigNumber.ROUND_DOWN);
|
|
64
|
-
this.validate();
|
|
65
|
-
}
|
|
66
|
-
updateLockedOn(lockedOn) {
|
|
67
|
-
this.lockedOn = lockedOn;
|
|
68
|
-
this.validate();
|
|
69
|
-
}
|
|
70
|
-
quoteFee() {
|
|
71
|
-
return this.quoteAmount.multipliedBy(this.takerFee);
|
|
72
|
-
}
|
|
73
|
-
updatePrice(price) {
|
|
74
|
-
this.price = price.decimalPlaces(this.precisionPrice);
|
|
75
|
-
if (this.lockedOn === "baseAmount") {
|
|
76
|
-
this.updateBaseAmount(this.baseAmount);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
this.updateQuoteAmount(this.quoteAmount);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
getOrders() {
|
|
83
|
-
return [this];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=limit.js.map
|
package/dist/orders/limit.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"limit.js","sourceRoot":"","sources":["../../lib/orders/limit.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAC,YAAY,EAAmB,SAAS,EAAC,MAAM,UAAU,CAAC;AAClE,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,sBAAsB,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AAC9D,OAAO,OAAO,MAAM,YAAY,CAAC;AASjC,MAAM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,EAAE,CAAA;IACjB,CAAC;IAED,iBAAiB,CAAC,WAAsB;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;QACzI,IAAI,CAAC,QAAQ,EAAE,CAAA;IACjB,CAAC;IAED,cAAc,CAAC,QAAgB;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,EAAE,CAAA;IACjB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACrD,CAAC;IAED,WAAW,CAAC,KAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAEtD,IAAI,IAAI,CAAC,QAAQ,KAAK,YAAY,EAAE;YAClC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SACvC;aAAM;YACL,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;SACzC;IACH,CAAC;IAED,SAAS;QACP,OAAO,CAAC,IAAI,CAAC,CAAA;IACf,CAAC;CACF"}
|
package/dist/orders/market.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import BaseOrder from "./base";
|
|
2
|
-
import { BaseOrderParams, OrderType } from "../types";
|
|
3
|
-
import BigNumber from "bignumber.js";
|
|
4
|
-
interface MarketOrderParams extends BaseOrderParams {
|
|
5
|
-
quoteAmount?: BigNumber;
|
|
6
|
-
baseAmount?: BigNumber;
|
|
7
|
-
}
|
|
8
|
-
export default class MarketOrder extends BaseOrder {
|
|
9
|
-
baseAmount?: BigNumber;
|
|
10
|
-
quoteAmount?: BigNumber;
|
|
11
|
-
price: BigNumber;
|
|
12
|
-
orderType: OrderType;
|
|
13
|
-
constraints: () => {
|
|
14
|
-
baseAmount: {
|
|
15
|
-
bigNumericality: {
|
|
16
|
-
greaterThanOrEqualTo: number;
|
|
17
|
-
notGreaterThanOrEqualTo: string;
|
|
18
|
-
lessThanOrEqualTo: any;
|
|
19
|
-
notLessThanOrEqualTo: string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
quoteAmount: {
|
|
23
|
-
bigNumericality: {
|
|
24
|
-
greaterThanOrEqualTo: number;
|
|
25
|
-
notGreaterThanOrEqualTo: string;
|
|
26
|
-
lessThanOrEqualTo: any;
|
|
27
|
-
notLessThanOrEqualTo: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
constructor(params: MarketOrderParams);
|
|
32
|
-
updateBaseAmount(baseAmount: BigNumber): void;
|
|
33
|
-
updateQuoteAmount(quoteAmount: BigNumber): void;
|
|
34
|
-
updatePrice(price: BigNumber): void;
|
|
35
|
-
getOrders(): Array<BaseOrder>;
|
|
36
|
-
}
|
|
37
|
-
export {};
|
package/dist/orders/market.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import BaseOrder from "./base";
|
|
2
|
-
import { BalanceLimit, OrderType } from "../types";
|
|
3
|
-
import BigNumber from "bignumber.js";
|
|
4
|
-
import Coinray from "../coinray";
|
|
5
|
-
import { correctNumberPrecision } from "../util";
|
|
6
|
-
export default class MarketOrder extends BaseOrder {
|
|
7
|
-
constructor(params) {
|
|
8
|
-
super(params);
|
|
9
|
-
this.orderType = OrderType.MARKET;
|
|
10
|
-
this.constraints = () => {
|
|
11
|
-
let maxBase = undefined;
|
|
12
|
-
let maxQuote = undefined;
|
|
13
|
-
if (this.balanceLimit === BalanceLimit.QUOTE) {
|
|
14
|
-
maxQuote = this.balances.quote || 0;
|
|
15
|
-
}
|
|
16
|
-
else if (this.balanceLimit === BalanceLimit.BASE) {
|
|
17
|
-
maxBase = this.balances.base || 0;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
baseAmount: {
|
|
21
|
-
bigNumericality: {
|
|
22
|
-
greaterThanOrEqualTo: maxBase ? this.minBase.toNumber() : undefined,
|
|
23
|
-
notGreaterThanOrEqualTo: `^${Coinray.I18n.t("validation.notGreaterThanOrEqualTo", { min: correctNumberPrecision(this.precisionBase, this.minBase) })}`,
|
|
24
|
-
lessThanOrEqualTo: maxBase ? maxBase.toNumber() : undefined,
|
|
25
|
-
notLessThanOrEqualTo: `^${Coinray.I18n.t("validation.insufficientFunds")}`,
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
quoteAmount: {
|
|
29
|
-
bigNumericality: {
|
|
30
|
-
greaterThanOrEqualTo: maxQuote ? this.minQuote.toNumber() : undefined,
|
|
31
|
-
notGreaterThanOrEqualTo: `^${Coinray.I18n.t("validation.notGreaterThanOrEqualTo", { min: correctNumberPrecision(this.precisionQuote, this.minQuote) })}`,
|
|
32
|
-
lessThanOrEqualTo: maxQuote ? maxQuote.toNumber() : undefined,
|
|
33
|
-
notLessThanOrEqualTo: `^${Coinray.I18n.t("validation.insufficientFunds")}`,
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
this.updateQuoteAmount(params.quoteAmount);
|
|
39
|
-
this.updateBaseAmount(params.baseAmount);
|
|
40
|
-
}
|
|
41
|
-
updateBaseAmount(baseAmount) {
|
|
42
|
-
this.baseAmount = baseAmount;
|
|
43
|
-
if (baseAmount)
|
|
44
|
-
this.quoteAmount = this.price.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote > 0 ? this.precisionQuote : 0, BigNumber.ROUND_DOWN);
|
|
45
|
-
this.validate();
|
|
46
|
-
}
|
|
47
|
-
updateQuoteAmount(quoteAmount) {
|
|
48
|
-
this.quoteAmount = quoteAmount;
|
|
49
|
-
if (quoteAmount)
|
|
50
|
-
this.baseAmount = quoteAmount.dividedBy(this.price).decimalPlaces(this.precisionBase > 0 ? this.precisionBase : 0, BigNumber.ROUND_DOWN);
|
|
51
|
-
this.validate();
|
|
52
|
-
}
|
|
53
|
-
updatePrice(price) {
|
|
54
|
-
this.price = price.decimalPlaces(this.precisionPrice);
|
|
55
|
-
}
|
|
56
|
-
getOrders() {
|
|
57
|
-
return [this];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=market.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"market.js","sourceRoot":"","sources":["../../lib/orders/market.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAC,YAAY,EAAmB,SAAS,EAAC,MAAM,UAAU,CAAC;AAClE,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,sBAAsB,EAAgB,MAAM,SAAS,CAAC;AAQ9D,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAS;IAmChD,YAAY,MAAyB;QACnC,KAAK,CAAC,MAAM,CAAC,CAAC;QAhChB,cAAS,GAAG,SAAS,CAAC,MAAM,CAAC;QAE7B,gBAAW,GAAG,GAAG,EAAE;YACjB,IAAI,OAAO,GAAG,SAAS,CAAC;YACxB,IAAI,QAAQ,GAAG,SAAS,CAAC;YACzB,IAAI,IAAI,CAAC,YAAY,KAAK,YAAY,CAAC,KAAK,EAAE;gBAC5C,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAA;aACpC;iBAAM,IAAI,IAAI,CAAC,YAAY,KAAK,YAAY,CAAC,IAAI,EAAE;gBAClD,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAA;aAClC;YAED,OAAO;gB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,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,UAAU;YAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;QACnK,IAAI,CAAC,QAAQ,EAAE,CAAA;IACjB,CAAC;IAED,iBAAiB,CAAC,WAAsB;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,WAAW;YAAE,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;QAC1J,IAAI,CAAC,QAAQ,EAAE,CAAA;IACjB,CAAC;IAED,WAAW,CAAC,KAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACxD,CAAC;IAED,SAAS;QACP,OAAO,CAAC,IAAI,CAAC,CAAA;IACf,CAAC;CACF"}
|
package/dist/orders/oco.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { OrderType } from "../types";
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
3
|
-
import LimitOrder, { LimitOrderParams } from "./limit";
|
|
4
|
-
interface OcoOrderParams extends LimitOrderParams {
|
|
5
|
-
linkedOrderId: string;
|
|
6
|
-
otherPrice: BigNumber;
|
|
7
|
-
stopPrice: BigNumber;
|
|
8
|
-
}
|
|
9
|
-
export default class OcoOrder extends LimitOrder {
|
|
10
|
-
linkedOrderId: string;
|
|
11
|
-
otherPrice: BigNumber;
|
|
12
|
-
stopPrice: BigNumber;
|
|
13
|
-
orderType: OrderType;
|
|
14
|
-
constraints(): {
|
|
15
|
-
otherPrice: {
|
|
16
|
-
bigNumericality: {
|
|
17
|
-
greaterThan: number;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
stopPrice: {
|
|
21
|
-
bigNumericality: {
|
|
22
|
-
greaterThan: number;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
baseAmount: {
|
|
26
|
-
bigNumericality: {
|
|
27
|
-
greaterThanOrEqualTo: number;
|
|
28
|
-
notGreaterThanOrEqualTo: string;
|
|
29
|
-
lessThanOrEqualTo: any;
|
|
30
|
-
notLessThanOrEqualTo: string;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
quoteAmount: {
|
|
34
|
-
bigNumericality: {
|
|
35
|
-
greaterThanOrEqualTo: number;
|
|
36
|
-
notGreaterThanOrEqualTo: string;
|
|
37
|
-
lessThanOrEqualTo: any;
|
|
38
|
-
notLessThanOrEqualTo: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
price: {
|
|
42
|
-
bigNumericality: {
|
|
43
|
-
greaterThan: number;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
constructor(params: OcoOrderParams);
|
|
48
|
-
updateQuoteAmount(quoteAmount: BigNumber): void;
|
|
49
|
-
updateBaseAmount(baseAmount: BigNumber): void;
|
|
50
|
-
updatePrice(price: BigNumber, priceOffset?: number): void;
|
|
51
|
-
updateOtherPrice(otherPrice: BigNumber, priceOffset?: number): void;
|
|
52
|
-
updateStopPrice(stopPrice: BigNumber, priceOffset?: number): void;
|
|
53
|
-
}
|
|
54
|
-
export {};
|
package/dist/orders/oco.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { OrderSide, OrderType } from "../types";
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
3
|
-
import LimitOrder from "./limit";
|
|
4
|
-
import { safeBigNumber } from "../util";
|
|
5
|
-
export default class OcoOrder extends LimitOrder {
|
|
6
|
-
constructor(params) {
|
|
7
|
-
super(params, false);
|
|
8
|
-
this.orderType = OrderType.OCO;
|
|
9
|
-
this.otherPrice = safeBigNumber(params.otherPrice);
|
|
10
|
-
this.stopPrice = safeBigNumber(params.stopPrice);
|
|
11
|
-
if (this.quoteAmount.gt(0) && this.lockedOn === "quoteAmount") {
|
|
12
|
-
this.updateQuoteAmount(this.quoteAmount);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
this.updateBaseAmount(this.baseAmount);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
constraints() {
|
|
19
|
-
const limitConstraints = super.constraints();
|
|
20
|
-
return Object.assign(Object.assign({}, limitConstraints), { otherPrice: {
|
|
21
|
-
bigNumericality: {
|
|
22
|
-
greaterThan: 0,
|
|
23
|
-
}
|
|
24
|
-
}, stopPrice: {
|
|
25
|
-
bigNumericality: {
|
|
26
|
-
greaterThan: 0,
|
|
27
|
-
}
|
|
28
|
-
} });
|
|
29
|
-
}
|
|
30
|
-
updateQuoteAmount(quoteAmount) {
|
|
31
|
-
this.quoteAmount = quoteAmount;
|
|
32
|
-
let basePrice = this.side === OrderSide.BUY ? this.otherPrice : this.price;
|
|
33
|
-
this.baseAmount = quoteAmount.dividedBy(basePrice).decimalPlaces(this.precisionBase > 0 ? this.precisionBase : 0, BigNumber.ROUND_DOWN);
|
|
34
|
-
this.validate();
|
|
35
|
-
}
|
|
36
|
-
updateBaseAmount(baseAmount) {
|
|
37
|
-
this.baseAmount = baseAmount;
|
|
38
|
-
let basePrice = this.side === OrderSide.BUY ? this.otherPrice : this.price;
|
|
39
|
-
this.quoteAmount = basePrice.multipliedBy(this.baseAmount).decimalPlaces(this.precisionQuote > 0 ? this.precisionQuote : 0, BigNumber.ROUND_DOWN);
|
|
40
|
-
this.validate();
|
|
41
|
-
}
|
|
42
|
-
updatePrice(price, priceOffset = 0.05) {
|
|
43
|
-
super.updatePrice(price);
|
|
44
|
-
if (price && this.otherPrice.eq(0)) {
|
|
45
|
-
const offset = this.side === OrderSide.BUY ? 1 + (priceOffset * 2) : 1 - (priceOffset * 2);
|
|
46
|
-
const stopOffset = this.side === OrderSide.BUY ? 1 + priceOffset : 1 - priceOffset;
|
|
47
|
-
this.otherPrice = price.multipliedBy(offset).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
48
|
-
this.stopPrice = price.multipliedBy(stopOffset).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
updateOtherPrice(otherPrice, priceOffset = 0.05) {
|
|
52
|
-
this.otherPrice = otherPrice.decimalPlaces(this.precisionPrice);
|
|
53
|
-
if (otherPrice && this.price.eq(0)) {
|
|
54
|
-
const offset = this.side === OrderSide.BUY ? 1 - (priceOffset * 2) : 1 + (priceOffset * 2);
|
|
55
|
-
const stopOffset = this.side === OrderSide.BUY ? 1 - priceOffset : 1 + priceOffset;
|
|
56
|
-
this.price = otherPrice.multipliedBy(offset).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
57
|
-
this.stopPrice = otherPrice.multipliedBy(stopOffset).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
updateStopPrice(stopPrice, priceOffset = 0.05) {
|
|
61
|
-
this.stopPrice = stopPrice.decimalPlaces(this.precisionPrice);
|
|
62
|
-
if (stopPrice && this.price.eq(0)) {
|
|
63
|
-
const offset = this.side === OrderSide.BUY ? 1 - priceOffset : 1 + priceOffset;
|
|
64
|
-
const otherOffset = this.side === OrderSide.BUY ? 1 + priceOffset : 1 - priceOffset;
|
|
65
|
-
this.price = stopPrice.multipliedBy(offset).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
66
|
-
this.otherPrice = stopPrice.multipliedBy(otherOffset).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=oco.js.map
|
package/dist/orders/oco.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oco.js","sourceRoot":"","sources":["../../lib/orders/oco.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAC9C,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,UAA8B,MAAM,SAAS,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAQtC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;IAuB9C,YAAY,MAAsB;QAChC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QApBvB,cAAS,GAAG,SAAS,CAAC,GAAG,CAAC;QAqBxB,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEjD,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,KAAK,aAAa,EAAE;YAC7D,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;SACzC;aAAM;YACL,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SACvC;IACH,CAAC;IA3BD,WAAW;QACT,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAC7C,uCACK,gBAAgB,KACnB,UAAU,EAAE;gBACV,eAAe,EAAE;oBACf,WAAW,EAAE,CAAC;iBACf;aACF,EACD,SAAS,EAAE;gBACT,eAAe,EAAE;oBACf,WAAW,EAAE,CAAC;iBACf;aACF,IACF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,CAAC;SACxH;IACH,CAAC;CACF"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { OrderType } from "../types";
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
3
|
-
import LimitOrder, { LimitOrderParams } from "./limit";
|
|
4
|
-
interface StopLimitOrderParams extends LimitOrderParams {
|
|
5
|
-
stopPrice: BigNumber;
|
|
6
|
-
}
|
|
7
|
-
export default class StopLimitOrder extends LimitOrder {
|
|
8
|
-
stopPrice: BigNumber;
|
|
9
|
-
orderType: OrderType;
|
|
10
|
-
constraints(): {
|
|
11
|
-
stopPrice: {
|
|
12
|
-
bigNumericality: {
|
|
13
|
-
greaterThan: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
baseAmount: {
|
|
17
|
-
bigNumericality: {
|
|
18
|
-
greaterThanOrEqualTo: number;
|
|
19
|
-
notGreaterThanOrEqualTo: string;
|
|
20
|
-
lessThanOrEqualTo: any;
|
|
21
|
-
notLessThanOrEqualTo: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
quoteAmount: {
|
|
25
|
-
bigNumericality: {
|
|
26
|
-
greaterThanOrEqualTo: number;
|
|
27
|
-
notGreaterThanOrEqualTo: string;
|
|
28
|
-
lessThanOrEqualTo: any;
|
|
29
|
-
notLessThanOrEqualTo: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
price: {
|
|
33
|
-
bigNumericality: {
|
|
34
|
-
greaterThan: number;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
constructor(params: StopLimitOrderParams);
|
|
39
|
-
updatePrice(price: BigNumber, priceOffset?: number): void;
|
|
40
|
-
updateStopPrice(stopPrice: BigNumber, priceOffset?: number): void;
|
|
41
|
-
}
|
|
42
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { OrderSide, OrderType } from "../types";
|
|
2
|
-
import LimitOrder from "./limit";
|
|
3
|
-
import { safeBigNumber } from "../util";
|
|
4
|
-
export default class StopLimitOrder extends LimitOrder {
|
|
5
|
-
constructor(params) {
|
|
6
|
-
super(params);
|
|
7
|
-
this.orderType = OrderType.STOP_LOSS_LIMIT;
|
|
8
|
-
this.stopPrice = safeBigNumber(params.stopPrice);
|
|
9
|
-
}
|
|
10
|
-
constraints() {
|
|
11
|
-
const limitConstraints = super.constraints();
|
|
12
|
-
return Object.assign(Object.assign({}, limitConstraints), { stopPrice: {
|
|
13
|
-
bigNumericality: {
|
|
14
|
-
greaterThan: 0,
|
|
15
|
-
}
|
|
16
|
-
} });
|
|
17
|
-
}
|
|
18
|
-
updatePrice(price, priceOffset = 0.05) {
|
|
19
|
-
super.updatePrice(price);
|
|
20
|
-
if (price && this.stopPrice.eq(0)) {
|
|
21
|
-
const offset = this.side === OrderSide.BUY ? 1 - priceOffset : 1 + priceOffset;
|
|
22
|
-
this.stopPrice = price.multipliedBy(offset).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
updateStopPrice(stopPrice, priceOffset = 0.05) {
|
|
26
|
-
this.stopPrice = stopPrice.decimalPlaces(this.precisionPrice);
|
|
27
|
-
if (stopPrice && this.price.eq(0)) {
|
|
28
|
-
const offset = this.side === OrderSide.BUY ? 1 + priceOffset : 1 - priceOffset;
|
|
29
|
-
this.price = stopPrice.multipliedBy(offset).decimalPlaces(this.precisionPrice > 0 ? this.precisionPrice : 0);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=stop-limit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop-limit.js","sourceRoot":"","sources":["../../lib/orders/stop-limit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAE9C,OAAO,UAA8B,MAAM,SAAS,CAAC;AACrD,OAAO,EAAC,aAAa,EAAY,MAAM,SA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AC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;YAC/E,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;SAC7G;IACH,CAAC;CACF"}
|
package/dist/orders/validate.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import validate from "validate.js";
|
|
2
|
-
validate.validators.bigNumericality = (value, options, key, attributes) => {
|
|
3
|
-
return validate.validators.numericality(value ? value.toNumber() : value, options, attributes);
|
|
4
|
-
};
|
|
5
|
-
export default validate;
|
|
6
|
-
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../lib/orders/validate.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,QAAQ,CAAC,UAAU,CAAC,eAAe,GAAG,CAAC,KAAU,EAAE,OAAY,EAAE,GAAW,EAAE,UAAkB,EAAE,EAAE;IAClG,OAAO,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;AAChG,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAA"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
|
-
import Market from "./market";
|
|
3
|
-
export interface MarketParam {
|
|
4
|
-
coinraySymbol: string;
|
|
5
|
-
}
|
|
6
|
-
export interface Candle {
|
|
7
|
-
time: Date;
|
|
8
|
-
open: number;
|
|
9
|
-
high: number;
|
|
10
|
-
low: number;
|
|
11
|
-
close: number;
|
|
12
|
-
baseVolume: number;
|
|
13
|
-
quoteVolume: number;
|
|
14
|
-
numTrades: number;
|
|
15
|
-
skipVolume?: Boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface CandleParam {
|
|
18
|
-
coinraySymbol: string;
|
|
19
|
-
resolution: string;
|
|
20
|
-
lastCandle?: Candle;
|
|
21
|
-
}
|
|
22
|
-
export interface CandlesParam {
|
|
23
|
-
coinraySymbol: string;
|
|
24
|
-
resolution: string;
|
|
25
|
-
start?: number;
|
|
26
|
-
end?: number;
|
|
27
|
-
useWebSocket?: boolean;
|
|
28
|
-
}
|
|
29
|
-
export interface MarketMap {
|
|
30
|
-
[key: string]: Market;
|
|
31
|
-
}
|
|
32
|
-
export interface MarketQuery {
|
|
33
|
-
query: string;
|
|
34
|
-
marketProperty: string;
|
|
35
|
-
}
|
|
36
|
-
export interface OrderBookSide {
|
|
37
|
-
[key: string]: number;
|
|
38
|
-
}
|
|
39
|
-
export interface OrderBook {
|
|
40
|
-
minSeq: number;
|
|
41
|
-
maxSeq: number;
|
|
42
|
-
asks: OrderBookSide;
|
|
43
|
-
bids: OrderBookSide;
|
|
44
|
-
}
|
|
45
|
-
export interface Trade {
|
|
46
|
-
id: string;
|
|
47
|
-
time: Date;
|
|
48
|
-
price: number;
|
|
49
|
-
quantity: number;
|
|
50
|
-
type: "sell" | "buy";
|
|
51
|
-
}
|
|
52
|
-
export interface Ticker {
|
|
53
|
-
coinraySymbol: string;
|
|
54
|
-
baseVolume: BigNumber;
|
|
55
|
-
quoteVolume: BigNumber;
|
|
56
|
-
btcVolume: BigNumber;
|
|
57
|
-
usdVolume: BigNumber;
|
|
58
|
-
openPrice24h: BigNumber;
|
|
59
|
-
highPrice24h: BigNumber;
|
|
60
|
-
lowPrice24h: BigNumber;
|
|
61
|
-
openPrice1s: BigNumber;
|
|
62
|
-
highPrice1s: BigNumber;
|
|
63
|
-
lowPrice1s: BigNumber;
|
|
64
|
-
lastPrice: BigNumber;
|
|
65
|
-
askPrice: BigNumber;
|
|
66
|
-
bidPrice: BigNumber;
|
|
67
|
-
}
|
|
68
|
-
export interface TradeList {
|
|
69
|
-
coinraySymbol: string;
|
|
70
|
-
trades: Trade[];
|
|
71
|
-
}
|
|
72
|
-
export declare enum OrderType {
|
|
73
|
-
MARKET = "MARKET",
|
|
74
|
-
LIMIT = "LIMIT",
|
|
75
|
-
LIMIT_LADDER = "LIMIT_LADDER",
|
|
76
|
-
STOP_LOSS = "STOP_LOSS",
|
|
77
|
-
OCO = "OCO",
|
|
78
|
-
STOP_LOSS_LIMIT = "STOP_LOSS_LIMIT",
|
|
79
|
-
STOP_LOSS_MARKET = "STOP_LOSS_MARKET",
|
|
80
|
-
TAKE_PROFIT = "TAKE_PROFIT",
|
|
81
|
-
TAKE_PROFIT_LIMIT = "TAKE_PROFIT_LIMIT",
|
|
82
|
-
TAKE_PROFIT_MARKET = "TAKE_PROFIT_MARKET"
|
|
83
|
-
}
|
|
84
|
-
export declare enum ExchangeFeatures {
|
|
85
|
-
HEDGE_MODE = "hedgeMode",
|
|
86
|
-
ORDER_QUOTE_AMOUNT = "orderQuoteAmount",
|
|
87
|
-
MARKET_BUY_QUOTE_ONLY = "marketBuyQuoteOnly",
|
|
88
|
-
UPDATE_LEVERAGE_ONLY_ON_OPEN_POSITIONS = "updateLeverageOnlyOnOpenPositions",
|
|
89
|
-
FAST_CONNECT = "fastConnect",
|
|
90
|
-
UNIFIED_BALANCE = "unifiedBalance"
|
|
91
|
-
}
|
|
92
|
-
export declare enum IpWhiteList {
|
|
93
|
-
NONE = "NONE",
|
|
94
|
-
LIST = "LIST",
|
|
95
|
-
COMMA = "COMMA",
|
|
96
|
-
COMMA_SPACE = "COMMA_SPACE",
|
|
97
|
-
SPACE = "SPACE"
|
|
98
|
-
}
|
|
99
|
-
export declare enum MarginType {
|
|
100
|
-
CROSSED = "CROSSED",
|
|
101
|
-
ISOLATED = "ISOLATED"
|
|
102
|
-
}
|
|
103
|
-
export declare enum OrderStatus {
|
|
104
|
-
OPEN = "open",
|
|
105
|
-
CLOSED = "closed",
|
|
106
|
-
CANCELED = "canceled"
|
|
107
|
-
}
|
|
108
|
-
export declare enum OrderSide {
|
|
109
|
-
BUY = "buy",
|
|
110
|
-
SELL = "sell"
|
|
111
|
-
}
|
|
112
|
-
export declare enum TimeInForce {
|
|
113
|
-
GTC = "gtc",
|
|
114
|
-
FOK = "fok",
|
|
115
|
-
IOC = "ioc"
|
|
116
|
-
}
|
|
117
|
-
export declare enum BalanceLimit {
|
|
118
|
-
QUOTE = "quote",
|
|
119
|
-
BASE = "base",
|
|
120
|
-
NONE = "none"
|
|
121
|
-
}
|
|
122
|
-
export interface BaseParams {
|
|
123
|
-
encryptedApiKey: string;
|
|
124
|
-
coinraySymbol: string;
|
|
125
|
-
}
|
|
126
|
-
export interface SmartOrderParams {
|
|
127
|
-
credential: string;
|
|
128
|
-
coinraySymbol?: String;
|
|
129
|
-
type?: OrderType;
|
|
130
|
-
side?: OrderSide;
|
|
131
|
-
quantity?: BigNumber;
|
|
132
|
-
price?: BigNumber;
|
|
133
|
-
stopPrice?: BigNumber;
|
|
134
|
-
allowParams?: string[];
|
|
135
|
-
reduceOnly?: boolean;
|
|
136
|
-
postOnly?: boolean;
|
|
137
|
-
timeInForce?: TimeInForce;
|
|
138
|
-
}
|
|
139
|
-
export interface CreateOrderParams extends BaseParams {
|
|
140
|
-
type: OrderType;
|
|
141
|
-
side: OrderSide;
|
|
142
|
-
quantity: BigNumber;
|
|
143
|
-
price?: BigNumber;
|
|
144
|
-
stopPrice?: BigNumber;
|
|
145
|
-
reduceOnly?: boolean;
|
|
146
|
-
postOnly?: boolean;
|
|
147
|
-
timeInForce?: TimeInForce;
|
|
148
|
-
}
|
|
149
|
-
export interface UpdateOrderParams extends BaseParams {
|
|
150
|
-
orderId: string;
|
|
151
|
-
type: OrderType;
|
|
152
|
-
side: OrderSide;
|
|
153
|
-
quantity: BigNumber;
|
|
154
|
-
price?: BigNumber;
|
|
155
|
-
stopPrice?: BigNumber;
|
|
156
|
-
reduceOnly?: boolean;
|
|
157
|
-
postOnly?: boolean;
|
|
158
|
-
timeInForce?: TimeInForce;
|
|
159
|
-
}
|
|
160
|
-
export interface CancelOrderParams extends BaseParams {
|
|
161
|
-
orderType: OrderType;
|
|
162
|
-
orderId: string;
|
|
163
|
-
}
|
|
164
|
-
export interface AccountTestParams extends BaseParams {
|
|
165
|
-
encryptedApiKey: string;
|
|
166
|
-
exchangeCode: string;
|
|
167
|
-
}
|
|
168
|
-
export interface BaseOrderParams {
|
|
169
|
-
externalId?: string;
|
|
170
|
-
coinraySymbol: string;
|
|
171
|
-
precisionBase: number;
|
|
172
|
-
precisionQuote: number;
|
|
173
|
-
precisionPrice: number;
|
|
174
|
-
minBase: BigNumber;
|
|
175
|
-
minQuote: BigNumber;
|
|
176
|
-
makerFee: BigNumber;
|
|
177
|
-
takerFee: BigNumber;
|
|
178
|
-
side: OrderSide;
|
|
179
|
-
balances: MarketBalance;
|
|
180
|
-
balanceLimit?: BalanceLimit;
|
|
181
|
-
reduceOnly?: boolean;
|
|
182
|
-
postOnly?: boolean;
|
|
183
|
-
timeInForce?: TimeInForce;
|
|
184
|
-
}
|
|
185
|
-
export interface Balance {
|
|
186
|
-
currency: string;
|
|
187
|
-
available: BigNumber;
|
|
188
|
-
inOrders: BigNumber;
|
|
189
|
-
total: BigNumber;
|
|
190
|
-
initialMargin?: BigNumber;
|
|
191
|
-
openOrderInitialMargin?: BigNumber;
|
|
192
|
-
positionInitialMargin?: BigNumber;
|
|
193
|
-
unrealizedProfit?: BigNumber;
|
|
194
|
-
crossWalletBalance?: BigNumber;
|
|
195
|
-
crossUnrealizedProfit?: BigNumber;
|
|
196
|
-
}
|
|
197
|
-
export interface MarketBalance {
|
|
198
|
-
[key: string]: Balance;
|
|
199
|
-
base: Balance;
|
|
200
|
-
quote: Balance;
|
|
201
|
-
}
|
|
202
|
-
export interface ApiCache {
|
|
203
|
-
exchanges?: Array<object>;
|
|
204
|
-
markets: {
|
|
205
|
-
[key: string]: Array<object>;
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
export interface CacheParams {
|
|
209
|
-
apiCache: ApiCache;
|
|
210
|
-
onStoreCache: {
|
|
211
|
-
(apiCache: object): void;
|
|
212
|
-
};
|
|
213
|
-
}
|