@aurox/ohlcv-helpers
Advanced tools
Comparing version 0.7.1 to 0.8.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./pricePointListToOHLCV"), exports); | ||
(0, tslib_1.__exportStar)(require("./pricePointListToOHLCV"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const avl_1 = tslib_1.__importDefault(require("avl")); | ||
const avl_1 = (0, tslib_1.__importDefault)(require("avl")); | ||
const utils_1 = require("../utils"); | ||
@@ -13,5 +13,5 @@ function pricePointListToOHLCV(list, timeUnit, [rangeStart, rangeEnd], defaultValue = 0) { | ||
} | ||
const timeUnitDuration = utils_1.getTimeUnitDuration(timeUnit); | ||
const startOfInitialTimeUnit = utils_1.startOfTimeUnit(rangeStart, timeUnit); | ||
const startOfFinalTimeUnit = utils_1.startOfTimeUnit(rangeEnd, timeUnit); | ||
const timeUnitDuration = (0, utils_1.getTimeUnitDuration)(timeUnit); | ||
const startOfInitialTimeUnit = (0, utils_1.startOfTimeUnit)(rangeStart, timeUnit); | ||
const startOfFinalTimeUnit = (0, utils_1.startOfTimeUnit)(rangeEnd, timeUnit); | ||
const result = []; | ||
@@ -18,0 +18,0 @@ let previousClose = defaultValue; |
@@ -12,3 +12,3 @@ "use strict"; | ||
if (filler !== null) { | ||
return utils_1.getTimeUnitStartsInRange(range[0], range[1], timeUnit, 'inclusive').map(timeUnitStart => ({ | ||
return (0, utils_1.getTimeUnitStartsInRange)(range[0], range[1], timeUnit, 'inclusive').map(timeUnitStart => ({ | ||
timeUnitStart, | ||
@@ -30,3 +30,3 @@ timeOpen: timeUnitStart, | ||
let lastKnownPriceCursor = lastKnownPrice; | ||
for (const timeUnitStart of utils_1.getTimeUnitStartsInRange(range[0], range[1], timeUnit, 'inclusive')) { | ||
for (const timeUnitStart of (0, utils_1.getTimeUnitStartsInRange)(range[0], range[1], timeUnit, 'inclusive')) { | ||
const existing = mapping.get(timeUnitStart); | ||
@@ -33,0 +33,0 @@ if (existing) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
tslib_1.__exportStar(require("./utils"), exports); | ||
tslib_1.__exportStar(require("./timeUnit"), exports); | ||
tslib_1.__exportStar(require("./OHLCVLiveAggregator"), exports); | ||
tslib_1.__exportStar(require("./reduceOHLCV"), exports); | ||
tslib_1.__exportStar(require("./converters"), exports); | ||
tslib_1.__exportStar(require("./gapFillRange"), exports); | ||
(0, tslib_1.__exportStar)(require("./types"), exports); | ||
(0, tslib_1.__exportStar)(require("./utils"), exports); | ||
(0, tslib_1.__exportStar)(require("./timeUnit"), exports); | ||
(0, tslib_1.__exportStar)(require("./OHLCVLiveAggregator"), exports); | ||
(0, tslib_1.__exportStar)(require("./reduceOHLCV"), exports); | ||
(0, tslib_1.__exportStar)(require("./converters"), exports); | ||
(0, tslib_1.__exportStar)(require("./gapFillRange"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
const tiny_typed_emitter_1 = require("tiny-typed-emitter"); | ||
const avl_1 = tslib_1.__importDefault(require("avl")); | ||
const avl_1 = (0, tslib_1.__importDefault)(require("avl")); | ||
const utils_1 = require("./utils"); | ||
@@ -69,3 +69,3 @@ class OHLCVLiveAggregator extends tiny_typed_emitter_1.TypedEmitter { | ||
if (lastTimeUnitStart !== null && lastPrice !== null) { | ||
const gaps = utils_1.getTimeUnitStartsInRange(lastTimeUnitStart, item.timeUnitStart, this._timeUnit, 'exclusive'); | ||
const gaps = (0, utils_1.getTimeUnitStartsInRange)(lastTimeUnitStart, item.timeUnitStart, this._timeUnit, 'exclusive'); | ||
for (const gap of gaps) { | ||
@@ -89,6 +89,6 @@ result.push({ | ||
}); | ||
const currentTimeUnitStart = utils_1.startOfTimeUnit(Date.now(), this._timeUnit); | ||
const currentTimeUnitStart = (0, utils_1.startOfTimeUnit)(Date.now(), this._timeUnit); | ||
const last = result[result.length - 1]; | ||
if (last && last.timeUnitStart !== currentTimeUnitStart) { | ||
const gaps = utils_1.getTimeUnitStartsInRange(last.timeUnitStart, currentTimeUnitStart, this._timeUnit); | ||
const gaps = (0, utils_1.getTimeUnitStartsInRange)(last.timeUnitStart, currentTimeUnitStart, this._timeUnit); | ||
for (const gap of gaps) { | ||
@@ -114,7 +114,9 @@ if (gap !== last.timeUnitStart) { | ||
this.getMostRecentOHLCVItem = () => { | ||
return (this._data.size > 0 && this._data.maxNode().data) || null; | ||
var _a; | ||
return (this._data.size > 0 && ((_a = this._data.maxNode()) === null || _a === void 0 ? void 0 : _a.data)) || null; | ||
}; | ||
this.getCurrentTimeUnitOHLCVItem = () => { | ||
const lastBar = this._data.size > 0 && this._data.maxNode().data; | ||
const currentTimeUnitStart = utils_1.startOfTimeUnit(Date.now(), this._timeUnit); | ||
var _a; | ||
const lastBar = this._data.size > 0 && ((_a = this._data.maxNode()) === null || _a === void 0 ? void 0 : _a.data); | ||
const currentTimeUnitStart = (0, utils_1.startOfTimeUnit)(Date.now(), this._timeUnit); | ||
if (lastBar) { | ||
@@ -152,4 +154,5 @@ if (lastBar.timeUnitStart === currentTimeUnitStart) { | ||
this.getLastKnownClosingPrice = () => { | ||
var _a; | ||
if (this._data.size > 0) { | ||
const lastEntry = this._data.maxNode().data; | ||
const lastEntry = (_a = this._data.maxNode()) === null || _a === void 0 ? void 0 : _a.data; | ||
if (lastEntry) { | ||
@@ -196,3 +199,3 @@ return lastEntry.close; | ||
applyItem(update) { | ||
const targetTimeUnit = utils_1.startOfTimeUnit(update.timeUnitStart, this._timeUnit); | ||
const targetTimeUnit = (0, utils_1.startOfTimeUnit)(update.timeUnitStart, this._timeUnit); | ||
const old = this._data.find(targetTimeUnit); | ||
@@ -199,0 +202,0 @@ let inserted; |
@@ -10,3 +10,3 @@ "use strict"; | ||
if (items.length === 1) { | ||
const _a = items[0], { timeUnitStart: time_unit_start } = _a, result = tslib_1.__rest(_a, ["timeUnitStart"]); | ||
const _a = items[0], { timeUnitStart: time_unit_start } = _a, result = (0, tslib_1.__rest)(_a, ["timeUnitStart"]); | ||
return result; | ||
@@ -13,0 +13,0 @@ } |
@@ -8,1 +8,2 @@ import { OHLCVTimeUnit, OHLCVTimeUnitGranularity } from './types'; | ||
export declare function ohlcvTimeUnitFromString(str: string | undefined | null | false): OHLCVTimeUnit | null; | ||
export declare function convertTimeUnitStringFormat(timeUnitStr: string, toFormat?: OHLCVTimeUnitStringFormats): string | null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ohlcvTimeUnitFromString = exports.ohlcvTimeUnitToDisplayString = exports.ohlcvTimeUnitToString = exports.isOHLCVTimeUnitValid = exports.ohlcvTimeUnitGranularities = void 0; | ||
exports.convertTimeUnitStringFormat = exports.ohlcvTimeUnitFromString = exports.ohlcvTimeUnitToDisplayString = exports.ohlcvTimeUnitToString = exports.isOHLCVTimeUnitValid = exports.ohlcvTimeUnitGranularities = void 0; | ||
exports.ohlcvTimeUnitGranularities = Object.freeze([ | ||
@@ -142,2 +142,7 @@ 'second', | ||
exports.ohlcvTimeUnitFromString = ohlcvTimeUnitFromString; | ||
function convertTimeUnitStringFormat(timeUnitStr, toFormat) { | ||
const timeUnit = timeUnitStr ? ohlcvTimeUnitFromString(timeUnitStr) : null; | ||
return timeUnit ? ohlcvTimeUnitToString(timeUnit, toFormat) : null; | ||
} | ||
exports.convertTimeUnitStringFormat = convertTimeUnitStringFormat; | ||
//# sourceMappingURL=timeUnit.js.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const moment_1 = tslib_1.__importDefault(require("moment")); | ||
const moment_1 = (0, tslib_1.__importDefault)(require("moment")); | ||
function getGranularityDuration(granularity) { | ||
@@ -33,15 +33,15 @@ switch (granularity) { | ||
case 'second': | ||
return moment_1.default(timestamp).utc().startOf('second').valueOf(); | ||
return (0, moment_1.default)(timestamp).utc().startOf('second').valueOf(); | ||
case 'minute': | ||
return moment_1.default(timestamp).utc().startOf('minute').valueOf(); | ||
return (0, moment_1.default)(timestamp).utc().startOf('minute').valueOf(); | ||
case 'hour': | ||
return moment_1.default(timestamp).utc().startOf('hour').valueOf(); | ||
return (0, moment_1.default)(timestamp).utc().startOf('hour').valueOf(); | ||
case 'day': | ||
return moment_1.default(timestamp).utc().startOf('day').valueOf(); | ||
return (0, moment_1.default)(timestamp).utc().startOf('day').valueOf(); | ||
case 'week': | ||
return moment_1.default(timestamp).utc().startOf('isoWeek').valueOf(); | ||
return (0, moment_1.default)(timestamp).utc().startOf('isoWeek').valueOf(); | ||
case 'month': | ||
return moment_1.default(timestamp).utc().startOf('month').valueOf(); | ||
return (0, moment_1.default)(timestamp).utc().startOf('month').valueOf(); | ||
case 'year': | ||
return moment_1.default(timestamp).utc().startOf('year').valueOf(); | ||
return (0, moment_1.default)(timestamp).utc().startOf('year').valueOf(); | ||
} | ||
@@ -48,0 +48,0 @@ } |
{ | ||
"name": "@aurox/ohlcv-helpers", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"description": "", | ||
@@ -21,23 +21,23 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@types/node": "^15.12.2", | ||
"avl": "^1.5.0", | ||
"@types/node": "^17.0.8", | ||
"avl": "^1.5.3", | ||
"moment": "^2.29.1", | ||
"tiny-typed-emitter": "^2.0.3", | ||
"tslib": "^2.2.0" | ||
"tiny-typed-emitter": "^2.1.0", | ||
"tslib": "^2.3.1" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.2.18", | ||
"@types/mocha": "^8.2.2", | ||
"@typescript-eslint/eslint-plugin": "^4.26.1", | ||
"@typescript-eslint/parser": "^4.26.1", | ||
"@types/chai": "^4.3.0", | ||
"@types/mocha": "^9.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.9.0", | ||
"@typescript-eslint/parser": "^5.9.0", | ||
"chai": "^4.3.4", | ||
"eslint": "^7.28.0", | ||
"eslint": "^8.6.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"mocha": "^9.0.0", | ||
"prettier": "^2.3.1", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"mocha": "^9.1.3", | ||
"prettier": "^2.5.1", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.3.2" | ||
"ts-node": "^10.4.0", | ||
"typescript": "^4.5.4" | ||
} | ||
} |
@@ -89,3 +89,3 @@ import { TypedEmitter } from 'tiny-typed-emitter'; | ||
while (this._data.size > 0 && this._data.min() < minimumAllowedTimestamp) { | ||
while (this._data.size > 0 && (this._data.min() as number) < minimumAllowedTimestamp) { | ||
this._data.pop(); | ||
@@ -270,7 +270,7 @@ } | ||
public getMostRecentOHLCVItem = (): OHLCVDataItem | null => { | ||
return (this._data.size > 0 && this._data.maxNode().data) || null; | ||
return (this._data.size > 0 && this._data.maxNode()?.data) || null; | ||
}; | ||
public getCurrentTimeUnitOHLCVItem = (): OHLCVDataItem | null => { | ||
const lastBar = this._data.size > 0 && this._data.maxNode().data; | ||
const lastBar = this._data.size > 0 && this._data.maxNode()?.data; | ||
@@ -312,3 +312,3 @@ const currentTimeUnitStart = startOfTimeUnit(Date.now(), this._timeUnit); | ||
if (this._data.size > 0) { | ||
const lastEntry = this._data.maxNode().data; | ||
const lastEntry = this._data.maxNode()?.data; | ||
@@ -315,0 +315,0 @@ if (lastEntry) { |
@@ -168,1 +168,7 @@ import { OHLCVTimeUnit, OHLCVTimeUnitGranularity } from './types'; | ||
} | ||
export function convertTimeUnitStringFormat(timeUnitStr: string, toFormat?: OHLCVTimeUnitStringFormats) { | ||
const timeUnit = timeUnitStr ? ohlcvTimeUnitFromString(timeUnitStr) : null; | ||
return timeUnit ? ohlcvTimeUnitToString(timeUnit, toFormat) : null; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93383
1684
+ Added@types/node@17.0.45(transitive)
- Removed@types/node@15.14.9(transitive)
Updated@types/node@^17.0.8
Updatedavl@^1.5.3
Updatedtiny-typed-emitter@^2.1.0
Updatedtslib@^2.3.1