@orderly.network/ui-tradingview
Version:
1,150 lines (1,141 loc) • 164 kB
JavaScript
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React3 = require('react');
var i18n = require('@orderly.network/i18n');
var ui = require('@orderly.network/ui');
var hooks = require('@orderly.network/hooks');
var types = require('@orderly.network/types');
var utils = require('@orderly.network/utils');
var dateFns = require('date-fns');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var React3__default = /*#__PURE__*/_interopDefault(React3);
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var CaretIcon, DisplaySettingIcon, IndicatorsIcon, SettingIcon, BarIcon, CandlesIcon, HollowCandlesIcon, LineIcon, AreaIcon, BaseLineIcon, UnSelectIcon, SelectedIcon;
var init_icons = __esm({
"src/icons/index.tsx"() {
CaretIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 12 12",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Caret-down", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Vector",
d: "M3.00349 3.9978C2.59149 3.9978 2.36564 4.4653 2.61289 4.7948C2.98789 5.2948 5.23784 8.29479 5.61289 8.79479C5.81289 9.06128 6.20974 9.06128 6.40974 8.79479L9.40974 4.7948C9.65694 4.4653 9.41554 3.9978 9.00349 3.9978H3.00349Z"
}
) })
}
);
DisplaySettingIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 18 18",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Display settings", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Union",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M15.0571 10.9856L11.6295 5.06523L8.71377 10.8968C8.38933 11.5456 7.54464 11.7223 6.98733 11.2579L5.75311 10.2294L2.83709 14.7654L1.57532 13.9543L4.49134 9.41824C4.97892 8.65978 6.0207 8.49981 6.71338 9.07705L7.58387 9.80246L10.5991 3.77192C10.9997 2.97082 12.1302 2.93624 12.579 3.71137L14.6517 7.29147C14.7714 7.03643 15.0305 6.85983 15.3309 6.85983C15.7451 6.85983 16.0809 7.19562 16.0809 7.60983C16.0809 8.02405 15.7451 8.35983 15.3309 8.35983C15.31 8.35983 15.2892 8.35897 15.2687 8.35729L16.3553 10.2341L15.0571 10.9856ZM2.58093 6.85983C2.16672 6.85983 1.83093 7.19562 1.83093 7.60983C1.83093 8.02405 2.16672 8.35983 2.58093 8.35983C2.99515 8.35983 3.33093 8.02405 3.33093 7.60983C3.33093 7.19562 2.99515 6.85983 2.58093 6.85983ZM4.83093 6.85983C4.41672 6.85983 4.08093 7.19562 4.08093 7.60983C4.08093 8.02405 4.41672 8.35983 4.83093 8.35983C5.24515 8.35983 5.58093 8.02405 5.58093 7.60983C5.58093 7.19562 5.24515 6.85983 4.83093 6.85983ZM6.33093 7.60983C6.33093 7.19562 6.66672 6.85983 7.08093 6.85983C7.49515 6.85983 7.83093 7.19562 7.83093 7.60983C7.83093 8.02405 7.49515 8.35983 7.08093 8.35983C6.66672 8.35983 6.33093 8.02405 6.33093 7.60983ZM11.5809 6.85983C11.1667 6.85983 10.8309 7.19562 10.8309 7.60983C10.8309 8.02405 11.1667 8.35983 11.5809 8.35983C11.9951 8.35983 12.3309 8.02405 12.3309 7.60983C12.3309 7.19562 11.9951 6.85983 11.5809 6.85983Z"
}
) })
}
);
IndicatorsIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 18 18",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Indicators", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Union",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M9.74483 2.25C8.96145 2.25 8.26885 2.76459 8.04549 3.51818L7.46202 5.48254H5.06262V7.08339H6.98652L5.00539 13.7532L4.31554 13.1112L3.22498 14.2831L4.4777 15.4489C5.08739 16.015 6.08317 15.7469 6.32134 14.945L8.65649 7.08339H11.6032V5.48254H9.13198L9.58033 3.97311C9.60167 3.90112 9.66833 3.85084 9.74483 3.85084H11.69V2.25H9.74483ZM10.6234 11.2354L10.2638 11.5172C10.0153 11.712 9.65591 11.6684 9.46115 11.4199C9.26639 11.1713 9.30998 10.812 9.55852 10.6172L10.1451 10.1575C10.5693 9.82514 11.1868 9.94011 11.4642 10.4005L11.4682 10.407L12.1304 11.5752L13.4594 10.3111C13.6882 10.0935 14.05 10.1025 14.2677 10.3313C14.4853 10.5601 14.4763 10.922 14.2475 11.1396L12.7116 12.6006L13.3897 13.797L13.6482 13.4503C13.8369 13.1972 14.1951 13.145 14.4483 13.3337C14.7014 13.5225 14.7536 13.8807 14.5649 14.1338L13.9917 14.9025L13.94 14.9457C13.5178 15.2981 12.8837 15.1886 12.6003 14.7226L12.5958 14.7151L11.8576 13.4129L10.3563 14.841C10.1275 15.0586 9.76561 15.0495 9.54798 14.8208C9.33036 14.592 9.3394 14.2301 9.56819 14.0125L11.2764 12.3875L10.6234 11.2354Z"
}
) })
}
);
SettingIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 18 18",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Setting", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Vector",
d: "M6.72589 1.84154C5.66239 2.17904 4.74515 2.72954 3.93665 3.48254C3.6869 3.71504 3.6104 4.09604 3.7724 4.39604C4.37315 5.50679 3.74464 6.69554 2.38939 6.76379C2.05789 6.78029 1.76465 7.0263 1.68665 7.34955C1.5524 7.9083 1.49915 8.37629 1.49915 8.98979C1.49915 9.50504 1.55464 10.0885 1.66339 10.6075C1.73089 10.9315 2.0129 11.1648 2.3429 11.1933C3.7064 11.311 4.3814 12.3513 3.7724 13.6773C3.6374 13.972 3.6989 14.3245 3.93665 14.545C4.73315 15.2815 5.64814 15.8013 6.72589 16.1388C7.03339 16.2348 7.38064 16.1185 7.56964 15.8575C8.40364 14.7033 9.6134 14.6995 10.4054 15.8575C10.5921 16.1298 10.9341 16.261 11.2491 16.162C12.2894 15.8343 13.2584 15.277 14.0616 14.545C14.3091 14.3193 14.3744 13.954 14.2259 13.654C13.6019 12.3948 14.3197 11.239 15.6082 11.2165C15.9502 11.2105 16.2547 10.9863 16.3349 10.654C16.4647 10.1163 16.4991 9.64829 16.4991 8.98979C16.4991 8.42429 16.4324 7.86704 16.3116 7.32629C16.2351 6.98354 15.9359 6.74054 15.5849 6.73979C14.3167 6.73754 13.6056 5.49104 14.2259 4.39604C14.3984 4.09154 14.3444 3.71804 14.0849 3.48254C13.2674 2.74004 12.2706 2.15954 11.2259 1.84154C10.9049 1.74404 10.5636 1.86404 10.3821 2.14604C9.65764 3.27179 8.30465 3.29129 7.5929 2.17004C7.41065 1.88204 7.04989 1.73879 6.72589 1.84154ZM11.2844 3.43455C11.7966 3.64905 12.2009 3.8733 12.6651 4.22505C12.1206 5.9478 13.0439 7.73729 14.9564 8.17304C15.0036 8.48279 14.9991 8.67029 14.9991 8.98979C14.9991 9.37154 15.0044 9.50579 14.9609 9.78179C13.0566 10.1763 12.1146 11.9155 12.6449 13.7538C12.1889 14.0845 11.8626 14.314 11.2904 14.5353C9.94639 13.1673 8.0804 13.1073 6.7079 14.5443C6.1724 14.3088 5.76066 14.0995 5.34441 13.7478C5.86041 11.881 4.98815 10.2693 3.05165 9.7803C2.9654 9.4383 2.9999 8.4723 3.0494 8.17905C5.0519 7.69905 5.8409 5.92679 5.34365 4.21979C5.78315 3.88904 6.1784 3.6483 6.69215 3.4398C7.9859 4.75605 9.92839 4.8873 11.2844 3.43455ZM8.99915 5.98979C7.3424 5.98979 5.99915 7.33304 5.99915 8.98979C5.99915 10.6473 7.3424 11.9898 8.99915 11.9898C10.6559 11.9898 11.9991 10.6473 11.9991 8.98979C11.9991 7.33304 10.6559 5.98979 8.99915 5.98979ZM8.99915 7.48979C9.8279 7.48979 10.4991 8.16179 10.4991 8.98979C10.4991 9.81855 9.8279 10.4898 8.99915 10.4898C8.1704 10.4898 7.49915 9.81855 7.49915 8.98979C7.49915 8.16179 8.1704 7.48979 8.99915 7.48979Z"
}
) })
}
);
BarIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 20 20",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Bars", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Union",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M12.5 15.5C12.5 15.7761 12.7239 16 13 16H14C14.2761 16 14.5 15.7761 14.5 15.5V14H16C16.2761 14 16.5 13.7761 16.5 13.5V12.5C16.5 12.2239 16.2761 12 16 12H14.5V2.5C14.5 2.22386 14.2761 2 14 2H13C12.7239 2 12.5 2.22386 12.5 2.5V4H11C10.7239 4 10.5 4.22386 10.5 4.5V5.5C10.5 5.77614 10.7239 6 11 6H12.5V15.5ZM5.5 17.5C5.5 17.7761 5.72386 18 6 18H7C7.27614 18 7.5 17.7761 7.5 17.5V10H9C9.27614 10 9.5 9.77614 9.5 9.5V8.5C9.5 8.22386 9.27614 8 9 8H7.5V4.5C7.5 4.22386 7.27614 4 7 4H6C5.72386 4 5.5 4.22386 5.5 4.5V14H4C3.72386 14 3.5 14.2239 3.5 14.5V15.5C3.5 15.7761 3.72386 16 4 16H5.5V17.5Z"
}
) })
}
);
CandlesIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 20 20",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Candles", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Union",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M7.25 2.5V4H8.5C8.77614 4 9 4.22386 9 4.5V15.5C9 15.7761 8.77614 16 8.5 16H7.25V17.5C7.25 17.7761 7.02614 18 6.75 18H6.25C5.97386 18 5.75 17.7761 5.75 17.5V16H4.5C4.22386 16 4 15.7761 4 15.5V4.5C4 4.22386 4.22386 4 4.5 4H5.75V2.5C5.75 2.22386 5.97386 2 6.25 2H6.75C7.02614 2 7.25 2.22386 7.25 2.5ZM5.5 5.5V14.5H7.5V5.5H5.5ZM14.25 4.5V7H15.5C15.7761 7 16 7.22386 16 7.5V15.5C16 15.7761 15.7761 16 15.5 16H14.25V17.5C14.25 17.7761 14.0261 18 13.75 18H13.25C12.9739 18 12.75 17.7761 12.75 17.5V16H11.5C11.2239 16 11 15.7761 11 15.5V7.5C11 7.22386 11.2239 7 11.5 7H12.75V4.5C12.75 4.22386 12.9739 4 13.25 4H13.75C14.0261 4 14.25 4.22386 14.25 4.5ZM12.5 8.5V14.5H14.5V8.5H12.5Z"
}
) })
}
);
HollowCandlesIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 20 20",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsxs("g", { id: "Hollow Candles", children: [
/* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Subtract",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M5.5 14.5V5.5H7.5V14.5H5.5Z",
fill: "white",
fillOpacity: "0.12"
}
),
/* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Union",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M7.25 2.5V4H8.5C8.77614 4 9 4.22386 9 4.5V15.5C9 15.7761 8.77614 16 8.5 16H7.25V17.5C7.25 17.7761 7.02614 18 6.75 18H6.25C5.97386 18 5.75 17.7761 5.75 17.5V16H4.5C4.22386 16 4 15.7761 4 15.5V4.5C4 4.22386 4.22386 4 4.5 4H5.75V2.5C5.75 2.22386 5.97386 2 6.25 2H6.75C7.02614 2 7.25 2.22386 7.25 2.5ZM5.5 5.5V14.5H7.5V5.5H5.5ZM14.25 4.5V7H15.5C15.7761 7 16 7.22386 16 7.5V15.5C16 15.7761 15.7761 16 15.5 16H14.25V17.5C14.25 17.7761 14.0261 18 13.75 18H13.25C12.9739 18 12.75 17.7761 12.75 17.5V16H11.5C11.2239 16 11 15.7761 11 15.5V7.5C11 7.22386 11.2239 7 11.5 7H12.75V4.5C12.75 4.22386 12.9739 4 13.25 4H13.75C14.0261 4 14.25 4.22386 14.25 4.5ZM12.5 8.5V14.5H14.5V8.5H12.5Z"
}
)
] })
}
);
LineIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 20 20",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Line", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Vector 16 (Stroke)",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M18.3 2.72288C18.542 2.85596 18.6303 3.15999 18.4972 3.40195L13.495 12.4968C13.0776 13.2557 12.1061 13.5044 11.3754 13.0394L7.19878 10.3816L2.97738 17.558C2.83737 17.796 2.53092 17.8754 2.2929 17.7354L1.43097 17.2284C1.19295 17.0884 1.1135 16.7819 1.25351 16.5439L5.73746 8.92122C6.16792 8.18943 7.1194 7.96045 7.83567 8.41626L11.9995 11.0659L16.7448 2.43811C16.8778 2.19615 17.1819 2.10788 17.4238 2.24096L18.3 2.72288Z"
}
) })
}
);
AreaIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 20 20",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsxs("g", { id: "Area", children: [
/* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Vector 16 (Stroke)",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M18.3 2.72288C18.542 2.85596 18.6303 3.15999 18.4972 3.40195L13.495 12.4968C13.0776 13.2557 12.1061 13.5044 11.3754 13.0394L7.19878 10.3816L2.97738 17.558C2.83737 17.796 2.53092 17.8754 2.2929 17.7354L1.43097 17.2284C1.19295 17.0884 1.1135 16.7819 1.25351 16.5439L5.73746 8.92122C6.16792 8.18943 7.1194 7.96045 7.83567 8.41626L11.9995 11.0659L16.7448 2.43811C16.8778 2.19615 17.1819 2.10788 17.4238 2.24096L18.3 2.72288Z"
}
),
/* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Subtract",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M2.7608 17.7562C2.84602 17.899 3.00106 18 3.19016 18H16.362C17.4665 18 18.362 17.1046 18.362 16V3.94663C18.362 3.86618 18.3453 3.79397 18.3162 3.73108L13.495 12.4968C13.0776 13.2557 12.1061 13.5044 11.3754 13.0394L7.19881 10.3816L2.9774 17.558C2.92465 17.6477 2.84826 17.7148 2.7608 17.7562Z",
fill: "white",
fillOpacity: "0.12"
}
)
] })
}
);
BaseLineIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 20 20",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Baseline", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Union",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M6.05938 2.93544C6.55642 1.71198 8.27766 1.68139 8.81785 2.88642L11.4361 8.72723H9.24438L7.4717 4.77279L5.86521 8.72723H3.70647L6.05938 2.93544ZM13.9282 14.2865L13.0051 12.2272H10.8133L12.5586 16.1204C13.088 17.3014 14.7641 17.3026 15.2952 16.1224L17.048 12.2272H14.8549L13.9282 14.2865ZM2.28459 12.2272H4.44333L1.85293 18.6036L0 17.8509L2.28459 12.2272ZM16.4299 8.72723H18.623L19.3384 7.13759L17.5145 6.31686L16.4299 8.72723ZM1.42645 10.2272C1.42645 9.95109 1.65031 9.72723 1.92645 9.72723H2.92645C3.20259 9.72723 3.42645 9.95109 3.42645 10.2272V10.7272C3.42645 11.0034 3.20259 11.2272 2.92645 11.2272H1.92645C1.65031 11.2272 1.42645 11.0034 1.42645 10.7272V10.2272ZM4.42645 10.2272C4.42645 9.95109 4.65031 9.72723 4.92645 9.72723H5.92645C6.20259 9.72723 6.42645 9.95109 6.42645 10.2272V10.7272C6.42645 11.0034 6.20259 11.2272 5.92645 11.2272H4.92645C4.65031 11.2272 4.42645 11.0034 4.42645 10.7272V10.2272ZM7.92645 9.72723C7.65031 9.72723 7.42645 9.95109 7.42645 10.2272V10.7272C7.42645 11.0034 7.65031 11.2272 7.92645 11.2272H8.92645C9.20259 11.2272 9.42645 11.0034 9.42645 10.7272V10.2272C9.42645 9.95109 9.20259 9.72723 8.92645 9.72723H7.92645ZM10.4265 10.2272C10.4265 9.95109 10.6503 9.72723 10.9265 9.72723H11.9265C12.2026 9.72723 12.4265 9.95109 12.4265 10.2272V10.7272C12.4265 11.0034 12.2026 11.2272 11.9265 11.2272H10.9265C10.6503 11.2272 10.4265 11.0034 10.4265 10.7272V10.2272ZM13.9265 9.72723C13.6503 9.72723 13.4265 9.95109 13.4265 10.2272V10.7272C13.4265 11.0034 13.6503 11.2272 13.9265 11.2272H14.9265C15.2026 11.2272 15.4265 11.0034 15.4265 10.7272V10.2272C15.4265 9.95109 15.2026 9.72723 14.9265 9.72723H13.9265ZM16.4265 10.2272C16.4265 9.95109 16.6503 9.72723 16.9265 9.72723H17.9265C18.2026 9.72723 18.4265 9.95109 18.4265 10.2272V10.7272C18.4265 11.0034 18.2026 11.2272 17.9265 11.2272H16.9265C16.6503 11.2272 16.4265 11.0034 16.4265 10.7272V10.2272Z"
}
) })
}
);
UnSelectIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 12 12",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Unselected", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Vector",
d: "M6.00684 0.999023C3.24544 0.999023 1.00684 3.23752 1.00684 5.99902C1.00684 8.76051 3.24544 10.999 6.00684 10.999C8.76834 10.999 11.0068 8.76051 11.0068 5.99902C11.0068 3.23752 8.76834 0.999023 6.00684 0.999023ZM6.00684 1.99902C8.21584 1.99902 10.0068 3.79002 10.0068 5.99902C10.0068 8.20801 8.21584 9.99901 6.00684 9.99901C3.79769 9.99901 2.00684 8.20801 2.00684 5.99902C2.00684 3.79002 3.79769 1.99902 6.00684 1.99902Z",
fill: "white",
fillOpacity: "0.2"
}
) })
}
);
SelectedIcon = (props) => /* @__PURE__ */ jsxRuntime.jsx(
"svg",
{
viewBox: "0 0 12 12",
fill: "currentColor",
xmlns: "http://www.w3.org/2000/svg",
...props,
children: /* @__PURE__ */ jsxRuntime.jsx("g", { id: "Selected-Multiple Choices-fill", children: /* @__PURE__ */ jsxRuntime.jsx(
"path",
{
id: "Subtract",
fillRule: "evenodd",
clipRule: "evenodd",
d: "M1.00684 5.99902C1.00684 3.23752 3.24544 0.999023 6.00684 0.999023C8.76834 0.999023 11.0068 3.23752 11.0068 5.99902C11.0068 8.76051 8.76834 10.999 6.00684 10.999C3.24544 10.999 1.00684 8.76051 1.00684 5.99902ZM8.49243 3.65563C8.60602 3.54726 8.76156 3.49957 8.91068 3.49957C9.05981 3.49957 9.21534 3.54726 9.32893 3.65563C9.5567 3.87231 9.5567 4.23649 9.32893 4.45317L5.25362 8.33706C5.02644 8.55374 4.6443 8.55374 4.41712 8.33706L2.67014 6.67253C2.44296 6.45585 2.44296 6.09161 2.67014 5.87499C2.89791 5.65831 3.28004 5.65831 3.50722 5.87499L4.83537 7.1407L8.49243 3.65563Z",
fill: "#608CFF"
}
) })
}
);
}
});
// src/components/lineType/index.tsx
var lineType_exports = {};
__export(lineType_exports, {
default: () => lineType_default
});
var LineType, lineType_default;
var init_lineType = __esm({
"src/components/lineType/index.tsx"() {
init_icons();
LineType = (props) => {
const [open, setOpen] = React3.useState(false);
const { t } = i18n.useTranslation();
const lineTypeList = React3.useMemo(() => {
return [
{
icon: /* @__PURE__ */ jsxRuntime.jsx(BarIcon, { fill: "currentColor", className: "oui-w-5 oui-h-5" }),
label: t("tradingView.lineType.bars"),
value: "0"
},
{
icon: /* @__PURE__ */ jsxRuntime.jsx(CandlesIcon, { fill: "currentColor", className: "oui-w-5 oui-h-5" }),
label: t("tradingView.lineType.candles"),
value: "1"
},
{
icon: /* @__PURE__ */ jsxRuntime.jsx(HollowCandlesIcon, { fill: "currentColor", className: "oui-w-5 oui-h-5" }),
label: t("tradingView.lineType.hollowCandles"),
value: "9"
},
{
icon: /* @__PURE__ */ jsxRuntime.jsx(LineIcon, { fill: "currentColor", className: "oui-w-5 oui-h-5" }),
label: t("tradingView.lineType.line"),
value: "2"
},
{
icon: /* @__PURE__ */ jsxRuntime.jsx(AreaIcon, { fill: "currentColor", className: "oui-w-5 oui-h-5" }),
label: t("tradingView.lineType.area"),
value: "3"
},
{
icon: /* @__PURE__ */ jsxRuntime.jsx(BaseLineIcon, { fill: "currentColor", className: "oui-w-5 oui-h-5" }),
label: t("tradingView.lineType.baseline"),
value: "10"
}
];
}, [t]);
const currentLineTypeIcon = React3.useMemo(() => {
const data = lineTypeList.find((item) => item.value === props.lineType);
if (data) {
return data.icon;
}
return lineTypeList[1].icon;
}, [props.lineType]);
return /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuRoot, { open, onOpenChange: setOpen, children: [
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
ui.Box,
{
className: ui.cn(
"oui-w-[18px] oui-h-[18px] oui-cursor-pointer oui-text-base-contrast-36 hover:oui-text-base-contrast-80",
open && "oui-text-base-contrast-80"
),
children: currentLineTypeIcon
}
) }),
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
ui.DropdownMenuContent,
{
onCloseAutoFocus: (e) => e.preventDefault(),
onClick: (e) => e.stopPropagation(),
align: "start",
sideOffset: 20,
className: "oui-bg-base-8",
children: /* @__PURE__ */ jsxRuntime.jsx(
ui.Flex,
{
direction: "column",
gap: 4,
px: 5,
py: 5,
width: 240,
justify: "start",
itemAlign: "start",
children: lineTypeList.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
ui.Flex,
{
justify: "start",
itemAlign: "center",
gap: 2,
className: ui.cn(
"oui-text-base-contrast-36 oui-cursor-pointer oui-w-full hover:oui-text-base-contrast",
props.lineType === item.value && "oui-text-base-contrast"
),
onClick: () => props.changeLineType(item.value),
children: [
item.icon,
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-text-sm", children: item.label })
]
},
item.value
))
}
)
}
) })
] });
};
lineType_default = LineType;
}
});
// src/components/timeInterval/index.tsx
var timeInterval_exports = {};
__export(timeInterval_exports, {
MobileTimeInterval: () => MobileTimeInterval,
TimeInterval: () => TimeInterval
});
var useMobileTimeIntervalMoreMap, TimeInterval, DesktopTimeInterval, MobileTimeInterval, DropDownTimeInterval;
var init_timeInterval = __esm({
"src/components/timeInterval/index.tsx"() {
init_icons();
useMobileTimeIntervalMoreMap = () => {
const { t } = i18n.useTranslation();
const mobileTimeIntervalMoreMap = React3.useMemo(() => {
return [
[
{
value: "3",
label: t("tradingView.timeInterval.3m")
},
{
value: "5",
label: t("tradingView.timeInterval.5m")
},
{
value: "30",
label: t("tradingView.timeInterval.30m")
},
{
value: "120",
label: t("tradingView.timeInterval.2h")
}
],
[
{
value: "360",
label: t("tradingView.timeInterval.6h")
},
{
value: "720",
label: t("tradingView.timeInterval.12h")
},
{
value: "3d",
label: t("tradingView.timeInterval.3d")
},
{
value: "1M",
label: t("tradingView.timeInterval.1M")
}
]
];
}, [t]);
return { mobileTimeIntervalMoreMap };
};
TimeInterval = (props) => {
const isMobile = hooks.useMediaQuery(types.MEDIA_TABLET);
if (isMobile) {
return /* @__PURE__ */ jsxRuntime.jsx(MobileTimeInterval, { ...props });
}
return /* @__PURE__ */ jsxRuntime.jsx(DesktopTimeInterval, { ...props });
};
DesktopTimeInterval = (props) => {
const { t } = i18n.useTranslation();
const timeIntervalMap = React3.useMemo(() => {
return [
{
value: "1",
label: t("tradingView.timeInterval.1m")
},
{
value: "3",
label: t("tradingView.timeInterval.3m")
},
{
value: "5",
label: t("tradingView.timeInterval.5m")
},
{
value: "15",
label: t("tradingView.timeInterval.15m")
},
{
value: "30",
label: t("tradingView.timeInterval.30m")
},
{
value: "60",
label: t("tradingView.timeInterval.1h")
},
{
value: "240",
label: t("tradingView.timeInterval.4h")
},
{
value: "720",
label: t("tradingView.timeInterval.12h")
},
{
value: "1D",
label: t("tradingView.timeInterval.1d")
},
{
value: "1W",
label: t("tradingView.timeInterval.1w")
},
{
value: "1M",
label: t("tradingView.timeInterval.1M")
}
];
}, [t]);
return /* @__PURE__ */ jsxRuntime.jsx(
"div",
{
className: ui.cn(
"oui-text-2xs oui-text-base-contrast-36 oui-flex oui-gap-[2px] oui-items-center oui-mr-3 oui-font-semibold",
"oui-overflow-hidden"
),
children: timeIntervalMap.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
"div",
{
className: ui.cn(
"oui-cursor-pointer oui-px-2",
"hover:oui-text-base-contrast-80",
"oui-break-normal oui-whitespace-nowrap",
props.interval === item.value && "oui-text-base-contrast-80 oui-bg-white/[.06] oui-rounded"
),
id: item.value,
onClick: () => props.changeInterval(item.value),
children: item.label
},
item.value
))
}
);
};
MobileTimeInterval = (props) => {
const { t } = i18n.useTranslation();
const mobileTimeIntervalDefaultMap = React3.useMemo(() => {
return [
{
value: "1",
label: t("tradingView.timeInterval.1m")
},
{
value: "15",
label: t("tradingView.timeInterval.15m")
},
{
value: "60",
label: t("tradingView.timeInterval.1h")
},
{
value: "240",
label: t("tradingView.timeInterval.4h")
},
{
value: "1D",
label: t("tradingView.timeInterval.1d")
},
{
value: "1W",
label: t("tradingView.timeInterval.1w")
}
];
}, [t]);
const { mobileTimeIntervalMoreMap } = useMobileTimeIntervalMoreMap();
const currentIntervalIsInExpand = React3.useMemo(() => {
for (const row of mobileTimeIntervalMoreMap) {
for (const item of row) {
if (item.value === props.interval) {
return item.label;
}
}
}
return null;
}, [props.interval, mobileTimeIntervalMoreMap]);
return /* @__PURE__ */ jsxRuntime.jsxs(
ui.Flex,
{
justify: "start",
itemAlign: "center",
gap: 3,
className: ui.cn(
"oui-text-2xs oui-text-base-contrast-36",
"oui-overflow-hidden"
),
children: [
/* @__PURE__ */ jsxRuntime.jsx("div", { className: " oui-flex oui-gap-1 oui-items-center oui-mr-3 oui-font-semibold", children: mobileTimeIntervalDefaultMap.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
"div",
{
className: ui.cn(
"oui-px-2",
"oui-break-normal oui-whitespace-nowrap",
props.interval === item.value && "oui-text-base-contrast-80 oui-bg-white/[.06] oui-rounded"
),
onClick: () => props.changeInterval(item.value),
children: item.label
},
item.value
)) }),
/* @__PURE__ */ jsxRuntime.jsx(DropDownTimeInterval, { ...props, children: currentIntervalIsInExpand ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-text-base-contrast-80", children: currentIntervalIsInExpand }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "oui-break-normal oui-whitespace-nowrap", children: t("tradingView.timeInterval.more") }) })
]
}
);
};
DropDownTimeInterval = (props) => {
const [open, setOpen] = React3__default.default.useState(false);
const { mobileTimeIntervalMoreMap } = useMobileTimeIntervalMoreMap();
return /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuRoot, { open, onOpenChange: setOpen, children: [
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "oui-flex oui-justify-start oui-items-center oui-gap-0.5", children: [
props.children,
/* @__PURE__ */ jsxRuntime.jsx(
CaretIcon,
{
className: ui.cn(
"oui-w-3 oui-h-3",
open && "oui-text-base-contrast-80 oui-rotate-180"
)
}
)
] }) }),
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
ui.DropdownMenuContent,
{
onCloseAutoFocus: (e) => e.preventDefault(),
onClick: (e) => e.stopPropagation(),
align: "start",
alignOffset: 0,
sideOffset: 0,
className: ui.cn(
"oui-markets-dropdown-menu-content oui-bg-base-9 oui-w-screen oui-flex oui-flex-col oui-gap-2 oui-p-3"
),
children: mobileTimeIntervalMoreMap.map((row, id) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-gap-2", children: row.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
"div",
{
className: ui.cn(
"oui-w-full oui-text-2xs oui-flex oui-items-center oui-justify-center oui-h-6 oui-rounded",
item.value === props.interval ? "oui-text-base-contrast oui-bg-primary-darken" : "oui-text-base-contrast-36 oui-bg-base-5"
),
onClick: () => {
props.changeInterval(item.value);
},
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: item.label })
},
item.value
)) }, id))
}
) })
] });
};
}
});
var DesktopDisplayControl;
var init_displayControl_desktop = __esm({
"src/components/displayControl/displayControl.desktop.tsx"() {
init_icons();
DesktopDisplayControl = (props) => {
const { displayControlState, changeDisplayControlState } = props;
const [open, setOpen] = React3.useState(false);
const { t } = i18n.useTranslation();
const displayControlMap = React3.useMemo(() => {
return [
{
label: t("common.position"),
id: "position"
},
{
label: t("tradingView.displayControl.buySell"),
id: "buySell"
},
{
label: t("tradingView.displayControl.limitOrders"),
id: "limitOrders"
},
{
label: t("tradingView.displayControl.stopOrders"),
id: "stopOrders"
},
{
label: t("common.tpsl"),
id: "tpsl"
},
{
label: t("tpsl.positionTpsl"),
id: "positionTpsl"
},
{
label: t("orderEntry.orderType.trailingStop"),
id: "trailingStop"
}
];
}, [t]);
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuRoot, { open, onOpenChange: setOpen, children: [
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
ui.Flex,
{
justify: "start",
itemAlign: "center",
className: "oui-gap-[2px] oui-cursor-pointer oui-text-base-contrast-36 hover:oui-text-base-contrast-80",
children: [
/* @__PURE__ */ jsxRuntime.jsx(
DisplaySettingIcon,
{
className: ui.cn(
"oui-w-[18px] oui-h-[18px] ",
open && "oui-text-base-contrast-80"
)
}
),
/* @__PURE__ */ jsxRuntime.jsx(
CaretIcon,
{
className: ui.cn(
"oui-w-3 oui-h-3",
open && "oui-text-base-contrast-80 oui-rotate-180"
)
}
)
]
}
) }),
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
ui.DropdownMenuContent,
{
onCloseAutoFocus: (e) => e.preventDefault(),
onClick: (e) => e.stopPropagation(),
align: "start",
className: "oui-bg-base-8",
children: /* @__PURE__ */ jsxRuntime.jsx(
ui.Flex,
{
direction: "column",
gap: 4,
px: 5,
py: 5,
width: 240,
justify: "start",
itemAlign: "start",
children: displayControlMap.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
ui.Flex,
{
justify: "between",
itemAlign: "center",
className: "oui-w-full",
children: [
/* @__PURE__ */ jsxRuntime.jsx(
ui.Text,
{
className: ui.cn(
"oui-text-sm oui-text-base-contrast-80",
!displayControlState[item.id] && "oui-text-base-contrast-36"
),
children: item.label
}
),
/* @__PURE__ */ jsxRuntime.jsx(
ui.Switch,
{
className: "oui-h-4 oui-w-8",
checked: displayControlState[item.id],
onCheckedChange: (checked) => {
changeDisplayControlState({
...displayControlState,
[item.id]: checked
});
}
}
)
]
},
item.id
))
}
)
}
) })
] }) });
};
}
});
var MobileDisplayControl;
var init_displayControl_mobile = __esm({
"src/components/displayControl/displayControl.mobile.tsx"() {
init_icons();
MobileDisplayControl = (props) => {
const [open, setOpen] = React3.useState(false);
const { t } = i18n.useTranslation();
const mobileDisplayControlMap = React3.useMemo(() => {
return [
[
{
label: t("common.position"),
id: "position"
},
{
label: t("tradingView.displayControl.limitOrders"),
id: "limitOrders"
}
],
[
{
label: t("tradingView.displayControl.stopOrders"),
id: "stopOrders"
},
{
label: t("common.tpsl"),
id: "tpsl"
}
],
[
{
label: t("tpsl.positionTpsl"),
id: "positionTpsl"
},
{
label: t("tradingView.displayControl.buySell"),
id: "buySell"
}
],
[
{
label: t("orderEntry.orderType.trailingStop"),
id: "trailingStop"
},
// placeholder
{}
]
];
}, [t]);
return /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuRoot, { open, onOpenChange: setOpen, children: [
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
"div",
{
className: ui.cn(
"oui-flex oui-items-center oui-justify-center oui-gap-0.5 oui-text-base-contrast-36",
open && "oui-text-base-contrast-8"
),
children: [
/* @__PURE__ */ jsxRuntime.jsx(
DisplaySettingIcon,
{
className: ui.cn(
"oui-size-[18px] ",
open && "oui-text-base-contrast-80"
)
}
),
/* @__PURE__ */ jsxRuntime.jsx(
CaretIcon,
{
className: ui.cn(
"oui-size-3",
open && "oui-rotate-180 oui-text-base-contrast-80"
)
}
)
]
}
) }),
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
ui.DropdownMenuContent,
{
onCloseAutoFocus: (e) => e.preventDefault(),
onClick: (e) => e.stopPropagation(),
align: "start",
alignOffset: 0,
sideOffset: 0,
className: ui.cn(
"oui-tradingview-display-control-dropdown-menu-content oui-flex oui-w-screen oui-flex-col oui-gap-2 oui-bg-base-9 oui-p-3"
),
children: mobileDisplayControlMap.map((row, id) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-flex oui-gap-2", children: row.map((item, index) => {
return /* @__PURE__ */ jsxRuntime.jsx(
"div",
{
className: ui.cn(
"oui-flex oui-h-6 oui-w-full oui-items-center oui-justify-between",
"oui-rounded oui-px-2 oui-text-2xs",
item.id && "oui-bg-base-5",
props.displayControlState[item.id] ? "oui-text-base-contrast" : "oui-text-base-contrast-36"
),
onClick: () => {
if (!item.id) {
return;
}
props.changeDisplayControlState({
...props.displayControlState,
[item.id]: !props.displayControlState[item.id]
});
},
children: item.id && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
/* @__PURE__ */ jsxRuntime.jsx("div", { children: item.label }),
props.displayControlState[item.id] ? /* @__PURE__ */ jsxRuntime.jsx(SelectedIcon, { className: "oui-size-3" }) : /* @__PURE__ */ jsxRuntime.jsx(UnSelectIcon, { className: "oui-size-3" })
] })
},
item.id || index
);
}) }, id))
}
) })
] });
};
}
});
// src/components/displayControl/index.tsx
var displayControl_exports = {};
__export(displayControl_exports, {
DesktopDisplayControl: () => DesktopDisplayControl,
MobileDisplayControl: () => MobileDisplayControl
});
var init_displayControl = __esm({
"src/components/displayControl/index.tsx"() {
init_displayControl_desktop();
init_displayControl_mobile();
}
});
// src/utils/chart.util.ts
var upColor = "#008676";
var downColor = "#D92D6B";
var chartBG = "#131519";
var pnlUpColor = "#00B49E";
var pnlDownColor = "#FF447C";
var pnlZoreColor = "#333948";
var textColor = "#FFFFFF";
var qtyTextColor = "#F4F7F9";
var font = "regular 11px Manrope";
var defaultColorConfig = {
upColor,
downColor,
chartBG,
pnlUpColor,
pnlDownColor,
pnlZoreColor,
textColor,
qtyTextColor,
font,
volumeUpColor: "#0C3E3A",
volumeDownColor: "#5A1E36",
closeIcon: "rgba(255, 255, 255, 0.8)"
};
var getOveriides = (colorConfig, isMobile) => {
const overrides = {
"paneProperties.background": colorConfig.chartBG,
// "paneProperties.background": "#ffff00",
// "mainSeriesProperties.style": 1,
"paneProperties.backgroundType": "solid",
// "paneProperties.background": "#151822",
"mainSeriesProperties.candleStyle.upColor": colorConfig.upColor,
"mainSeriesProperties.candleStyle.downColor": colorConfig.downColor,
"mainSeriesProperties.candleStyle.borderColor": colorConfig.upColor,
"mainSeriesProperties.candleStyle.borderUpColor": colorConfig.upColor,
"mainSeriesProperties.candleStyle.borderDownColor": colorConfig.downColor,
"mainSeriesProperties.candleStyle.wickUpColor": colorConfig.upColor,
"mainSeriesProperties.candleStyle.wickDownColor": colorConfig.downColor,
"paneProperties.separatorColor": "#2B2833",
"paneProperties.vertGridProperties.color": "#26232F",
"paneProperties.horzGridProperties.color": "#26232F",
"scalesProperties.fontSize": isMobile ? 8 : 12,
"scalesProperties.textColor": "#97969B",
"paneProperties.legendProperties.showSeriesTitle": isMobile ? false : true,
"mainSeriesProperties.statusViewStyle.symbolTextSource": "ticker"
};
const studiesOverrides = {
"volume.volume.color.0": colorConfig.volumeDownColor,
"volume.volume.color.1": colorConfig.volumeUpColor
};
return {
overrides,
studiesOverrides
};
};
var EXCHANGE = "Orderly";
var withoutExchangePrefix = (symbol) => symbol.includes(":") ? symbol.split(":")[1] : symbol;
var withExchangePrefix = (symbol) => symbol.startsWith(`${EXCHANGE}:`) ? symbol : `${EXCHANGE}:${symbol}`;
var getBrokerAdapter = (host, broker) => {
let _symbolInfo;
const getOrderCombinationType = (orderType) => {
return [
null,
"limit",
"MARKET" /* MARKET */,
"STOP_MARKET" /* STOP_MARKET */,
"STOP_LIMIT" /* STOP_LIMIT */
][orderType];
};
return {
symbolInfo: async (symbol2) => {
_symbolInfo = broker.getSymbolInfo(withoutExchangePrefix(symbol2));
return {
qty: {
min: _symbolInfo?.baseMin ?? 0,
max: _symbolInfo?.baseMax ?? 0,
step: _symbolInfo?.baseTick ?? 0
},
pipValue: 0,
pipSize: _symbolInfo?.quoteTick ?? 0,
minTick: _symbolInfo?.quoteTick ?? 0,
description: ""
};
},
placeOrder: async (order) => {
const side = ["SELL" /* SELL */, "BUY" /* BUY */][+(order.side > 0)];
const quantity = order.qty.toString();
(order.limitPrice ?? 0).toString();
(order.stopPrice ?? 0).toString();
const symbol2 = withoutExchangePrefix(order.symbol);
const orderCombinationType = getOrderCombinationType(order.type);
if (orderCombinationType === "MARKET" /* MARKET */) {
broker.sendMarketOrder({ side, order_quantity: quantity, symbol: symbol2, order_type: types.OrderType.MARKET });
}
},
orders: () => [],
positions: () => [],
executions: () => [],
connectionStatus: () => 1,
chartContextMenuActions: (context) => host.defaultContextMenuActions(context),
isTradable: async () => true,
accountManagerInfo: () => ({}),
currentAccount: () => "1",
accountsMetainfo: async () => [{ id: "1" }],
remove: () => host?.silentOrdersPlacement().unsubscribe()
};
};
var getBrokerAdapter_default = getBrokerAdapter;
function logMessage(message) {
}
function getErrorMessage(error) {
if (error === void 0) {
return "";
}
if (typeof error === "string") {
return error;
}
return error.message;
}
// src/tradingviewAdapter/datafeed/history-provider.ts
var HISTORY_PATH = "tv/history";
var KLINE_HISTORY_PATH = "v1/tv/kline_history";
var _HistoryProvider = class _HistoryProvider {
constructor(datafeedUrl, requester, limitedServerResponse) {
this._klinePreference = /* @__PURE__ */ new Map();
this._datafeedUrl = datafeedUrl;
this._requester = requester;
this._limitedServerResponse = limitedServerResponse;
}
/**
* Build request parameters for history API calls
* @param symbolInfo - Symbol information
* @param resolution - Resolution string
* @param periodParams - Period parameters with optional countback
* @returns Request parameters object
*/
_buildRequestParams(symbolInfo, resolution, periodParams) {
const requestParams = {
symbol: symbolInfo.ticker || "",
resolution,
from: periodParams.from,
to: periodParams.to
};
const countBack = Math.min(periodParams.countBack ?? 0, 1e3);
if (periodParams.countBack !== void 0) {
requestParams.countback = countBack;
}
if (symbolInfo.currency_code !== void 0) {
requestParams.currencyCode = symbolInfo.currency_code;
}
if (symbolInfo.unit_id !== void 0) {
requestParams.unitId = symbolInfo.unit_id;
}
return requestParams;
}
getBars(symbolInfo, resolution, periodParams) {
const requestParams = this._buildRequestParams(
symbolInfo,
resolution,
periodParams
);
const preferenceKey = this._getPreferenceKey(symbolInfo, resolution);
const prefersKline = this._klinePreference.get(preferenceKey) === true;
const countBack = Math.min(periodParams.countBack ?? 0, 1e3);
return new Promise(
async (resolve, reject) => {
try {
let result;
let usedHistoryResult = false;
if (prefersKline) {
result = await this._requestKlineHistory(
this._buildKlineParams(requestParams, countBack)
);
} else {
const initialResponse = await this._requestHistory(requestParams);
result = this._processHistoryResponse(initialResponse);
usedHistoryResult = true;
const needsFallback = this._shouldFallbackToKline(
initialResponse,
countBack
);
if (needsFallback) {
const earliestTime = this._getEarliestTime(result.bars);
if (earliestTime !== null) {
const remainingCountBack = Math.max(
0,
countBack - result.bars.length
);
const mergedResult = await this._tryKlineFallbackWithMerge(
requestParams,
remainingCountBack,
earliestTime,
result
);
if (mergedResult !== null) {
result = mergedResult;
usedHistoryResult = false;
this._klinePreference.set(preferenceKey, true);
} else {
this._klinePreference.set(preferenceKey, false);
}
} else {
const klineResult = await this._tryKlineFallback(
requestParams,
countBack
);
if (klineResult !== null) {
result = klineResult;
usedHistoryResult = false;
this._klinePreference.set(preferenceKey, true);
} else {
this._klinePreference.set(preferenceKey, false);
}
}
} else {
this._klinePreference.set(preferenceKey, false);
}
}
if (usedHistoryResult && this._limitedServerResponse) {
await this._processTruncatedResponse(result, { ...requestParams });
}
resolve(result);
} catch (e) {
const error = e instanceof Error ? e : typeof e === "string" ? e : void 0;
const reasonString = getErrorMessage(error);
reject(reasonString || "Error");
}
}
);
}
/**
* Request kline history using KLINE_HISTORY_PATH endpoint
* Handles rate limiting (429 errors) by waiting and retrying
* @param requestParams - Request parameters
* @param retryCount - Current retry attempt (internal use)
* @returns Processed history response
*/
async _requestKlineHistory(requestParams, retryCount = 0) {
const maxRetries = 5;
const baseRetryDelay = 2500;
const maxRetryDelay = 1e4;
const params = {
...requestParams,
resolution: this._mapToKlineHistoryResolution(
requestParams.resolution
)
};
const urlPath = this._buildUrlWithParams(KLINE_HISTORY_PATH, params);
const options = { credentials: "same-origin" };
const requesterWithHeaders = this._requester;
if (requesterWithHeaders._headers !== void 0) {
options.headers = req