UNPKG

@thoshpathi/utils-smartapi

Version:

Extended utilities for Angel One's smartapi-javascript SDK, including custom methods and helpers for market data like candles, P&L, and more.

50 lines (48 loc) 1.65 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/smartapi/ohlc_data.ts var ohlc_data_exports = {}; __export(ohlc_data_exports, { OHLCData: () => OHLCData, default: () => OHLCData }); module.exports = __toCommonJS(ohlc_data_exports); var OHLCData = class { constructor(date, open, high, low, close) { const parsedDate = new Date(date); if (isNaN(parsedDate.getTime())) { throw new Error("Invalid date"); } if ([open, high, low, close].some((value) => isNaN(value))) { throw new Error("Open, High, Low, and Close must be valid numbers"); } if (low > high) { throw new Error("Low cannot be greater than High"); } this.date = parsedDate; this.open = open; this.high = high; this.low = low; this.close = close; } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { OHLCData });