From a54c626c41fd31dd55a82ca4a909528f8a615560 Mon Sep 17 00:00:00 2001 From: Bryan Ingle Date: Sun, 10 Sep 2023 16:01:59 -0600 Subject: [PATCH] Release. Bump version number --- docs/_coverpage.md | 2 +- example/browser/example.js | 12 ++-- lib/meta.js | 2 +- package.json | 2 +- test/dist/barchart-marketdata-api-tests-6.js | 76 +++++++++++--------- 5 files changed, 52 insertions(+), 42 deletions(-) diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 043e9be..b2bf946 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,4 +1,4 @@ -# Barchart Market Data SDK JavaScript 6.2.0 +# Barchart Market Data SDK JavaScript 6.2.1 > Inject real-time market data into your JavaScript applications diff --git a/example/browser/example.js b/example/browser/example.js index 77c65f8..0e4000e 100644 --- a/example/browser/example.js +++ b/example/browser/example.js @@ -5312,7 +5312,7 @@ module.exports = (() => { 'use strict'; return { - version: '6.2.0' + version: '6.2.1' }; })(); @@ -5770,15 +5770,15 @@ module.exports = (() => { /** * Rounds a value to the nearest valid tick. * - * @param {Number|Decimal} value - * @param {Number} tickIncrement - * @param {Boolean=} roundToZero + * @param {Number|Decimal} value - The price to round. + * @param {Number|Decimal} minimumTick - The minimum tick size (see {@link UnitCode#getMinimumTick}) + * @param {Boolean=} roundToZero - When true, the rounding will always go towards zero. * @returns {Number} */ - roundToNearestTick(value, tickIncrement, roundToZero) { + roundToNearestTick(value, minimumTick, roundToZero) { assert.argumentIsValid(value, 'value', x => is.number(x) || x instanceof Decimal, 'must be a number primitive or a Decimal instance'); + assert.argumentIsValid(minimumTick, 'minimumTick', x => is.number(x) || x instanceof Decimal, 'must be a number primitive or a Decimal instance'); assert.argumentIsOptional(roundToZero, 'roundToZero', Boolean); - const minimumTick = this.getMinimumTick(tickIncrement); let valueToUse; if (value instanceof Decimal) { valueToUse = value; diff --git a/lib/meta.js b/lib/meta.js index d5600db..6ce86dc 100644 --- a/lib/meta.js +++ b/lib/meta.js @@ -2,6 +2,6 @@ module.exports = (() => { 'use strict'; return { - version: '6.2.0' + version: '6.2.1' }; })(); \ No newline at end of file diff --git a/package.json b/package.json index 1bb0112..bd1fe6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@barchart/marketdata-api-js", - "version": "6.2.0", + "version": "6.2.1", "description": "SDK for streaming market data from Barchart.com", "author": { "name": "Eero Pikat", diff --git a/test/dist/barchart-marketdata-api-tests-6.js b/test/dist/barchart-marketdata-api-tests-6.js index c9c9b93..7fb639b 100644 --- a/test/dist/barchart-marketdata-api-tests-6.js +++ b/test/dist/barchart-marketdata-api-tests-6.js @@ -1239,15 +1239,15 @@ module.exports = (() => { /** * Rounds a value to the nearest valid tick. * - * @param {Number|Decimal} value - * @param {Number} tickIncrement - * @param {Boolean=} roundToZero + * @param {Number|Decimal} value - The price to round. + * @param {Number|Decimal} minimumTick - The minimum tick size (see {@link UnitCode#getMinimumTick}) + * @param {Boolean=} roundToZero - When true, the rounding will always go towards zero. * @returns {Number} */ - roundToNearestTick(value, tickIncrement, roundToZero) { + roundToNearestTick(value, minimumTick, roundToZero) { assert.argumentIsValid(value, 'value', x => is.number(x) || x instanceof Decimal, 'must be a number primitive or a Decimal instance'); + assert.argumentIsValid(minimumTick, 'minimumTick', x => is.number(x) || x instanceof Decimal, 'must be a number primitive or a Decimal instance'); assert.argumentIsOptional(roundToZero, 'roundToZero', Boolean); - const minimumTick = this.getMinimumTick(tickIncrement); let valueToUse; if (value instanceof Decimal) { valueToUse = value; @@ -11450,116 +11450,126 @@ describe('When calculating minimum ticks and minimum tick values', () => { describe('When rounding a value to the nearest tick value', () => { describe('For unit code "2" and with a tickIncrement of 2 (e.g. corn)', () => { let uc; + let mt; beforeEach(() => { uc = UnitCode.parse('2'); + mt = uc.getMinimumTick(2); }); it('A value of 0 should be rounded to 0', () => { - expect(uc.roundToNearestTick(0, 2)).toEqual(0); + expect(uc.roundToNearestTick(0, mt)).toEqual(0); }); it('A value of 488.5 should be rounded to 488.5', () => { - expect(uc.roundToNearestTick(488.5, 2)).toEqual(488.5); + expect(uc.roundToNearestTick(488.5, mt)).toEqual(488.5); }); it('A value of 488.51 should be rounded to 488.5', () => { - expect(uc.roundToNearestTick(488.51, 2)).toEqual(488.5); + expect(uc.roundToNearestTick(488.51, mt)).toEqual(488.5); }); it('A value of 488.74 should be rounded to 488.75', () => { - expect(uc.roundToNearestTick(488.74, 2)).toEqual(488.75); + expect(uc.roundToNearestTick(488.74, mt)).toEqual(488.75); }); it('A value of 488.625 should be rounded to 488.75', () => { - expect(uc.roundToNearestTick(488.625, 2)).toEqual(488.75); + expect(uc.roundToNearestTick(488.625, mt)).toEqual(488.75); }); it('A value of 488.625 should be rounded to 488.5 (when using "roundDown" option)', () => { - expect(uc.roundToNearestTick(488.625, 2, true)).toEqual(488.5); + expect(uc.roundToNearestTick(488.625, mt, true)).toEqual(488.5); }); }); describe('For unit code "A" and with a tickIncrement of 25 (e.g. e-mini)', () => { let uc; + let mt; beforeEach(() => { uc = UnitCode.parse('A'); + mt = uc.getMinimumTick(25); }); it('A value of 4455.5 should be rounded to 4455.5', () => { - expect(uc.roundToNearestTick(4455.5, 25)).toEqual(4455.5); + expect(uc.roundToNearestTick(4455.5, mt)).toEqual(4455.5); }); it('A value of 4455.51 should be rounded to 4455.5', () => { - expect(uc.roundToNearestTick(4455.51, 25)).toEqual(4455.5); + expect(uc.roundToNearestTick(4455.51, mt)).toEqual(4455.5); }); it('A value of 4455.74 should be rounded to 4455.75', () => { - expect(uc.roundToNearestTick(4455.74, 25)).toEqual(4455.75); + expect(uc.roundToNearestTick(4455.74, mt)).toEqual(4455.75); }); it('A value of 4455.625 should be rounded to 4455.75', () => { - expect(uc.roundToNearestTick(4455.625, 25)).toEqual(4455.75); + expect(uc.roundToNearestTick(4455.625, mt)).toEqual(4455.75); }); it('A value of 4455.625 should be rounded to 4455.5 (when using "roundDown" option)', () => { - expect(uc.roundToNearestTick(4455.625, 25, true)).toEqual(4455.5); + expect(uc.roundToNearestTick(4455.625, mt, true)).toEqual(4455.5); }); }); describe('For unit code "A" and with a tickIncrement of 1 (e.g. crude)', () => { let uc; + let mt; beforeEach(() => { uc = UnitCode.parse('A'); + mt = uc.getMinimumTick(1); }); it('A value of 87.30 should be rounded to 87.30', () => { - expect(uc.roundToNearestTick(87.30, 1)).toEqual(87.30); + expect(uc.roundToNearestTick(87.30, mt)).toEqual(87.30); }); it('A value of 87.31 should be rounded to 87.31', () => { - expect(uc.roundToNearestTick(87.31, 1)).toEqual(87.31); + expect(uc.roundToNearestTick(87.31, mt)).toEqual(87.31); }); it('A value of 87.312 should be rounded to 87.31', () => { - expect(uc.roundToNearestTick(87.312, 1)).toEqual(87.31); + expect(uc.roundToNearestTick(87.312, mt)).toEqual(87.31); }); it('A value of 87.318 should be rounded to 87.32', () => { - expect(uc.roundToNearestTick(87.318, 1)).toEqual(87.32); + expect(uc.roundToNearestTick(87.318, mt)).toEqual(87.32); }); it('A value of 87.325 should be rounded to 87.33', () => { - expect(uc.roundToNearestTick(87.325, 1)).toEqual(87.33); + expect(uc.roundToNearestTick(87.325, mt)).toEqual(87.33); }); it('A value of 87.325 should be rounded to 87.32 (when using "roundDown" option)', () => { - expect(uc.roundToNearestTick(87.325, 1, true)).toEqual(87.32); + expect(uc.roundToNearestTick(87.325, mt, true)).toEqual(87.32); }); }); describe('For unit code "9" and with a tickIncrement of 1 (e.g. gold)', () => { let uc; + let mt; beforeEach(() => { uc = UnitCode.parse('9'); + mt = uc.getMinimumTick(1); }); it('A value of 1922.5 should be rounded to 1922.5', () => { - expect(uc.roundToNearestTick(1922.5, 1)).toEqual(1922.5); + expect(uc.roundToNearestTick(1922.5, mt)).toEqual(1922.5); }); it('A value of 1922.6 should be rounded to 1922.6', () => { - expect(uc.roundToNearestTick(1922.6, 1)).toEqual(1922.6); + expect(uc.roundToNearestTick(1922.6, mt)).toEqual(1922.6); }); it('A value of 1922.51 should be rounded to 1922.5', () => { - expect(uc.roundToNearestTick(1922.51, 1)).toEqual(1922.5); + expect(uc.roundToNearestTick(1922.51, mt)).toEqual(1922.5); }); it('A value of 1922.59 should be rounded to 1922.6', () => { - expect(uc.roundToNearestTick(1922.59, 1)).toEqual(1922.6); + expect(uc.roundToNearestTick(1922.59, mt)).toEqual(1922.6); }); it('A value of 1922.55 should be rounded to 1922.6', () => { - expect(uc.roundToNearestTick(1922.55, 1)).toEqual(1922.6); + expect(uc.roundToNearestTick(1922.55, mt)).toEqual(1922.6); }); it('A value of 1922.55 should be rounded to 1922.5 (when using "roundDown" option)', () => { - expect(uc.roundToNearestTick(1922.55, 1, true)).toEqual(1922.5); + expect(uc.roundToNearestTick(1922.55, mt, true)).toEqual(1922.5); }); }); describe('For unit code "5" and with a tickIncrement of 1 (e.g. t-notes)', () => { let uc; + let mt; beforeEach(() => { uc = UnitCode.parse('5'); + mt = uc.getMinimumTick(1); }); it('A value of 110.328125 should be rounded to 110.328125', () => { - expect(uc.roundToNearestTick(110.328125, 1)).toEqual(110.328125); + expect(uc.roundToNearestTick(110.328125, mt)).toEqual(110.328125); }); it('A value of 110.34375 should be rounded to 110.34375', () => { - expect(uc.roundToNearestTick(110.34375, 1)).toEqual(110.34375); + expect(uc.roundToNearestTick(110.34375, mt)).toEqual(110.34375); }); it('A value of 110.328126 should be rounded to 110.328125', () => { - expect(uc.roundToNearestTick(110.328126, 1)).toEqual(110.328125); + expect(uc.roundToNearestTick(110.328126, mt)).toEqual(110.328125); }); it('A value of 110.34374 should be rounded to 110.34375', () => { - expect(uc.roundToNearestTick(110.34374, 1)).toEqual(110.34375); + expect(uc.roundToNearestTick(110.34374, mt)).toEqual(110.34375); }); it('A value of 110.34374 should be rounded to 110.328125 (when using "roundDown" option)', () => { - expect(uc.roundToNearestTick(110.34374, 1, true)).toEqual(110.328125); + expect(uc.roundToNearestTick(110.34374, mt, true)).toEqual(110.328125); }); }); });