charting_library.min.d.ts 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231
  1. /// <reference types="jquery" />
  2. export declare type LanguageCode = 'ar' | 'zh' | 'cs' | 'da_DK' | 'nl_NL' | 'en' | 'et_EE' | 'fr' | 'de' | 'el' | 'he_IL' | 'hu_HU' | 'id_ID' | 'it' | 'ja' | 'ko' | 'fa' | 'pl' | 'pt' | 'ro' | 'ru' | 'sk_SK' | 'es' | 'sv' | 'th' | 'tr' | 'vi';
  3. export interface ISubscription<TFunc extends Function> {
  4. subscribe(obj: object | null, member: TFunc, singleshot?: boolean): void;
  5. unsubscribe(obj: object | null, member: TFunc): void;
  6. unsubscribeAll(obj: object | null): void;
  7. }
  8. export interface IDelegate<TFunc extends Function> extends ISubscription<TFunc> {
  9. fire: TFunc;
  10. }
  11. export interface IDestroyable {
  12. destroy(): void;
  13. }
  14. export interface FormatterParseResult {
  15. res: boolean;
  16. }
  17. export interface ErrorFormatterParseResult extends FormatterParseResult {
  18. error?: string;
  19. res: false;
  20. }
  21. export interface SuccessFormatterParseResult extends FormatterParseResult {
  22. res: true;
  23. suggest?: string;
  24. }
  25. export interface IFormatter {
  26. format(value: any): string;
  27. parse?(value: string): ErrorFormatterParseResult | SuccessFormatterParseResult;
  28. }
  29. /**
  30. * This is the generic type useful for declaring a nominal type,
  31. * which does not structurally matches with the base type and
  32. * the other types declared over the same base type
  33. *
  34. * Usage:
  35. * @example
  36. * type Index = Nominal<number, 'Index'>;
  37. * // let i: Index = 42; // this fails to compile
  38. * let i: Index = 42 as Index; // OK
  39. * @example
  40. * type TagName = Nominal<string, 'TagName'>;
  41. */
  42. export declare type Nominal<T, Name extends string> = T & {
  43. [Symbol.species]: Name;
  44. };
  45. export declare type StudyInputValueType = string | number | boolean;
  46. export declare type StudyOverrideValueType = string | number | boolean;
  47. export interface StudyOverrides {
  48. [key: string]: StudyOverrideValueType;
  49. }
  50. export interface WatchedValueSubscribeOptions {
  51. once?: boolean;
  52. callWithLast?: boolean;
  53. }
  54. export interface IWatchedValueReadonly<T> {
  55. value(): T;
  56. subscribe(callback: (value: T) => void, options?: WatchedValueSubscribeOptions): void;
  57. unsubscribe(callback?: ((value: T) => void) | null): void;
  58. spawn(): IWatchedValueReadonlySpawn<T>;
  59. }
  60. export interface IWatchedValueReadonlySpawn<T> extends IWatchedValueReadonly<T>, IDestroyable {
  61. }
  62. export declare type WatchedValueCallback<T> = (value: T) => void;
  63. export interface IWatchedValue<T> extends IWatchedValueReadonly<T> {
  64. value(): T;
  65. setValue(value: T, forceUpdate?: boolean): void;
  66. subscribe(callback: WatchedValueCallback<T>, options?: WatchedValueSubscribeOptions): void;
  67. unsubscribe(callback?: WatchedValueCallback<T> | null): void;
  68. readonly(): IWatchedValueReadonly<T>;
  69. spawn(): IWatchedValueSpawn<T>;
  70. }
  71. export interface IWatchedValueSpawn<T> extends IWatchedValueReadonlySpawn<T>, IWatchedValue<T> {
  72. spawn(): IWatchedValueSpawn<T>;
  73. }
  74. export declare const enum ConnectionStatus {
  75. Connected = 1,
  76. Connecting = 2,
  77. Disconnected = 3,
  78. Error = 4,
  79. }
  80. export declare const enum OrderType {
  81. Limit = 1,
  82. Market = 2,
  83. Stop = 3,
  84. StopLimit = 4,
  85. }
  86. export declare const enum Side {
  87. Buy = 1,
  88. Sell = -1,
  89. }
  90. export declare const enum OrderStatus {
  91. Canceled = 1,
  92. Filled = 2,
  93. Inactive = 3,
  94. Placing = 4,
  95. Rejected = 5,
  96. Working = 6,
  97. }
  98. export declare const enum ParentType {
  99. Order = 1,
  100. Position = 2,
  101. Trade = 3,
  102. }
  103. export declare const enum OrderTicketFocusControl {
  104. StopLoss = 1,
  105. StopPrice = 2,
  106. TakeProfit = 3,
  107. }
  108. export declare const enum NotificationType {
  109. Error = 0,
  110. Success = 1,
  111. }
  112. export interface TableRow {
  113. priceFormatter?: IFormatter;
  114. [name: string]: any;
  115. }
  116. export interface TableFormatterInputs {
  117. value: number | string | Side | OrderType | OrderStatus;
  118. prevValue?: number | undefined;
  119. row: TableRow;
  120. $container: JQuery;
  121. priceFormatter?: IFormatter;
  122. }
  123. export declare type TableElementFormatFunction = (inputs: TableFormatterInputs) => string | JQuery;
  124. export interface TableElementFormatter {
  125. name: string;
  126. format: TableElementFormatFunction;
  127. }
  128. export declare type StandardFormatterName = 'date' | 'default' | 'fixed' | 'formatPrice' | 'formatPriceForexSup' | 'integerSeparated' | 'localDate' | 'percentage' | 'pips' | 'profit' | 'side' | 'status' | 'symbol' | 'type';
  129. export interface DOMLevel {
  130. price: number;
  131. volume: number;
  132. }
  133. export interface DOMData {
  134. snapshot: boolean;
  135. asks: DOMLevel[];
  136. bids: DOMLevel[];
  137. }
  138. export interface QuantityMetainfo {
  139. min: number;
  140. max: number;
  141. step: number;
  142. }
  143. export interface InstrumentInfo {
  144. qty: QuantityMetainfo;
  145. pipValue: number;
  146. pipSize: number;
  147. minTick: number;
  148. description: string;
  149. domVolumePrecision?: number;
  150. }
  151. export interface CustomFields {
  152. [key: string]: any;
  153. }
  154. export interface PreOrder {
  155. symbol: string;
  156. brokerSymbol?: string;
  157. type?: OrderType;
  158. side?: Side;
  159. qty: number;
  160. status?: OrderStatus;
  161. stopPrice?: number;
  162. limitPrice?: number;
  163. stopLoss?: number;
  164. takeProfit?: number;
  165. duration?: OrderDuration;
  166. }
  167. export interface PlacedOrder extends PreOrder, CustomFields {
  168. id: string;
  169. filledQty?: number;
  170. avgPrice?: number;
  171. updateTime?: number;
  172. takeProfit?: number;
  173. stopLoss?: number;
  174. type: OrderType;
  175. side: Side;
  176. status: OrderStatus;
  177. }
  178. export interface OrderWithParent extends PlacedOrder {
  179. parentId: string;
  180. parentType: ParentType;
  181. }
  182. export declare type Order = OrderWithParent | PlacedOrder;
  183. export interface Position {
  184. id: string;
  185. symbol: string;
  186. brokerSymbol?: string;
  187. qty: number;
  188. side: Side;
  189. avgPrice: number;
  190. [key: string]: any;
  191. }
  192. export interface Trade extends CustomFields {
  193. id: string;
  194. date: number;
  195. symbol: string;
  196. brokerSymbol?: string;
  197. qty: number;
  198. side: Side;
  199. price: number;
  200. }
  201. export interface Execution extends CustomFields {
  202. symbol: string;
  203. brokerSymbol?: string;
  204. price: number;
  205. qty: number;
  206. side: Side;
  207. time: number;
  208. }
  209. export interface AccountInfo {
  210. id: string;
  211. name: string;
  212. currency?: string;
  213. }
  214. export interface AccountManagerColumn {
  215. id?: string;
  216. label: string;
  217. className?: string;
  218. formatter?: StandardFormatterName | 'orderSettings' | 'posSettings' | string;
  219. property?: string;
  220. sortProp?: string;
  221. modificationProperty?: string;
  222. notSortable?: boolean;
  223. help?: string;
  224. highlightDiff?: boolean;
  225. fixedWidth?: boolean;
  226. notHideable?: boolean;
  227. hideByDefault?: boolean;
  228. }
  229. export interface SortingParameters {
  230. columnId: string;
  231. asc?: boolean;
  232. }
  233. export interface AccountManagerTable {
  234. id: string;
  235. title?: string;
  236. columns: AccountManagerColumn[];
  237. initialSorting?: SortingParameters;
  238. changeDelegate: IDelegate<(data: object) => void>;
  239. getData(): Promise<object[]>;
  240. }
  241. export interface AccountManagerPage {
  242. id: string;
  243. title: string;
  244. tables: AccountManagerTable[];
  245. }
  246. export interface AccountManagerInfo {
  247. accountTitle: string;
  248. accountsList?: AccountInfo[];
  249. account?: IWatchedValue<AccountInfo>;
  250. summary: AccountManagerSummaryField[];
  251. customFormatters?: TableElementFormatter[];
  252. orderColumns: AccountManagerColumn[];
  253. historyColumns?: AccountManagerColumn[];
  254. positionColumns: AccountManagerColumn[];
  255. tradeColumns?: AccountManagerColumn[];
  256. pages: AccountManagerPage[];
  257. possibleOrderStatuses?: OrderStatus[];
  258. contextMenuActions?(contextMenuEvent: JQueryEventObject, activePageActions: ActionMetaInfo[]): Promise<ActionMetaInfo[]>;
  259. }
  260. export interface TradingQuotes {
  261. trade?: number;
  262. size?: number;
  263. bid?: number;
  264. bid_size?: number;
  265. ask?: number;
  266. ask_size?: number;
  267. spread?: number;
  268. }
  269. export interface ActionDescription {
  270. text?: '-' | string;
  271. separator?: boolean;
  272. shortcut?: string;
  273. tooltip?: string;
  274. checked?: boolean;
  275. checkable?: boolean;
  276. enabled?: boolean;
  277. externalLink?: boolean;
  278. }
  279. export interface MenuSeparator extends ActionDescription {
  280. separator: boolean;
  281. }
  282. export interface ActionDescriptionWithCallback extends ActionDescription {
  283. action: (a: ActionDescription) => void;
  284. }
  285. export declare type ActionMetaInfo = ActionDescriptionWithCallback | MenuSeparator;
  286. export interface AccountManagerSummaryField {
  287. text: string;
  288. wValue: IWatchedValueReadonly<number>;
  289. formatter?: string;
  290. }
  291. export interface OrderDurationMetaInfo {
  292. hasDatePicker?: boolean;
  293. hasTimePicker?: boolean;
  294. name: string;
  295. value: string;
  296. }
  297. export interface OrderDuration {
  298. type: string;
  299. datetime?: number;
  300. }
  301. export interface BrokerConfigFlags {
  302. showQuantityInsteadOfAmount?: boolean;
  303. supportOrderBrackets?: boolean;
  304. supportPositionBrackets?: boolean;
  305. supportTradeBrackets?: boolean;
  306. supportTrades?: boolean;
  307. supportClosePosition?: boolean;
  308. supportCloseTrade?: boolean;
  309. supportEditAmount?: boolean;
  310. supportLevel2Data?: boolean;
  311. supportMultiposition?: boolean;
  312. supportPLUpdate?: boolean;
  313. supportReducePosition?: boolean;
  314. supportReversePosition?: boolean;
  315. supportStopLimitOrders?: boolean;
  316. supportDemoLiveSwitcher?: boolean;
  317. supportCustomPlaceOrderTradableCheck?: boolean;
  318. supportMarketBrackets?: boolean;
  319. supportSymbolSearch?: boolean;
  320. supportModifyDuration?: boolean;
  321. requiresFIFOCloseTrades?: boolean;
  322. supportBottomWidget?: boolean;
  323. /**
  324. * @deprecated
  325. */
  326. supportBrackets?: boolean;
  327. }
  328. export interface SingleBrokerMetaInfo {
  329. configFlags: BrokerConfigFlags;
  330. customNotificationFields?: string[];
  331. durations?: OrderDurationMetaInfo[];
  332. }
  333. export interface Brackets {
  334. stopLoss?: number;
  335. takeProfit?: number;
  336. }
  337. export interface DefaultContextMenuActionsParams {
  338. }
  339. export interface DefaultDropdownActionsParams {
  340. showFloatingToolbar?: boolean;
  341. showDOM?: boolean;
  342. tradingProperties?: boolean;
  343. selectAnotherBroker?: boolean;
  344. disconnect?: boolean;
  345. showHowToUse?: boolean;
  346. }
  347. export interface ITradeContext {
  348. symbol: string;
  349. displaySymbol: string;
  350. value: number | null;
  351. formattedValue: string;
  352. last: number;
  353. }
  354. export interface QuotesBase {
  355. change: number;
  356. change_percent: number;
  357. last_price: number;
  358. fractional: number;
  359. minmov: number;
  360. minmove2: number;
  361. pricescale: number;
  362. description: string;
  363. }
  364. export interface IBrokerConnectionAdapterFactory {
  365. createDelegate<T extends Function>(): IDelegate<T>;
  366. createWatchedValue<T>(value?: T): IWatchedValue<T>;
  367. }
  368. export interface IBrokerConnectionAdapterHost {
  369. factory: IBrokerConnectionAdapterFactory;
  370. connectionStatusUpdate(status: ConnectionStatus, message?: string): void;
  371. defaultFormatter(symbol: string): Promise<IFormatter>;
  372. numericFormatter(decimalPlaces: number): Promise<IFormatter>;
  373. defaultContextMenuActions(context: ITradeContext, params?: DefaultContextMenuActionsParams): Promise<ActionMetaInfo[]>;
  374. defaultDropdownMenuActions(options?: Partial<DefaultDropdownActionsParams>): ActionMetaInfo[];
  375. floatingTradingPanelVisibility(): IWatchedValue<boolean>;
  376. domVisibility(): IWatchedValue<boolean>;
  377. patchConfig(config: Partial<BrokerConfigFlags>): void;
  378. setDurations(durations: OrderDurationMetaInfo[]): void;
  379. orderUpdate(order: Order, isHistoryUpdate?: boolean): void;
  380. orderPartialUpdate(id: string, orderChanges: Partial<Order>): void;
  381. positionUpdate(position: Position, isHistoryUpdate?: boolean): void;
  382. positionPartialUpdate(id: string, positionChanges: Partial<Position>): void;
  383. tradeUpdate(trade: Trade, isHistoryUpdate?: boolean): void;
  384. tradePartialUpdate(id: string, tradeChanges: Partial<Trade>): void;
  385. executionUpdate(execution: Execution, isHistoryUpdate?: boolean): void;
  386. fullUpdate(): void;
  387. realtimeUpdate(symbol: string, data: TradingQuotes): void;
  388. plUpdate(positionId: string, pl: number): void;
  389. tradePLUpdate(tradeId: string, pl: number): void;
  390. equityUpdate(equity: number): void;
  391. domeUpdate(symbol: string, equity: DOMData): void;
  392. showOrderDialog<T extends PreOrder>(order: T, handler: (order: T) => Promise<void>, focus?: OrderTicketFocusControl): Promise<void>;
  393. showCancelOrderDialog(orderId: string, handler: () => void): Promise<void>;
  394. showCancelMultipleOrdersDialog(symbol: string, side: Side | undefined, qty: number, handler: () => void): Promise<void>;
  395. showCancelBracketsDialog(orderId: string, handler: () => void): Promise<void>;
  396. showCancelMultipleBracketsDialog(orderId: string, handler: () => void): Promise<void>;
  397. showClosePositionDialog(positionId: string, handler: () => void): Promise<void>;
  398. showReversePositionDialog(position: Position, handler: () => void): Promise<void>;
  399. showPositionBracketsDialog(position: Position | Trade, brackets: Brackets, focus: OrderTicketFocusControl | null, handler: (brackets: Brackets) => void): Promise<void>;
  400. showNotification(title: string, text: string, notificationType?: NotificationType): void;
  401. setButtonDropdownActions(descriptions: ActionMetaInfo[]): void;
  402. activateBottomWidget(): Promise<void>;
  403. showTradingProperties(): void;
  404. symbolSnapshot(symbol: string): Promise<QuotesBase>;
  405. }
  406. export interface IBrokerCommon {
  407. chartContextMenuActions(context: ITradeContext, options?: DefaultContextMenuActionsParams): Promise<ActionMetaInfo[]>;
  408. isTradable(symbol: string): Promise<boolean>;
  409. connectionStatus(): ConnectionStatus;
  410. placeOrder(order: PreOrder, silently?: boolean): Promise<void>;
  411. modifyOrder(order: Order, silently?: boolean, focus?: OrderTicketFocusControl): Promise<void>;
  412. orders(): Promise<Order[]>;
  413. positions(): Promise<Position[]>;
  414. trades?(): Promise<Trade[]>;
  415. executions(symbol: string): Promise<Execution[]>;
  416. symbolInfo(symbol: string): Promise<InstrumentInfo>;
  417. accountInfo(): Promise<AccountInfo>;
  418. editPositionBrackets?(positionId: string, focus?: OrderTicketFocusControl, brackets?: Brackets, silently?: boolean): Promise<void>;
  419. editTradeBrackets?(tradeId: string, focus?: OrderTicketFocusControl, brackets?: Brackets, silently?: boolean): Promise<void>;
  420. accountManagerInfo(): AccountManagerInfo;
  421. formatter?(symbol: string): Promise<IFormatter>;
  422. spreadFormatter?(symbol: string): Promise<IFormatter>;
  423. }
  424. export interface IBrokerWithoutRealtime extends IBrokerCommon {
  425. subscribeDOME?(symbol: string): void;
  426. unsubscribeDOME?(symbol: string): void;
  427. cancelOrder(orderId: string, silently: boolean): Promise<void>;
  428. cancelOrders(symbol: string, side: Side | undefined, ordersIds: string[], silently: boolean): Promise<void>;
  429. reversePosition?(positionId: string, silently?: boolean): Promise<void>;
  430. closePosition(positionId: string, silently: boolean): Promise<void>;
  431. closeTrade?(tradeId: string, silently: boolean): Promise<void>;
  432. /**
  433. * @deprecated Brokers should always send PL and equity updates
  434. */
  435. subscribePL?(positionId: string): void;
  436. subscribeEquity?(): void;
  437. /**
  438. * @deprecated
  439. */
  440. unsubscribePL?(positionId: string): void;
  441. unsubscribeEquity?(): void;
  442. }
  443. export interface IBrokerTerminal extends IBrokerWithoutRealtime {
  444. subscribeRealtime(symbol: string): void;
  445. unsubscribeRealtime(symbol: string): void;
  446. }
  447. export declare type ResolutionString = string;
  448. export interface Exchange {
  449. value: string;
  450. name: string;
  451. desc: string;
  452. }
  453. export interface DatafeedSymbolType {
  454. name: string;
  455. value: string;
  456. }
  457. export interface DatafeedConfiguration {
  458. exchanges?: Exchange[];
  459. supported_resolutions?: ResolutionString[];
  460. supports_marks?: boolean;
  461. supports_time?: boolean;
  462. supports_timescale_marks?: boolean;
  463. symbols_types?: DatafeedSymbolType[];
  464. }
  465. export declare type OnReadyCallback = (configuration: DatafeedConfiguration) => void;
  466. export interface IExternalDatafeed {
  467. onReady(callback: OnReadyCallback): void;
  468. }
  469. export interface DatafeedQuoteValues {
  470. ch?: number;
  471. chp?: number;
  472. short_name?: string;
  473. exchange?: string;
  474. description?: string;
  475. lp?: number;
  476. ask?: number;
  477. bid?: number;
  478. spread?: number;
  479. open_price?: number;
  480. high_price?: number;
  481. low_price?: number;
  482. prev_close_price?: number;
  483. volume?: number;
  484. original_name?: string;
  485. [valueName: string]: string | number | undefined;
  486. }
  487. export interface QuoteOkData {
  488. s: 'ok';
  489. n: string;
  490. v: DatafeedQuoteValues;
  491. }
  492. export interface QuoteErrorData {
  493. s: 'error';
  494. n: string;
  495. v: object;
  496. }
  497. export declare type QuoteData = QuoteOkData | QuoteErrorData;
  498. export declare type QuotesCallback = (data: QuoteData[]) => void;
  499. export interface IDatafeedQuotesApi {
  500. getQuotes(symbols: string[], onDataCallback: QuotesCallback, onErrorCallback: (msg: string) => void): void;
  501. subscribeQuotes(symbols: string[], fastSymbols: string[], onRealtimeCallback: QuotesCallback, listenerGUID: string): void;
  502. unsubscribeQuotes(listenerGUID: string): void;
  503. }
  504. export declare type CustomTimezones = 'America/New_York' | 'America/Los_Angeles' | 'America/Chicago' | 'America/Phoenix' | 'America/Toronto' | 'America/Vancouver' | 'America/Argentina/Buenos_Aires' | 'America/El_Salvador' | 'America/Sao_Paulo' | 'America/Bogota' | 'America/Caracas' | 'Europe/Moscow' | 'Europe/Athens' | 'Europe/Berlin' | 'Europe/London' | 'Europe/Madrid' | 'Europe/Paris' | 'Europe/Rome' | 'Europe/Warsaw' | 'Europe/Istanbul' | 'Europe/Zurich' | 'Australia/Sydney' | 'Australia/Brisbane' | 'Australia/Adelaide' | 'Australia/ACT' | 'Asia/Almaty' | 'Asia/Ashkhabad' | 'Asia/Tokyo' | 'Asia/Taipei' | 'Asia/Singapore' | 'Asia/Shanghai' | 'Asia/Seoul' | 'Asia/Tehran' | 'Asia/Dubai' | 'Asia/Kolkata' | 'Asia/Hong_Kong' | 'Asia/Bangkok' | 'Pacific/Auckland' | 'Pacific/Chatham' | 'Pacific/Fakaofo' | 'Pacific/Honolulu' | 'America/Mexico_City' | 'Africa/Johannesburg' | 'Asia/Kathmandu' | 'US/Mountain';
  505. export declare type Timezone = 'UTC' | CustomTimezones;
  506. export interface LibrarySymbolInfo {
  507. /**
  508. * Symbol Name
  509. */
  510. name: string;
  511. full_name: string;
  512. base_name?: [string];
  513. /**
  514. * Unique symbol id
  515. */
  516. ticker?: string;
  517. description: string;
  518. type: string;
  519. /**
  520. * @example "1700-0200"
  521. */
  522. session: string;
  523. /**
  524. * Traded exchange
  525. * @example "NYSE"
  526. */
  527. exchange: string;
  528. listed_exchange: string;
  529. timezone: Timezone;
  530. /**
  531. * Code (Tick)
  532. * @example 8/16/.../256 (1/8/100 1/16/100 ... 1/256/100) or 1/10/.../10000000 (1 0.1 ... 0.0000001)
  533. */
  534. pricescale: number;
  535. /**
  536. * The number of units that make up one tick.
  537. * @example For example, U.S. equities are quotes in decimals, and tick in decimals, and can go up +/- .01. So the tick increment is 1. But the e-mini S&P futures contract, though quoted in decimals, goes up in .25 increments, so the tick increment is 25. (see also Tick Size)
  538. */
  539. minmov: number;
  540. fractional?: boolean;
  541. /**
  542. * @example Quarters of 1/32: pricescale=128, minmovement=1, minmovement2=4
  543. */
  544. minmove2?: number;
  545. /**
  546. * false if DWM only
  547. */
  548. has_intraday?: boolean;
  549. /**
  550. * An array of resolutions which should be enabled in resolutions picker for this symbol.
  551. */
  552. supported_resolutions: ResolutionString[];
  553. /**
  554. * @example (for ex.: "1,5,60") - only these resolutions will be requested, all others will be built using them if possible
  555. */
  556. intraday_multipliers?: string[];
  557. has_seconds?: boolean;
  558. /**
  559. * It is an array containing seconds resolutions (in seconds without a postfix) the datafeed builds by itself.
  560. */
  561. seconds_multipliers?: string[];
  562. has_daily?: boolean;
  563. has_weekly_and_monthly?: boolean;
  564. has_empty_bars?: boolean;
  565. force_session_rebuild?: boolean;
  566. has_no_volume?: boolean;
  567. /**
  568. * Integer showing typical volume value decimal places for this symbol
  569. */
  570. volume_precision?: number;
  571. data_status?: 'streaming' | 'endofday' | 'pulsed' | 'delayed_streaming';
  572. /**
  573. * Boolean showing whether this symbol is expired futures contract or not.
  574. */
  575. expired?: boolean;
  576. /**
  577. * Unix timestamp of expiration date.
  578. */
  579. expiration_date?: number;
  580. sector?: string;
  581. industry?: string;
  582. currency_code?: string;
  583. }
  584. export interface Bar {
  585. time: number;
  586. open: number;
  587. high: number;
  588. low: number;
  589. close: number;
  590. volume?: number;
  591. }
  592. export interface SearchSymbolResultItem {
  593. symbol: string;
  594. full_name: string;
  595. description: string;
  596. exchange: string;
  597. ticker: string;
  598. type: string;
  599. }
  600. export interface HistoryMetadata {
  601. noData: boolean;
  602. nextTime?: number | null;
  603. }
  604. export interface MarkCustomColor {
  605. color: string;
  606. background: string;
  607. }
  608. export declare type MarkConstColors = 'red' | 'green' | 'blue' | 'yellow';
  609. export interface Mark {
  610. id: string | number;
  611. time: number;
  612. color: MarkConstColors | MarkCustomColor;
  613. text: string;
  614. label: string;
  615. labelFontColor: string;
  616. minSize: number;
  617. }
  618. export interface TimescaleMark {
  619. id: string | number;
  620. time: number;
  621. color: MarkConstColors | string;
  622. label: string;
  623. tooltip: string[];
  624. }
  625. export declare type ResolutionBackValues = 'D' | 'M';
  626. export interface HistoryDepth {
  627. resolutionBack: ResolutionBackValues;
  628. intervalBack: number;
  629. }
  630. export declare type SearchSymbolsCallback = (items: SearchSymbolResultItem[]) => void;
  631. export declare type ResolveCallback = (symbolInfo: LibrarySymbolInfo) => void;
  632. export declare type HistoryCallback = (bars: Bar[], meta: HistoryMetadata) => void;
  633. export declare type SubscribeBarsCallback = (bar: Bar) => void;
  634. export declare type GetMarksCallback<T> = (marks: T[]) => void;
  635. export declare type ServerTimeCallback = (serverTime: number) => void;
  636. export declare type DomeCallback = (data: DOMData) => void;
  637. export declare type ErrorCallback = (reason: string) => void;
  638. export interface IDatafeedChartApi {
  639. calculateHistoryDepth?(resolution: ResolutionString, resolutionBack: ResolutionBackValues, intervalBack: number): HistoryDepth | undefined;
  640. getMarks?(symbolInfo: LibrarySymbolInfo, startDate: number, endDate: number, onDataCallback: GetMarksCallback<Mark>, resolution: ResolutionString): void;
  641. getTimescaleMarks?(symbolInfo: LibrarySymbolInfo, startDate: number, endDate: number, onDataCallback: GetMarksCallback<TimescaleMark>, resolution: ResolutionString): void;
  642. /**
  643. * This function is called if configuration flag supports_time is set to true when chart needs to know the server time.
  644. * The charting library expects callback to be called once.
  645. * The time is provided without milliseconds. Example: 1445324591. It is used to display Countdown on the price scale.
  646. */
  647. getServerTime?(callback: ServerTimeCallback): void;
  648. searchSymbols(userInput: string, exchange: string, symbolType: string, onResult: SearchSymbolsCallback): void;
  649. resolveSymbol(symbolName: string, onResolve: ResolveCallback, onError: ErrorCallback): void;
  650. getBars(symbolInfo: LibrarySymbolInfo, resolution: ResolutionString, rangeStartDate: number, rangeEndDate: number, onResult: HistoryCallback, onError: ErrorCallback, isFirstCall: boolean): void;
  651. subscribeBars(symbolInfo: LibrarySymbolInfo, resolution: ResolutionString, onTick: SubscribeBarsCallback, listenerGuid: string, onResetCacheNeededCallback: () => void): void;
  652. unsubscribeBars(listenerGuid: string): void;
  653. subscribeDepth?(symbolInfo: LibrarySymbolInfo, callback: DomeCallback): string;
  654. unsubscribeDepth?(subscriberUID: string): void;
  655. }
  656. export interface ChartMetaInfo {
  657. id: string;
  658. name: string;
  659. symbol: string;
  660. resolution: ResolutionString;
  661. timestamp: number;
  662. }
  663. export interface ChartData {
  664. id: string;
  665. name: string;
  666. symbol: string;
  667. resolution: ResolutionString;
  668. content: string;
  669. }
  670. export interface StudyTemplateMetaInfo {
  671. name: string;
  672. }
  673. export interface StudyTemplateData {
  674. name: string;
  675. content: string;
  676. }
  677. export interface IExternalSaveLoadAdapter {
  678. getAllCharts(): Promise<ChartMetaInfo[]>;
  679. removeChart(chartId: string): Promise<void>;
  680. saveChart(chartData: ChartData): Promise<string>;
  681. getChartContent(chartId: string): Promise<string>;
  682. getAllStudyTemplates(): Promise<StudyTemplateMetaInfo[]>;
  683. removeStudyTemplate(studyTemplateInfo: StudyTemplateMetaInfo): Promise<void>;
  684. saveStudyTemplate(studyTemplateData: StudyTemplateData): Promise<void>;
  685. getStudyTemplateContent(studyTemplateInfo: StudyTemplateMetaInfo): Promise<string>;
  686. }
  687. export interface RestBrokerMetaInfo {
  688. url: string;
  689. access_token: string;
  690. }
  691. export interface AccessListItem {
  692. name: string;
  693. grayed?: boolean;
  694. }
  695. export interface AccessList {
  696. type: 'black' | 'white';
  697. tools: AccessListItem[];
  698. }
  699. export interface NumericFormattingParams {
  700. decimal_sign: string;
  701. }
  702. export declare type AvailableSaveloadVersions = '1.0' | '1.1';
  703. export interface Overrides {
  704. [key: string]: string | number | boolean;
  705. }
  706. export interface WidgetBarParams {
  707. details?: boolean;
  708. watchlist?: boolean;
  709. news?: boolean;
  710. watchlist_settings?: {
  711. default_symbols: string[];
  712. readonly?: boolean;
  713. };
  714. }
  715. export interface RssNewsFeedInfo {
  716. url: string;
  717. name: string;
  718. }
  719. export declare type RssNewsFeedItem = RssNewsFeedInfo | RssNewsFeedInfo[];
  720. export interface RssNewsFeedParams {
  721. default: RssNewsFeedItem;
  722. [symbolType: string]: RssNewsFeedItem;
  723. }
  724. export interface NewsProvider {
  725. is_news_generic?: boolean;
  726. get_news(symbol: string, callback: (items: NewsItem[]) => void): void;
  727. }
  728. export interface CustomFormatter {
  729. format(date: Date): string;
  730. formatLocal(date: Date): string;
  731. }
  732. export interface CustomFormatters {
  733. timeFormatter: CustomFormatter;
  734. dateFormatter: CustomFormatter;
  735. }
  736. export interface TimeFrameItem {
  737. text: string;
  738. resolution: ResolutionString;
  739. description?: string;
  740. title?: string;
  741. }
  742. export interface Favorites {
  743. intervals: ResolutionString[];
  744. chartTypes: string[];
  745. }
  746. export interface NewsItem {
  747. fullDescription: string;
  748. link?: string;
  749. published: number;
  750. shortDescription?: string;
  751. source: string;
  752. title: string;
  753. }
  754. export interface LoadingScreenOptions {
  755. foregroundColor?: string;
  756. backgroundColor?: string;
  757. }
  758. export interface InitialSettingsMap {
  759. [key: string]: string;
  760. }
  761. export interface ISettingsAdapter {
  762. initialSettings?: InitialSettingsMap;
  763. setValue(key: string, value: string): void;
  764. removeValue(key: string): void;
  765. }
  766. export declare type IBasicDataFeed = IDatafeedChartApi & IExternalDatafeed;
  767. export interface ChartingLibraryWidgetOptions {
  768. container_id: string;
  769. datafeed: IBasicDataFeed | (IBasicDataFeed & IDatafeedQuotesApi);
  770. interval: ResolutionString;
  771. symbol: string;
  772. auto_save_delay?: number;
  773. autosize?: boolean;
  774. debug?: boolean;
  775. disabled_features?: string[];
  776. drawings_access?: AccessList;
  777. enabled_features?: string[];
  778. fullscreen?: boolean;
  779. height?: number;
  780. library_path?: string;
  781. locale: LanguageCode;
  782. numeric_formatting?: NumericFormattingParams;
  783. saved_data?: object;
  784. studies_access?: AccessList;
  785. study_count_limit?: number;
  786. symbol_search_request_delay?: number;
  787. timeframe?: string;
  788. timezone?: 'exchange' | Timezone;
  789. toolbar_bg?: string;
  790. width?: number;
  791. charts_storage_url?: string;
  792. charts_storage_api_version?: AvailableSaveloadVersions;
  793. client_id?: string;
  794. user_id?: string;
  795. load_last_chart?: boolean;
  796. studies_overrides?: StudyOverrides;
  797. customFormatters?: CustomFormatters;
  798. overrides?: Overrides;
  799. snapshot_url?: string;
  800. indicators_file_name?: string;
  801. preset?: 'mobile';
  802. time_frames?: TimeFrameItem[];
  803. custom_css_url?: string;
  804. favorites?: Favorites;
  805. save_load_adapter?: IExternalSaveLoadAdapter;
  806. loading_screen?: LoadingScreenOptions;
  807. settings_adapter?: ISettingsAdapter;
  808. }
  809. export interface TradingTerminalWidgetOptions extends ChartingLibraryWidgetOptions {
  810. brokerConfig?: SingleBrokerMetaInfo;
  811. restConfig?: RestBrokerMetaInfo;
  812. widgetbar?: WidgetBarParams;
  813. rss_news_feed?: RssNewsFeedParams;
  814. news_provider?: NewsProvider;
  815. brokerFactory?(host: IBrokerConnectionAdapterHost): IBrokerWithoutRealtime | IBrokerTerminal;
  816. }
  817. export declare type LayoutType = 's' | '2h' | '2-1' | '2v' | '3h' | '3v' | '3s' | '4' | '6' | '8';
  818. export declare type SupportedLineTools = 'text' | 'anchored_text' | 'note' | 'anchored_note' | 'double_curve' | 'arc' | 'icon' | 'arrow_up' | 'arrow_down' | 'arrow_left' | 'arrow_right' | 'price_label' | 'flag' | 'vertical_line' | 'horizontal_line' | 'horizontal_ray' | 'trend_line' | 'trend_angle' | 'arrow' | 'ray' | 'extended' | 'parallel_channel' | 'disjoint_angle' | 'flat_bottom' | 'pitchfork' | 'schiff_pitchfork_modified' | 'schiff_pitchfork' | 'balloon' | 'inside_pitchfork' | 'pitchfan' | 'gannbox' | 'gannbox_square' | 'gannbox_fan' | 'fib_retracement' | 'fib_trend_ext' | 'fib_speed_resist_fan' | 'fib_timezone' | 'fib_trend_time' | 'fib_circles' | 'fib_spiral' | 'fib_speed_resist_arcs' | 'fib_channel' | 'xabcd_pattern' | 'cypher_pattern' | 'abcd_pattern' | 'callout' | 'triangle_pattern' | '3divers_pattern' | 'head_and_shoulders' | 'fib_wedge' | 'elliott_impulse_wave' | 'elliott_triangle_wave' | 'elliott_triple_combo' | 'elliott_correction' | 'elliott_double_combo' | 'cyclic_lines' | 'time_cycles' | 'sine_line' | 'long_position' | 'short_position' | 'forecast' | 'date_range' | 'price_range' | 'date_and_price_range' | 'bars_pattern' | 'ghost_feed' | 'projection' | 'rectangle' | 'rotated_rectangle' | 'ellipse' | 'triangle' | 'polyline' | 'curve' | 'regression_trend' | 'cursor' | 'dot' | 'arrow_cursor' | 'eraser' | 'measure' | 'zoom' | 'brush';
  819. export interface IOrderLineAdapter {
  820. remove(): void;
  821. onModify(callback: () => void): this;
  822. onModify<T>(data: T, callback: (data: T) => void): this;
  823. onMove(callback: () => void): this;
  824. onMove<T>(data: T, callback: (data: T) => void): this;
  825. getPrice(): number;
  826. setPrice(value: number): this;
  827. getText(): string;
  828. setText(value: string): this;
  829. getTooltip(): string;
  830. setTooltip(value: string): this;
  831. getQuantity(): string;
  832. setQuantity(value: string): this;
  833. getEditable(): boolean;
  834. setEditable(value: boolean): this;
  835. getExtendLeft(): boolean;
  836. setExtendLeft(value: boolean): this;
  837. getLineLength(): number;
  838. setLineLength(value: number): this;
  839. getLineStyle(): number;
  840. setLineStyle(value: number): this;
  841. getLineWidth(): number;
  842. setLineWidth(value: number): this;
  843. getBodyFont(): string;
  844. setBodyFont(value: string): this;
  845. getQuantityFont(): string;
  846. setQuantityFont(value: string): this;
  847. getLineColor(): string;
  848. setLineColor(value: string): this;
  849. getBodyBorderColor(): string;
  850. setBodyBorderColor(value: string): this;
  851. getBodyBackgroundColor(): string;
  852. setBodyBackgroundColor(value: string): this;
  853. getBodyTextColor(): string;
  854. setBodyTextColor(value: string): this;
  855. getQuantityBorderColor(): string;
  856. setQuantityBorderColor(value: string): this;
  857. getQuantityBackgroundColor(): string;
  858. setQuantityBackgroundColor(value: string): this;
  859. getQuantityTextColor(): string;
  860. setQuantityTextColor(value: string): this;
  861. getCancelButtonBorderColor(): string;
  862. setCancelButtonBorderColor(value: string): this;
  863. getCancelButtonBackgroundColor(): string;
  864. setCancelButtonBackgroundColor(value: string): this;
  865. getCancelButtonIconColor(): string;
  866. setCancelButtonIconColor(value: string): this;
  867. }
  868. export interface IPositionLineAdapter {
  869. remove(): void;
  870. onClose(callback: () => void): this;
  871. onClose<T>(data: T, callback: (data: T) => void): this;
  872. onModify(callback: () => void): this;
  873. onModify<T>(data: T, callback: (data: T) => void): this;
  874. onReverse(callback: () => void): this;
  875. onReverse<T>(data: T, callback: (data: T) => void): this;
  876. getPrice(): number;
  877. setPrice(value: number): this;
  878. getText(): string;
  879. setText(value: string): this;
  880. getTooltip(): string;
  881. setTooltip(value: string): this;
  882. getQuantity(): string;
  883. setQuantity(value: string): this;
  884. getExtendLeft(): boolean;
  885. setExtendLeft(value: boolean): this;
  886. getLineLength(): number;
  887. setLineLength(value: number): this;
  888. getLineStyle(): number;
  889. setLineStyle(value: number): this;
  890. getLineWidth(): number;
  891. setLineWidth(value: number): this;
  892. getBodyFont(): string;
  893. setBodyFont(value: string): this;
  894. getQuantityFont(): string;
  895. setQuantityFont(value: string): this;
  896. getLineColor(): string;
  897. setLineColor(value: string): this;
  898. getBodyBorderColor(): string;
  899. setBodyBorderColor(value: string): this;
  900. getBodyBackgroundColor(): string;
  901. setBodyBackgroundColor(value: string): this;
  902. getBodyTextColor(): string;
  903. setBodyTextColor(value: string): this;
  904. getQuantityBorderColor(): string;
  905. setQuantityBorderColor(value: string): this;
  906. getQuantityBackgroundColor(): string;
  907. setQuantityBackgroundColor(value: string): this;
  908. getQuantityTextColor(): string;
  909. setQuantityTextColor(value: string): this;
  910. getReverseButtonBorderColor(): string;
  911. setReverseButtonBorderColor(value: string): this;
  912. getReverseButtonBackgroundColor(): string;
  913. setReverseButtonBackgroundColor(value: string): this;
  914. getReverseButtonIconColor(): string;
  915. setReverseButtonIconColor(value: string): this;
  916. getCloseButtonBorderColor(): string;
  917. setCloseButtonBorderColor(value: string): this;
  918. getCloseButtonBackgroundColor(): string;
  919. setCloseButtonBackgroundColor(value: string): this;
  920. getCloseButtonIconColor(): string;
  921. setCloseButtonIconColor(value: string): this;
  922. }
  923. export declare type Direction = 'buy' | 'sell';
  924. export interface IExecutionLineAdapter {
  925. remove(): void;
  926. getPrice(): number;
  927. setPrice(value: number): this;
  928. getTime(): number;
  929. setTime(value: number): this;
  930. getDirection(): Direction;
  931. setDirection(value: Direction): this;
  932. getText(): string;
  933. setText(value: string): this;
  934. getTooltip(): string;
  935. setTooltip(value: string): this;
  936. getArrowHeight(): number;
  937. setArrowHeight(value: number): this;
  938. getArrowSpacing(): number;
  939. setArrowSpacing(value: number): this;
  940. getFont(): string;
  941. setFont(value: string): this;
  942. getTextColor(): string;
  943. setTextColor(value: string): this;
  944. getArrowColor(): string;
  945. setArrowColor(value: string): this;
  946. }
  947. export declare type StudyInputId = Nominal<string, 'StudyInputId'>;
  948. export interface StudyInputInfo {
  949. id: StudyInputId;
  950. name: string;
  951. type: string;
  952. localizedName: string;
  953. }
  954. export interface StudyInputValueItem {
  955. id: StudyInputId;
  956. value: StudyInputValueType;
  957. }
  958. export interface IStudyApi {
  959. isUserEditEnabled(): boolean;
  960. setUserEditEnabled(enabled: boolean): void;
  961. getInputsInfo(): StudyInputInfo[];
  962. getInputValues(): StudyInputValueItem[];
  963. setInputValues(values: StudyInputValueItem[]): void;
  964. mergeUp(): void;
  965. mergeDown(): void;
  966. unmergeUp(): void;
  967. unmergeDown(): void;
  968. isVisible(): boolean;
  969. setVisible(visible: boolean): void;
  970. bringToFront(): void;
  971. sendToBack(): void;
  972. applyOverrides<TOverrides extends StudyOverrides>(overrides: TOverrides): void;
  973. }
  974. export interface TimePoint {
  975. time: number;
  976. }
  977. export interface StickedPoint extends TimePoint {
  978. channel: 'open' | 'high' | 'low' | 'close';
  979. }
  980. export interface PricedPoint extends TimePoint {
  981. price: number;
  982. }
  983. export declare type ShapePoint = StickedPoint | PricedPoint | TimePoint;
  984. export interface ILineDataSourceApi {
  985. isSelectionEnabled(): boolean;
  986. setSelectionEnabled(enable: boolean): void;
  987. isSavingEnabled(): boolean;
  988. setSavingEnabled(enable: boolean): void;
  989. isShowInObjectsTreeEnabled(): boolean;
  990. setShowInObjectsTreeEnabled(enabled: boolean): void;
  991. isUserEditEnabled(): boolean;
  992. setUserEditEnabled(enabled: boolean): void;
  993. bringToFront(): void;
  994. sendToBack(): void;
  995. getProperties(): object;
  996. setProperties(newProperties: object): void;
  997. getPoints(): PricedPoint[];
  998. setPoints(points: ShapePoint[]): void;
  999. }
  1000. export interface CrossHairMovedEventParams {
  1001. time: number;
  1002. price: number;
  1003. }
  1004. export interface VisibleTimeRange {
  1005. from: number;
  1006. to: number;
  1007. }
  1008. export interface VisiblePriceRange {
  1009. from: number;
  1010. to: number;
  1011. }
  1012. export declare type ChartActionId = 'chartProperties' | 'compareOrAdd' | 'scalesProperties' | 'tmzProperties' | 'paneObjectTree' | 'insertIndicator' | 'symbolSearch' | 'changeInterval' | 'timeScaleReset' | 'chartReset' | 'seriesHide' | 'studyHide' | 'lineToggleLock' | 'lineHide' | 'showLeftAxis' | 'showRightAxis' | 'scaleSeriesOnly' | 'drawingToolbarAction' | 'magnetAction' | 'stayInDrawingModeAction' | 'lockDrawingsAction' | 'hideAllDrawingsAction' | 'hideAllMarks' | 'showCountdown' | 'showSeriesLastValue' | 'showSymbolLabelsAction' | 'showStudyLastValue' | 'showStudyPlotNamesAction' | 'undo' | 'redo' | 'takeScreenshot' | 'paneRemoveAllStudiesDrawingTools';
  1013. export declare const enum SeriesStyle {
  1014. Bars = 0,
  1015. Candles = 1,
  1016. Line = 2,
  1017. Area = 3,
  1018. HeikenAshi = 8,
  1019. HollowCandles = 9,
  1020. Renko = 4,
  1021. Kagi = 5,
  1022. PointAndFigure = 6,
  1023. LineBreak = 7,
  1024. }
  1025. export declare type EntityId = Nominal<string, 'EntityId'>;
  1026. export interface EntityInfo {
  1027. id: EntityId;
  1028. name: string;
  1029. }
  1030. export interface CreateStudyOptions {
  1031. checkLimit: boolean;
  1032. }
  1033. export interface CreateShapeOptions<TOverrides extends object> {
  1034. shape?: 'arrow_up' | 'arrow_down' | 'flag' | 'vertical_line' | 'horizontal_line';
  1035. text?: string;
  1036. lock?: boolean;
  1037. disableSelection?: boolean;
  1038. disableSave?: boolean;
  1039. disableUndo?: boolean;
  1040. overrides?: TOverrides;
  1041. zOrder?: 'top' | 'bottom';
  1042. showInObjectsTree?: boolean;
  1043. }
  1044. export interface CreateStudyTemplateOptions {
  1045. saveInterval?: boolean;
  1046. }
  1047. export interface SymbolExt {
  1048. symbol: string;
  1049. full_name: string;
  1050. exchange: string;
  1051. description: string;
  1052. type: string;
  1053. }
  1054. export interface CreateTradingPrimitiveOptions {
  1055. disableUndo?: boolean;
  1056. }
  1057. export interface IChartWidgetApi {
  1058. onDataLoaded(): ISubscription<() => void>;
  1059. onSymbolChanged(): ISubscription<() => void>;
  1060. onIntervalChanged(): ISubscription<(interval: ResolutionString, timeFrameParameters: {
  1061. timeframe?: string;
  1062. }) => void>;
  1063. dataReady(callback: () => void): boolean;
  1064. crossHairMoved(callback: (params: CrossHairMovedEventParams) => void): void;
  1065. setVisibleRange(range: VisibleTimeRange, callback: () => void): void;
  1066. setSymbol(symbol: string, callback: () => void): void;
  1067. setResolution(resolution: ResolutionString, callback: () => void): void;
  1068. resetData(): void;
  1069. executeActionById(actionId: ChartActionId): void;
  1070. getCheckableActionState(actionId: ChartActionId): boolean;
  1071. refreshMarks(): void;
  1072. clearMarks(): void;
  1073. setChartType(type: SeriesStyle): void;
  1074. getAllShapes(): EntityInfo[];
  1075. getAllStudies(): EntityInfo[];
  1076. /**
  1077. * @deprecated Use shape/study API instead ([getStudyById] / [getShapeById])
  1078. */
  1079. setEntityVisibility(entityId: EntityId, isVisible: boolean): void;
  1080. createStudy<TStudyInputs extends StudyInputValueType, TOverrides extends StudyOverrides>(name: string, forceOverlay: boolean, lock?: boolean, inputs?: TStudyInputs[], callback?: (entityId: EntityId) => void, overrides?: TOverrides, options?: CreateStudyOptions): EntityId | null;
  1081. getStudyById(entityId: EntityId): IStudyApi;
  1082. createShape<TOverrides extends object>(point: ShapePoint, options: CreateShapeOptions<TOverrides>): EntityId | null;
  1083. createMultipointShape<TOverrides extends object>(points: ShapePoint[], options: CreateShapeOptions<TOverrides>): EntityId | null;
  1084. getShapeById(entityId: EntityId): ILineDataSourceApi;
  1085. removeEntity(entityId: EntityId): void;
  1086. removeAllShapes(): void;
  1087. removeAllStudies(): void;
  1088. createStudyTemplate(options: CreateStudyTemplateOptions): object;
  1089. applyStudyTemplate(template: object): void;
  1090. createOrderLine(options: CreateTradingPrimitiveOptions): IOrderLineAdapter;
  1091. createPositionLine(options: CreateTradingPrimitiveOptions): IPositionLineAdapter;
  1092. createExecutionShape(options: CreateTradingPrimitiveOptions): IExecutionLineAdapter;
  1093. symbol(): string;
  1094. symbolExt(): SymbolExt;
  1095. resolution(): ResolutionString;
  1096. getVisibleRange(): VisibleTimeRange;
  1097. getVisiblePriceRange(): VisiblePriceRange;
  1098. priceFormatter(): IFormatter;
  1099. chartType(): SeriesStyle;
  1100. setTimezone(timezone: 'exchange' | Timezone): void;
  1101. }
  1102. export declare type EditObjectDialogObjectType = 'mainSeries' | 'drawing' | 'study' | 'other';
  1103. export interface EditObjectDialogEventParams {
  1104. objectType: EditObjectDialogObjectType;
  1105. scriptTitle: string;
  1106. }
  1107. export interface MouseEventParams {
  1108. clientX: number;
  1109. clientY: number;
  1110. pageX: number;
  1111. pageY: number;
  1112. screenX: number;
  1113. screenY: number;
  1114. }
  1115. export interface StudyOrDrawingAddedToChartEventParams {
  1116. value: string;
  1117. }
  1118. export declare type EmptyCallback = () => void;
  1119. export interface SubscribeEventsMap {
  1120. toggle_sidebar: (isHidden: boolean) => void;
  1121. indicators_dialog: EmptyCallback;
  1122. toggle_header: (isHidden: boolean) => void;
  1123. edit_object_dialog: (params: EditObjectDialogEventParams) => void;
  1124. chart_load_requested: (savedData: object) => void;
  1125. chart_loaded: EmptyCallback;
  1126. mouse_down: (params: MouseEventParams) => void;
  1127. mouse_up: (params: MouseEventParams) => void;
  1128. drawing: (params: StudyOrDrawingAddedToChartEventParams) => void;
  1129. study: (params: StudyOrDrawingAddedToChartEventParams) => void;
  1130. undo: EmptyCallback;
  1131. redo: EmptyCallback;
  1132. reset_scales: EmptyCallback;
  1133. compare_add: EmptyCallback;
  1134. add_compare: EmptyCallback;
  1135. 'load_study template': EmptyCallback;
  1136. onTick: (tick: Bar) => void;
  1137. onAutoSaveNeeded: EmptyCallback;
  1138. onScreenshotReady: (url: string) => void;
  1139. onMarkClick: (markId: Mark['id']) => void;
  1140. onTimescaleMarkClick: (markId: TimescaleMark['id']) => void;
  1141. onSelectedLineToolChanged: EmptyCallback;
  1142. layout_about_to_be_changed: (newLayoutType: LayoutType) => void;
  1143. layout_changed: EmptyCallback;
  1144. activeChartChanged: (chartIndex: number) => void;
  1145. }
  1146. export interface SaveChartToServerOptions {
  1147. chartName?: string;
  1148. defaultChartName?: string;
  1149. }
  1150. export interface WatchListApi {
  1151. getList(): string[];
  1152. setList(symbols: string[]): void;
  1153. onListChanged(): ISubscription<EmptyCallback>;
  1154. }
  1155. export interface GrayedObject {
  1156. type: 'drawing' | 'study';
  1157. name: string;
  1158. }
  1159. export interface ContextMenuItem {
  1160. position: 'top' | 'bottom';
  1161. text: string;
  1162. click: EmptyCallback;
  1163. }
  1164. export interface DialogParams<CallbackType> {
  1165. title: string;
  1166. body: string;
  1167. callback: CallbackType;
  1168. }
  1169. export interface SymbolIntervalResult {
  1170. symbol: string;
  1171. interval: ResolutionString;
  1172. }
  1173. export interface SaveLoadChartRecord {
  1174. id: string;
  1175. name: string;
  1176. image_url: string;
  1177. modified_iso: number;
  1178. short_symbol: string;
  1179. interval: ResolutionString;
  1180. }
  1181. export interface CreateButtonOptions {
  1182. align: 'right' | 'left';
  1183. }
  1184. export interface IChartingLibraryWidget {
  1185. onChartReady(callback: EmptyCallback): void;
  1186. onGrayedObjectClicked(callback: (obj: GrayedObject) => void): void;
  1187. onShortcut(shortCut: string, callback: EmptyCallback): void;
  1188. subscribe<EventName extends keyof SubscribeEventsMap>(event: EventName, callback: SubscribeEventsMap[EventName]): void;
  1189. unsubscribe<EventName extends keyof SubscribeEventsMap>(event: EventName, callback: SubscribeEventsMap[EventName]): void;
  1190. chart(index?: number): IChartWidgetApi;
  1191. setLanguage(lang: LanguageCode): void;
  1192. setSymbol(symbol: string, interval: ResolutionString, callback: EmptyCallback): void;
  1193. remove(): void;
  1194. closePopupsAndDialogs(): void;
  1195. selectLineTool(linetool: SupportedLineTools): void;
  1196. selectedLineTool(): SupportedLineTools;
  1197. save(callback: (state: object) => void): void;
  1198. load(state: object): void;
  1199. getSavedCharts(callback: (chartRecords: SaveLoadChartRecord[]) => void): void;
  1200. loadChartFromServer(chartRecord: SaveLoadChartRecord): void;
  1201. saveChartToServer(onComplete?: EmptyCallback, onFail?: EmptyCallback, saveAsSnapshot?: false, options?: SaveChartToServerOptions): void;
  1202. removeChartFromServer(chartId: string, onCompleteCallback: EmptyCallback): void;
  1203. onContextMenu(callback: (unixTime: number, price: number) => ContextMenuItem[]): void;
  1204. createButton(options?: CreateButtonOptions): JQuery;
  1205. showNoticeDialog(params: DialogParams<() => void>): void;
  1206. showConfirmDialog(params: DialogParams<(confirmed: boolean) => void>): void;
  1207. showLoadChartDialog(): void;
  1208. showSaveAsChartDialog(): void;
  1209. symbolInterval(): SymbolIntervalResult;
  1210. mainSeriesPriceFormatter(): IFormatter;
  1211. getIntervals(): string[];
  1212. getStudiesList(): string[];
  1213. addCustomCSSFile(url: string): void;
  1214. applyOverrides<TOverrides extends StudyOverrides>(overrides: TOverrides): void;
  1215. applyStudiesOverrides(overrides: object): void;
  1216. watchList(): WatchListApi;
  1217. activeChart(): IChartWidgetApi;
  1218. chartsCount(): number;
  1219. layout(): LayoutType;
  1220. setLayout(layout: LayoutType): void;
  1221. }
  1222. export interface ChartingLibraryWidgetConstructor {
  1223. new (options: ChartingLibraryWidgetOptions | TradingTerminalWidgetOptions): IChartingLibraryWidget;
  1224. }
  1225. export declare function version(): string;
  1226. export declare function onready(callback: () => void): void;
  1227. export declare const widget: ChartingLibraryWidgetConstructor;
  1228. export as namespace TradingView;