@alphapoint/apex-web 5.5.4 → 5.5.5
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/README.md +27 -2
- package/lib/components/FuturesOrderBook/FuturesOrderBookContainer.js +5 -0
- package/lib/components/OrderBookComponents/OrderBookComponent.js +27 -25
- package/lib/components/OrderBookComponents/OrderBookContainer.js +5 -0
- package/lib/components/common/APVerticalScroller/APVerticalScroller.js +8 -5
- package/lib/helpers/orderBook/priceGroupingHelper.js +29 -12
- package/lib/helpers/orderBook/priceGroupingHelper.test.js +50 -35
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
# @alphapoint/apex-web
|
|
2
2
|
|
|
3
|
+
React component library for the AlphaPoint APEX trading platform. It provides
|
|
4
|
+
the trading UI building blocks — exchange, order entry, order book, charts,
|
|
5
|
+
wallets, KYC, account management — together with the Redux store configuration
|
|
6
|
+
and APEX WebSocket API wiring that drive them.
|
|
3
7
|
|
|
4
|
-
|
|
8
|
+
## Installation
|
|
5
9
|
|
|
10
|
+
```bash
|
|
11
|
+
npm install @alphapoint/apex-web
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The library expects these peer dependencies in the host application: `react`
|
|
15
|
+
and `react-dom` (^18), `react-redux`, `redux-thunk`, `i18next`, and
|
|
16
|
+
`react-i18next`. Node 18 or later.
|
|
17
|
+
|
|
18
|
+
## Getting started
|
|
19
|
+
|
|
20
|
+
The supported starting point is the
|
|
21
|
+
[apex-web-example](https://github.com/alphapoint/apex-web-example)
|
|
22
|
+
application: a complete, deployable implementation wired to an APEX backend.
|
|
23
|
+
Fork it, point it at your environment, and customize from there rather than
|
|
24
|
+
assembling an application from this package directly.
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
Proprietary — Copyright (c) AlphaPoint. All rights reserved. Use is permitted
|
|
29
|
+
only under a commercial agreement with [AlphaPoint](https://alphapoint.com).
|
|
30
|
+
See the LICENSE file for details.
|
|
@@ -12,6 +12,7 @@ var _futuresOrderFormActions = require("../../redux/futures/actions/futuresOrder
|
|
|
12
12
|
var _decimalPlacesHelper = require("../../helpers/decimalPlaces/decimalPlacesHelper");
|
|
13
13
|
var _selectors = require("../../redux/futures/selectors");
|
|
14
14
|
var _actions = require("../../redux/futures/actions");
|
|
15
|
+
var _wsHelper = require("../../helpers/wsHelper");
|
|
15
16
|
var _FuturesSpreadRow = require("./FuturesSpreadRow");
|
|
16
17
|
var _config = _interopRequireDefault(require("../../config"));
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -19,6 +20,8 @@ var mapStateToProps = function mapStateToProps(state) {
|
|
|
19
20
|
var _config$TradingLayout, _config$TradingLayout2;
|
|
20
21
|
var selectedInstrument = (0, _selectors.futuresSelectedInstrumentSelector)(state);
|
|
21
22
|
var selectedInstrumentId = selectedInstrument === null || selectedInstrument === void 0 ? void 0 : selectedInstrument.InstrumentId;
|
|
23
|
+
var selectedAccountId = state.user.selectedAccountId;
|
|
24
|
+
var gateway = (0, _wsHelper.getGateway)();
|
|
22
25
|
var decimalPlaces = state.apexCore.product.decimalPlaces;
|
|
23
26
|
var fetching = (0, _futuresOrdersSelectors.futuresLevel2LoadingSelector)(state);
|
|
24
27
|
var filter = {
|
|
@@ -37,6 +40,8 @@ var mapStateToProps = function mapStateToProps(state) {
|
|
|
37
40
|
decimalPlaces: decimalPlaces,
|
|
38
41
|
fetching: fetching,
|
|
39
42
|
selectedInstrumentId: selectedInstrumentId,
|
|
43
|
+
selectedAccountId: selectedAccountId,
|
|
44
|
+
gateway: gateway,
|
|
40
45
|
openOrders: openOrders,
|
|
41
46
|
buyOpenOrders: buyOpenOrders,
|
|
42
47
|
sellOpenOrders: sellOpenOrders,
|
|
@@ -62,7 +62,7 @@ var OrderBookComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
62
62
|
showCenterButton: false,
|
|
63
63
|
// will change to true when user scrolls away from rest position
|
|
64
64
|
viewMode: localStorage.getItem('orderBookViewMode') || 'both',
|
|
65
|
-
grouping: _this.resolveGrouping(props.selectedInstrumentId)
|
|
65
|
+
grouping: _this.resolveGrouping(props.gateway, props.selectedAccountId, props.selectedInstrumentId)
|
|
66
66
|
};
|
|
67
67
|
// event handler bindings
|
|
68
68
|
_this.onClickCenter = _this.onClickCenter.bind(_this);
|
|
@@ -79,12 +79,12 @@ var OrderBookComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
79
79
|
// No instrument-derived default: forcing e.g. 0.01 grouping on a sub-cent instrument
|
|
80
80
|
// would collapse its whole book into a single Price: 0 row, so grouping starts unset
|
|
81
81
|
// (dropdown shows its placeholder) unless the user already picked something for this
|
|
82
|
-
// instrument.
|
|
82
|
+
// server+account+instrument combination.
|
|
83
83
|
_inherits(OrderBookComponent, _React$Component);
|
|
84
84
|
return _createClass(OrderBookComponent, [{
|
|
85
85
|
key: "resolveGrouping",
|
|
86
|
-
value: function resolveGrouping(selectedInstrumentId) {
|
|
87
|
-
return (0, _priceGroupingHelper.getStoredGrouping)(selectedInstrumentId, this.getGroupingOptions());
|
|
86
|
+
value: function resolveGrouping(gateway, selectedAccountId, selectedInstrumentId) {
|
|
87
|
+
return (0, _priceGroupingHelper.getStoredGrouping)(gateway, selectedAccountId, selectedInstrumentId, this.getGroupingOptions());
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// getPriceGroupingOptions returns a fresh options array/objects on every call. render()
|
|
@@ -138,20 +138,21 @@ var OrderBookComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
138
138
|
key: "componentDidUpdate",
|
|
139
139
|
value: function componentDidUpdate(prevProps) {
|
|
140
140
|
var instrumentChanged = this.props.selectedInstrumentId !== prevProps.selectedInstrumentId;
|
|
141
|
+
var accountChanged = this.props.selectedAccountId !== prevProps.selectedAccountId;
|
|
142
|
+
var gatewayChanged = this.props.gateway !== prevProps.gateway;
|
|
141
143
|
|
|
142
|
-
//
|
|
143
|
-
// stored
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
if (instrumentChanged) {
|
|
144
|
+
// On instrument, account, or server change, resolve the newly selected combination's own
|
|
145
|
+
// stored grouping (or unset, if it has none) rather than carrying over the previous
|
|
146
|
+
// combination's state.grouping - that carryover is what read as a bug in QA (e.g. BTCUSD's
|
|
147
|
+
// "10" appearing on ETHUSD, one account's grouping choice leaking into another account
|
|
148
|
+
// trading the same instrument, or a choice made against one server leaking into another
|
|
149
|
+
// server whose account/instrument ids happen to collide). Re-resolving from storage on
|
|
150
|
+
// every switch, not just the first undefined -> id transition on cold load, also restores
|
|
151
|
+
// a value the user picked for this combination earlier in the session (e.g. switching back
|
|
152
|
+
// to LTCUSD after BTCUSD).
|
|
153
|
+
if (instrumentChanged || accountChanged || gatewayChanged) {
|
|
153
154
|
this.setState({
|
|
154
|
-
grouping:
|
|
155
|
+
grouping: this.resolveGrouping(this.props.gateway, this.props.selectedAccountId, this.props.selectedInstrumentId)
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
this.onClickCenter(instrumentChanged);
|
|
@@ -178,19 +179,20 @@ var OrderBookComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
178
179
|
}, {
|
|
179
180
|
key: "handleScrollRestChange",
|
|
180
181
|
value: function handleScrollRestChange() {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
182
|
+
var sellScroller = this.sellScroller.current;
|
|
183
|
+
var buyScroller = this.buyScroller.current;
|
|
184
|
+
// A scroller that is not currently rendered (single buy/sell view mode) is
|
|
185
|
+
// considered at rest so it doesn't force the center button to show.
|
|
186
|
+
var sellIsAtRest = sellScroller ? sellScroller.getIsAtRest() : true;
|
|
187
|
+
var buyIsAtRest = buyScroller ? buyScroller.getIsAtRest() : true;
|
|
188
|
+
this.setState({
|
|
189
|
+
showCenterButton: !sellIsAtRest || !buyIsAtRest
|
|
190
|
+
});
|
|
189
191
|
}
|
|
190
192
|
}, {
|
|
191
193
|
key: "onGroupingChange",
|
|
192
194
|
value: function onGroupingChange(grouping) {
|
|
193
|
-
(0, _priceGroupingHelper.storeGrouping)(this.props.selectedInstrumentId, grouping);
|
|
195
|
+
(0, _priceGroupingHelper.storeGrouping)(this.props.gateway, this.props.selectedAccountId, this.props.selectedInstrumentId, grouping);
|
|
194
196
|
this.setState({
|
|
195
197
|
grouping: grouping
|
|
196
198
|
});
|
|
@@ -13,6 +13,7 @@ var _level2Selectors = require("../../redux/selectors/level2Selectors");
|
|
|
13
13
|
var _instrumentPositionSelectors = require("../../redux/selectors/instrumentPositionSelectors");
|
|
14
14
|
var _orderHistorySelectors = require("../../redux/selectors/orderHistorySelectors");
|
|
15
15
|
var _decimalPlacesHelper = require("../../helpers/decimalPlaces/decimalPlacesHelper");
|
|
16
|
+
var _wsHelper = require("../../helpers/wsHelper");
|
|
16
17
|
var _SpreadRowComponent = _interopRequireDefault(require("./SpreadRowComponent"));
|
|
17
18
|
var _config = _interopRequireDefault(require("../../config"));
|
|
18
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
@@ -22,6 +23,8 @@ var makeMapStateToProps = function makeMapStateToProps() {
|
|
|
22
23
|
var _config$TradingLayout, _config$TradingLayout2;
|
|
23
24
|
var selectedInstrument = (0, _instrumentPositionSelectors.selectedInstrumentSelector)(state);
|
|
24
25
|
var selectedInstrumentId = selectedInstrument.InstrumentId;
|
|
26
|
+
var selectedAccountId = state.user.selectedAccountId;
|
|
27
|
+
var gateway = (0, _wsHelper.getGateway)();
|
|
25
28
|
var fetching = state.apexCore.level2.fetching;
|
|
26
29
|
var decimalPlaces = state.apexCore.product.decimalPlaces;
|
|
27
30
|
var filter = {
|
|
@@ -40,6 +43,8 @@ var makeMapStateToProps = function makeMapStateToProps() {
|
|
|
40
43
|
decimalPlaces: decimalPlaces,
|
|
41
44
|
fetching: fetching,
|
|
42
45
|
selectedInstrumentId: selectedInstrumentId,
|
|
46
|
+
selectedAccountId: selectedAccountId,
|
|
47
|
+
gateway: gateway,
|
|
43
48
|
openOrders: openOrders,
|
|
44
49
|
buyOpenOrders: buyOpenOrders,
|
|
45
50
|
sellOpenOrders: sellOpenOrders,
|
|
@@ -28,6 +28,13 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
28
28
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
29
29
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
30
30
|
var scrollerClasses = (0, _cssClassesHelper.getBEMClasses)('ap-vertical-scroller');
|
|
31
|
+
|
|
32
|
+
// scrollTop/scrollHeight/clientHeight are rounded independently by the browser,
|
|
33
|
+
// so on fractional-DPI displays (e.g. 125%/150% scaling) the resting scroll
|
|
34
|
+
// position can land a couple of pixels off zero. Treat anything within this
|
|
35
|
+
// tolerance as at rest so the order book's center button isn't shown when it's
|
|
36
|
+
// already centered.
|
|
37
|
+
var AT_REST_TOLERANCE = 5;
|
|
31
38
|
var APVerticalScroller = /*#__PURE__*/function (_React$Component) {
|
|
32
39
|
function APVerticalScroller(props) {
|
|
33
40
|
var _this;
|
|
@@ -105,11 +112,7 @@ var APVerticalScroller = /*#__PURE__*/function (_React$Component) {
|
|
|
105
112
|
var scrollTop = newScroll;
|
|
106
113
|
var scrollBottom = scrollHeight - clientHeight - newScroll;
|
|
107
114
|
var isAtRestPrev = this.state.isAtRest;
|
|
108
|
-
|
|
109
|
-
// Without it the bottom-rest side rarely reports exactly <= 0, so it reads as
|
|
110
|
-
// "not at rest" even when visually pinned and the Center button never hides.
|
|
111
|
-
var REST_TOLERANCE = 2;
|
|
112
|
-
var isAtRest = this.props.restPosition === 'top' && scrollTop <= REST_TOLERANCE || this.props.restPosition === 'bottom' && scrollBottom <= REST_TOLERANCE;
|
|
115
|
+
var isAtRest = this.props.restPosition === 'top' && scrollTop <= AT_REST_TOLERANCE || this.props.restPosition === 'bottom' && scrollBottom <= AT_REST_TOLERANCE;
|
|
113
116
|
this.setState({
|
|
114
117
|
isAtRest: isAtRest
|
|
115
118
|
});
|
|
@@ -55,12 +55,21 @@ var isValidGroupingOption = exports.isValidGroupingOption = function isValidGrou
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* Every instrument's grouping lives in a single localStorage
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
58
|
+
* Every server+account+instrument combination's grouping lives in a single localStorage
|
|
59
|
+
* record, keyed by `"<server>:<accountId>:<instrumentId>"`:
|
|
60
|
+
* `{"wss://api.qa-current.apstage.net/WSGateway:1:10":"10","wss://api.qa-next.apstage.net/WSGateway:1:10":"1"}`.
|
|
61
|
+
* One record rather than a key per combination keeps the whole preference readable/clearable
|
|
62
|
+
* in one place instead of accumulating an unbounded number of `orderBookGrouping:<id>` entries
|
|
63
|
+
* as the user visits instruments, switches accounts, and switches servers. Scoping by server as
|
|
64
|
+
* well as account keeps one backend's (or account's) grouping choice for an instrument from
|
|
65
|
+
* leaking into another backend (or account) trading an instrument with the same id - account
|
|
66
|
+
* and instrument ids are backend-assigned and aren't guaranteed to mean the same thing across
|
|
67
|
+
* servers (e.g. qa-current vs qa-next).
|
|
62
68
|
*/
|
|
63
69
|
var GROUPING_STORAGE_KEY = exports.GROUPING_STORAGE_KEY = 'orderBookGrouping';
|
|
70
|
+
var storageKey = function storageKey(server, accountId, instrumentId) {
|
|
71
|
+
return "".concat(server, ":").concat(accountId, ":").concat(instrumentId);
|
|
72
|
+
};
|
|
64
73
|
|
|
65
74
|
// Anything unparseable or not a plain object (a stale value from another format, a user
|
|
66
75
|
// editing localStorage by hand) is treated as "nothing stored" rather than throwing on read.
|
|
@@ -72,28 +81,36 @@ var readStoredGroupings = function readStoredGroupings() {
|
|
|
72
81
|
return {};
|
|
73
82
|
}
|
|
74
83
|
};
|
|
84
|
+
var isMissing = function isMissing(value) {
|
|
85
|
+
return value === undefined || value === null;
|
|
86
|
+
};
|
|
75
87
|
|
|
76
88
|
/**
|
|
89
|
+
* @param {String} server gateway URL of the connected backend
|
|
90
|
+
* @param {Number} accountId
|
|
77
91
|
* @param {Number} instrumentId
|
|
78
92
|
* @param {Array<{value: String, label: String}>} options currently offered options
|
|
79
93
|
* @returns {String|undefined} the stored grouping, or undefined when nothing valid is stored
|
|
80
94
|
*/
|
|
81
|
-
var getStoredGrouping = exports.getStoredGrouping = function getStoredGrouping(instrumentId, options) {
|
|
82
|
-
|
|
95
|
+
var getStoredGrouping = exports.getStoredGrouping = function getStoredGrouping(server, accountId, instrumentId, options) {
|
|
96
|
+
if (isMissing(server) || isMissing(accountId) || isMissing(instrumentId)) return undefined;
|
|
97
|
+
var stored = readStoredGroupings()[storageKey(server, accountId, instrumentId)];
|
|
83
98
|
return stored && isValidGroupingOption(stored, options) ? stored : undefined;
|
|
84
99
|
};
|
|
85
100
|
|
|
86
101
|
/**
|
|
87
|
-
* Merges one instrument's grouping into the shared record, leaving
|
|
88
|
-
*
|
|
89
|
-
*
|
|
102
|
+
* Merges one server+account+instrument combination's grouping into the shared record, leaving
|
|
103
|
+
* every other combination's entry untouched. No-ops without a server, account, and instrument
|
|
104
|
+
* id so a selection made before all three resolve can't leave an "undefined" entry behind.
|
|
90
105
|
*
|
|
106
|
+
* @param {String} server gateway URL of the connected backend
|
|
107
|
+
* @param {Number} accountId
|
|
91
108
|
* @param {Number} instrumentId
|
|
92
109
|
* @param {String} grouping
|
|
93
110
|
*/
|
|
94
|
-
var storeGrouping = exports.storeGrouping = function storeGrouping(instrumentId, grouping) {
|
|
95
|
-
if (
|
|
96
|
-
localStorage.setItem(GROUPING_STORAGE_KEY, JSON.stringify(_objectSpread(_objectSpread({}, readStoredGroupings()), {}, _defineProperty({}, instrumentId, grouping))));
|
|
111
|
+
var storeGrouping = exports.storeGrouping = function storeGrouping(server, accountId, instrumentId, grouping) {
|
|
112
|
+
if (isMissing(server) || isMissing(accountId) || isMissing(instrumentId)) return;
|
|
113
|
+
localStorage.setItem(GROUPING_STORAGE_KEY, JSON.stringify(_objectSpread(_objectSpread({}, readStoredGroupings()), {}, _defineProperty({}, storageKey(server, accountId, instrumentId), grouping))));
|
|
97
114
|
};
|
|
98
115
|
|
|
99
116
|
/**
|
|
@@ -59,57 +59,72 @@ describe('priceGroupingHelper', function () {
|
|
|
59
59
|
});
|
|
60
60
|
describe('stored grouping', function () {
|
|
61
61
|
var options = (0, _priceGroupingHelper.getPriceGroupingOptions)(t);
|
|
62
|
+
var serverA = 'wss://api.qa-current.apstage.net/WSGateway';
|
|
63
|
+
var serverB = 'wss://api.qa-next.apstage.net/WSGateway';
|
|
62
64
|
beforeEach(function () {
|
|
63
65
|
return localStorage.clear();
|
|
64
66
|
});
|
|
65
|
-
it('keeps every instrument in a single record', function () {
|
|
66
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
67
|
-
(0, _priceGroupingHelper.storeGrouping)(
|
|
68
|
-
expect(JSON.parse(localStorage.getItem(_priceGroupingHelper.GROUPING_STORAGE_KEY))).toEqual({
|
|
69
|
-
1: '10',
|
|
70
|
-
2: '0.1'
|
|
71
|
-
});
|
|
67
|
+
it('keeps every server+account+instrument combination in a single record', function () {
|
|
68
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
69
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 11, '0.1');
|
|
70
|
+
expect(JSON.parse(localStorage.getItem(_priceGroupingHelper.GROUPING_STORAGE_KEY))).toEqual(_defineProperty(_defineProperty({}, "".concat(serverA, ":1:10"), '10'), "".concat(serverA, ":1:11"), '0.1'));
|
|
72
71
|
expect(localStorage.length).toBe(1);
|
|
73
72
|
});
|
|
74
|
-
it("reads back
|
|
75
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
76
|
-
(0, _priceGroupingHelper.storeGrouping)(
|
|
77
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBe('10');
|
|
78
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(
|
|
79
|
-
});
|
|
80
|
-
it('overwrites one
|
|
81
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
82
|
-
(0, _priceGroupingHelper.storeGrouping)(
|
|
83
|
-
(0, _priceGroupingHelper.storeGrouping)(1, _priceGroupingHelper.NONE_GROUPING_VALUE);
|
|
84
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBe(_priceGroupingHelper.NONE_GROUPING_VALUE);
|
|
85
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(
|
|
86
|
-
});
|
|
87
|
-
it('
|
|
88
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
89
|
-
|
|
90
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(
|
|
73
|
+
it("reads back a combination's own value", function () {
|
|
74
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
75
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 11, '0.1');
|
|
76
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe('10');
|
|
77
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 11, options)).toBe('0.1');
|
|
78
|
+
});
|
|
79
|
+
it('overwrites one combination without disturbing the others', function () {
|
|
80
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
81
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 11, '0.1');
|
|
82
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, _priceGroupingHelper.NONE_GROUPING_VALUE);
|
|
83
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe(_priceGroupingHelper.NONE_GROUPING_VALUE);
|
|
84
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 11, options)).toBe('0.1');
|
|
85
|
+
});
|
|
86
|
+
it('keeps different accounts trading the same instrument separate', function () {
|
|
87
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
88
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 2, 10, '0.1');
|
|
89
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe('10');
|
|
90
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 2, 10, options)).toBe('0.1');
|
|
91
|
+
});
|
|
92
|
+
it('keeps different servers with colliding account/instrument ids separate', function () {
|
|
93
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
94
|
+
(0, _priceGroupingHelper.storeGrouping)(serverB, 1, 10, '0.1');
|
|
95
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe('10');
|
|
96
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverB, 1, 10, options)).toBe('0.1');
|
|
97
|
+
});
|
|
98
|
+
it('returns undefined for a combination with nothing stored', function () {
|
|
99
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
100
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 99, options)).toBeUndefined();
|
|
101
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 99, 10, options)).toBeUndefined();
|
|
102
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverB, 1, 10, options)).toBeUndefined();
|
|
103
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(undefined, 1, 10, options)).toBeUndefined();
|
|
104
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, undefined, 10, options)).toBeUndefined();
|
|
105
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, undefined, options)).toBeUndefined();
|
|
91
106
|
});
|
|
92
107
|
it('returns undefined when the stored value is no longer an offered option', function () {
|
|
93
|
-
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, JSON.stringify({
|
|
94
|
-
|
|
95
|
-
}));
|
|
96
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBeUndefined();
|
|
108
|
+
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, JSON.stringify(_defineProperty({}, "".concat(serverA, ":1:10"), '0.00000001')));
|
|
109
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBeUndefined();
|
|
97
110
|
});
|
|
98
111
|
it('treats an unusable record as nothing stored instead of throwing', function () {
|
|
99
112
|
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, 'not json');
|
|
100
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBeUndefined();
|
|
113
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBeUndefined();
|
|
101
114
|
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, JSON.stringify(['10']));
|
|
102
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBeUndefined();
|
|
115
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBeUndefined();
|
|
103
116
|
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, JSON.stringify(null));
|
|
104
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBeUndefined();
|
|
117
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBeUndefined();
|
|
105
118
|
});
|
|
106
119
|
it('recovers from an unusable record on the next write', function () {
|
|
107
120
|
localStorage.setItem(_priceGroupingHelper.GROUPING_STORAGE_KEY, 'not json');
|
|
108
|
-
(0, _priceGroupingHelper.storeGrouping)(1, '10');
|
|
109
|
-
expect((0, _priceGroupingHelper.getStoredGrouping)(1, options)).toBe('10');
|
|
121
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, 10, '10');
|
|
122
|
+
expect((0, _priceGroupingHelper.getStoredGrouping)(serverA, 1, 10, options)).toBe('10');
|
|
110
123
|
});
|
|
111
|
-
it('does not store an entry when there is no instrument id yet', function () {
|
|
112
|
-
(0, _priceGroupingHelper.storeGrouping)(undefined, '10');
|
|
124
|
+
it('does not store an entry when there is no server, account, or instrument id yet', function () {
|
|
125
|
+
(0, _priceGroupingHelper.storeGrouping)(undefined, 1, 10, '10');
|
|
126
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, undefined, 10, '10');
|
|
127
|
+
(0, _priceGroupingHelper.storeGrouping)(serverA, 1, undefined, '10');
|
|
113
128
|
expect(localStorage.getItem(_priceGroupingHelper.GROUPING_STORAGE_KEY)).toBeNull();
|
|
114
129
|
});
|
|
115
130
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alphapoint/apex-web",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.5",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"node": ">=18.0.0"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@alphapoint/apex-chart-react": "^5.5.
|
|
12
|
+
"@alphapoint/apex-chart-react": "^5.5.5",
|
|
13
13
|
"@dnd-kit/core": "^6.1.0",
|
|
14
14
|
"@dnd-kit/modifiers": "^7.0.0",
|
|
15
15
|
"@dnd-kit/sortable": "^8.0.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"@babel/runtime": "^7.23.4",
|
|
70
70
|
"cross-env": "^7.0.3",
|
|
71
71
|
"enzyme": "^3.11.0",
|
|
72
|
-
"eslint-config-apex": "^5.5.
|
|
72
|
+
"eslint-config-apex": "^5.5.5",
|
|
73
73
|
"fs-extra": "^11.1.1",
|
|
74
74
|
"lint-staged": "^15.2.0",
|
|
75
75
|
"react": "^18.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"files": [
|
|
118
118
|
"lib"
|
|
119
119
|
],
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "8a0620cee361f365dc2ad192c39056291eb397a6"
|
|
121
121
|
}
|