MCPcopy
hub / github.com/Mathieu2301/TradingView-API / ChartSession

Class ChartSession

src/chart/session.js:117–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115 * @param {import('../client').ClientBridge} client
116 */
117module.exports = (client) => class ChartSession {
118 #chartSessionID = genSessionID('cs');
119
120 #replaySessionID = genSessionID('rs');
121
122 #replayMode = false;
123
124 /** @type {Object<string, (): any>} */
125 #replayOKCB = {};
126
127 /** Parent client */
128 #client = client;
129
130 /** @type {StudyListeners} */
131 #studyListeners = {};
132
133 /**
134 * Table of periods values indexed by timestamp
135 * @type {Object<number, PricePeriod[]>}
136 */
137 #periods = {};
138
139 /** @return {PricePeriod[]} List of periods values */
140 get periods() {
141 return Object.values(this.#periods).sort((a, b) => b.time - a.time);
142 }
143
144 /**
145 * Current market infos
146 * @type {MarketInfos}
147 */
148 #infos = {};
149
150 /** @return {MarketInfos} Current market infos */
151 get infos() {
152 return this.#infos;
153 }
154
155 #callbacks = {
156 seriesLoaded: [],
157 symbolLoaded: [],
158 update: [],
159
160 replayLoaded: [],
161 replayPoint: [],
162 replayResolution: [],
163 replayEnd: [],
164
165 event: [],
166 error: [],
167 };
168
169 /**
170 * @param {ChartEvent} ev Client event
171 * @param {...{}} data Packet data
172 */
173 #handleEvent(ev, ...data) {
174 this.#callbacks[ev].forEach((e) => e(...data));

Callers

nothing calls this directly

Calls 2

genSessionIDFunction · 0.85
sendMethod · 0.80

Tested by

no test coverage detected