mdas-jsview-sdk 1.0.11-uat.0 → 1.0.12-uat.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mdas-sdk.js CHANGED
@@ -1205,13 +1205,12 @@
1205
1205
  <div class="company-market-info">
1206
1206
  <span class="night-company-name"></span>
1207
1207
  <span class="market-name"></span>
1208
- <span class="market-mic"></span>
1209
1208
  </div>
1210
1209
  <h1 class="symbol editable-symbol"
1211
1210
  title="Double-click to edit symbol"
1212
1211
  data-original-symbol="">
1213
1212
  </h1>
1214
-
1213
+
1215
1214
  </div>
1216
1215
  <div class="price-section">
1217
1216
  <div class="current-price"></div>
@@ -4421,13 +4420,6 @@
4421
4420
  marketNameElement.textContent = this.exchangeName || data.exchangeName || '';
4422
4421
  }
4423
4422
 
4424
- // Update MIC (Market Identifier Code)
4425
- const marketMicElement = this.container.querySelector('.market-mic');
4426
- if (marketMicElement) {
4427
- const micValue = this.mic || data.mic || '';
4428
- marketMicElement.textContent = micValue;
4429
- }
4430
-
4431
4423
  // Update price
4432
4424
  const currentPriceElement = this.container.querySelector('.current-price');
4433
4425
  if (currentPriceElement) {
@@ -37506,6 +37498,10 @@ ${SharedStyles}
37506
37498
 
37507
37499
  // Symbol editor
37508
37500
  this.symbolEditor = null;
37501
+
37502
+ // Lazy loading cache for 5D data
37503
+ this.cached5DData = null;
37504
+ this.is5DDataLoading = false;
37509
37505
  this.createWidgetStructure();
37510
37506
  this.setupSymbolEditor();
37511
37507
  this.initialize();
@@ -37607,6 +37603,10 @@ ${SharedStyles}
37607
37603
  this.chartData = null;
37608
37604
  this.livePrice = null;
37609
37605
 
37606
+ // Clear cached 5D data for old symbol
37607
+ this.cached5DData = null;
37608
+ this.is5DDataLoading = false;
37609
+
37610
37610
  // Update internal symbol
37611
37611
  this.symbol = upperSymbol;
37612
37612
 
@@ -37757,7 +37757,13 @@ ${SharedStyles}
37757
37757
  throw new Error('API service not available');
37758
37758
  }
37759
37759
 
37760
- // FALLBACK LOGIC: Try to find most recent available data
37760
+ // For 5D chart: Load data from multiple days (rangeback 0-5)
37761
+ if (this.rangeBack === 5) {
37762
+ await this.load5DayChartData(apiService);
37763
+ return;
37764
+ }
37765
+
37766
+ // FALLBACK LOGIC: Try to find most recent available data (for 1D)
37761
37767
  const MAX_LOOKBACK_DAYS = 7;
37762
37768
  let attemptRangeBack = this.rangeBack;
37763
37769
  let dataFound = false;
@@ -37846,6 +37852,9 @@ ${SharedStyles}
37846
37852
  await this.startAutoRefresh();
37847
37853
  // Subscribe to live price updates
37848
37854
  this.subscribeToLivePrice();
37855
+
37856
+ // LAZY LOADING: Preload 5D data in the background after 1D loads
37857
+ this.preload5DDataInBackground();
37849
37858
  } else {
37850
37859
  // Historical data or fallback - don't refresh
37851
37860
  this.stopAutoRefresh();
@@ -37873,6 +37882,159 @@ ${SharedStyles}
37873
37882
  this.showError(errorMessage);
37874
37883
  }
37875
37884
  }
37885
+ async load5DayChartData(apiService) {
37886
+ try {
37887
+ // Check if we have cached 5D data
37888
+ if (this.cached5DData) {
37889
+ if (this.debug) {
37890
+ console.log('[IntradayChartWidget] Using cached 5D data');
37891
+ }
37892
+
37893
+ // Use cached data
37894
+ this.chartData = this.cached5DData;
37895
+ this.renderChart();
37896
+ this.updateStats();
37897
+ this.hideLoading();
37898
+
37899
+ // Don't auto-refresh for 5D chart
37900
+ this.stopAutoRefresh();
37901
+ return;
37902
+ }
37903
+
37904
+ // No cached data, load it now
37905
+ const combinedData = await this.fetch5DayData(apiService);
37906
+
37907
+ // Process the combined data
37908
+ this.chartData = new IntradayChartModel(combinedData);
37909
+ if (this.chartData.dataPoints.length === 0) {
37910
+ throw new Error(`No valid data points for ${this.symbol}`);
37911
+ }
37912
+
37913
+ // Cache the processed data
37914
+ this.cached5DData = this.chartData;
37915
+ this.renderChart();
37916
+ this.updateStats();
37917
+ this.hideLoading();
37918
+ if (this.debug) {
37919
+ console.log(`[IntradayChartWidget] 5D chart loaded with ${this.chartData.dataPoints.length} data points`);
37920
+ }
37921
+
37922
+ // Don't auto-refresh for 5D chart
37923
+ this.stopAutoRefresh();
37924
+ } catch (error) {
37925
+ console.error('[IntradayChartWidget] Error loading 5D chart data:', error);
37926
+ throw error; // Re-throw to be caught by parent loadChartData
37927
+ }
37928
+ }
37929
+ async fetch5DayData(apiService) {
37930
+ const DAYS_TO_COLLECT = 5;
37931
+ const MAX_RANGEBACK_ATTEMPTS = 7; // API limit: maximum 7 rangeback
37932
+
37933
+ if (this.debug) {
37934
+ console.log('[IntradayChartWidget] Fetching 5D chart data with parallel requests (API limit: rangeback 0-6)');
37935
+ }
37936
+
37937
+ // OPTIMIZATION: Query all rangeback values in parallel (0-6)
37938
+ const rangebackPromises = [];
37939
+ for (let rb = 0; rb < MAX_RANGEBACK_ATTEMPTS; rb++) {
37940
+ rangebackPromises.push(apiService.getIntradayChart(this.source, this.symbol, rb).then(response => {
37941
+ // Extract data array from response
37942
+ let dataArray = response;
37943
+ if (response && response.data && Array.isArray(response.data)) {
37944
+ dataArray = response.data;
37945
+ }
37946
+ return {
37947
+ rangeBack: rb,
37948
+ data: dataArray
37949
+ };
37950
+ }).catch(error => {
37951
+ // If a request fails, return null so we can filter it out
37952
+ if (this.debug) {
37953
+ console.warn(`[IntradayChartWidget] Request failed for rangeback ${rb}:`, error);
37954
+ }
37955
+ return {
37956
+ rangeBack: rb,
37957
+ data: null
37958
+ };
37959
+ }));
37960
+ }
37961
+
37962
+ // Wait for all parallel requests to complete
37963
+ const results = await Promise.all(rangebackPromises);
37964
+ if (this.debug) {
37965
+ console.log('[IntradayChartWidget] All parallel requests completed');
37966
+ }
37967
+
37968
+ // Filter out empty/null responses and collect valid days
37969
+ const collectedDays = results.filter(result => {
37970
+ const isValid = result.data && Array.isArray(result.data) && result.data.length > 0;
37971
+ if (this.debug) {
37972
+ if (isValid) {
37973
+ console.log(`[IntradayChartWidget] Rangeback ${result.rangeBack}: ${result.data.length} data points`);
37974
+ } else {
37975
+ console.log(`[IntradayChartWidget] Rangeback ${result.rangeBack}: No data (skipped)`);
37976
+ }
37977
+ }
37978
+ return isValid;
37979
+ }).slice(0, DAYS_TO_COLLECT); // Take only the first 5 days with data
37980
+
37981
+ if (collectedDays.length === 0) {
37982
+ throw new Error(`No intraday data available for ${this.symbol} in the past ${MAX_RANGEBACK_ATTEMPTS} days`);
37983
+ }
37984
+ if (this.debug) {
37985
+ console.log(`[IntradayChartWidget] Collected ${collectedDays.length}/${DAYS_TO_COLLECT} days of data`);
37986
+ if (collectedDays.length < DAYS_TO_COLLECT) {
37987
+ console.log(`[IntradayChartWidget] Note: Only ${collectedDays.length} days available within API limit (rangeback 0-6)`);
37988
+ }
37989
+ }
37990
+
37991
+ // Combine all collected days into a single array (oldest to newest)
37992
+ const combinedData = [];
37993
+ for (let i = collectedDays.length - 1; i >= 0; i--) {
37994
+ combinedData.push(...collectedDays[i].data);
37995
+ }
37996
+ if (this.debug) {
37997
+ console.log(`[IntradayChartWidget] Combined ${combinedData.length} total data points from ${collectedDays.length} days`);
37998
+ }
37999
+ return combinedData;
38000
+ }
38001
+ preload5DDataInBackground() {
38002
+ // Prevent multiple simultaneous preloads
38003
+ if (this.is5DDataLoading || this.cached5DData) {
38004
+ return;
38005
+ }
38006
+ this.is5DDataLoading = true;
38007
+ if (this.debug) {
38008
+ console.log('[IntradayChartWidget] Starting background preload of 5D data...');
38009
+ }
38010
+
38011
+ // Run in background without blocking
38012
+ setTimeout(async () => {
38013
+ try {
38014
+ const apiService = this.wsManager.getApiService();
38015
+ if (!apiService) {
38016
+ if (this.debug) {
38017
+ console.log('[IntradayChartWidget] API service not available for preload');
38018
+ }
38019
+ return;
38020
+ }
38021
+ const combinedData = await this.fetch5DayData(apiService);
38022
+
38023
+ // Create and cache the model
38024
+ const chartData = new IntradayChartModel(combinedData);
38025
+ this.cached5DData = chartData;
38026
+ if (this.debug) {
38027
+ console.log(`[IntradayChartWidget] ✓ Background preload complete: ${chartData.dataPoints.length} data points cached`);
38028
+ }
38029
+ } catch (error) {
38030
+ if (this.debug) {
38031
+ console.warn('[IntradayChartWidget] Background preload failed:', error);
38032
+ }
38033
+ } finally {
38034
+ this.is5DDataLoading = false;
38035
+ }
38036
+ }, 1000); // Wait 1 second after 1D loads before starting preload
38037
+ }
37876
38038
  subscribeToLivePrice() {
37877
38039
  // Unsubscribe from previous subscription if any
37878
38040
  if (this.unsubscribe) {
@@ -38421,10 +38583,12 @@ ${SharedStyles}
38421
38583
  autoSkip: true,
38422
38584
  maxRotation: 0,
38423
38585
  minRotation: 0,
38424
- callback: (value, index) => {
38586
+ callback: (value, index, ticks) => {
38425
38587
  if (this.rangeBack > 0) {
38426
- // For multi-day charts with linear scale, show actual time from data point
38427
- const point = validDataPoints[index];
38588
+ // For multi-day charts with linear scale
38589
+ // value is the x-value (index in data array), not the tick index
38590
+ const dataIndex = Math.round(value);
38591
+ const point = validDataPoints[dataIndex];
38428
38592
  if (point) {
38429
38593
  const date = new Date(point.time);
38430
38594
  return date.toLocaleString('en-US', {