Skip to content

Commit

Permalink
Release. Bump version number
Browse files Browse the repository at this point in the history
  • Loading branch information
bryaningl3 committed Sep 10, 2023
1 parent 3125d9f commit a54c626
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 42 deletions.
2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Barchart Market Data SDK <small>JavaScript 6.2.0</small>
# Barchart Market Data SDK <small>JavaScript 6.2.1</small>

> Inject real-time market data into your JavaScript applications
Expand Down
12 changes: 6 additions & 6 deletions example/browser/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5312,7 +5312,7 @@ module.exports = (() => {
'use strict';

return {
version: '6.2.0'
version: '6.2.1'
};
})();

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module.exports = (() => {
'use strict';

return {
version: '6.2.0'
version: '6.2.1'
};
})();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
76 changes: 43 additions & 33 deletions test/dist/barchart-marketdata-api-tests-6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
});
});
Expand Down

0 comments on commit a54c626

Please sign in to comment.