Removed unused code from SharePrices.js
This commit is contained in:
parent
566237e63f
commit
7b32c87376
@ -4,9 +4,6 @@ var timespans = { oneSecond: 1000, oneMinute: 60 * 1000, oneHour: 60 * 60 * 1000
|
||||
var fetchIntervalDaily = 12 * timespans.oneHour;
|
||||
var fetchIntervalIntraday = 4 * timespans.oneHour;
|
||||
var fetchIntervalSingleDay = 2 * timespans.oneMinute;
|
||||
//var fetchIntervalSingleDay_WhenOpen = 90 * timespans.oneSecond;
|
||||
//var fetchIntervalSingleDay_WhenClosed = 30 * timespans.oneMinute;
|
||||
//var fetchInterval = 500;
|
||||
var initialPageTitle;
|
||||
var fetchTimer = 0;
|
||||
var lastSuccessfulFetch;
|
||||
@ -424,20 +421,6 @@ function getInstruments() {
|
||||
let i = Instruments.Data[ix];
|
||||
i.Holdings = [];
|
||||
i.HoldingsHistory = [];
|
||||
/*i.MarketIsOpen = function (timeMargin) {
|
||||
timeMargin = timeMargin | 0;
|
||||
let currentMarketDT = new Date().getTime() + this.GMTOffset; //Should this be new Date().getUTCTime()???
|
||||
|
||||
if (currentMarketDT < this.SingleDayStartDate-timeMargin) {
|
||||
return 0; //Not open yet
|
||||
} else {
|
||||
if (currentMarketDT > this.SingleDayEndDate+timeMargin) {
|
||||
return 2; //Market closed (end of day)
|
||||
} else {
|
||||
return 1; //Market is currently open
|
||||
}
|
||||
}
|
||||
};*/
|
||||
}
|
||||
let symbol = '';
|
||||
let instrument = {};
|
||||
@ -652,11 +635,7 @@ function swapInstrumentDisplayOrders(symbol1, symbol2) {
|
||||
$("#shareRow" + i.DisplayOrder).html(createSharesTableRow(i));
|
||||
i = Instruments.Data[i2];
|
||||
$("#shareRow" + i.DisplayOrder).html(createSharesTableRow(i));
|
||||
/*tempContent = $("#shareRow" + do1).html();
|
||||
$("#shareRow" + do1).html($("#shareRow" + do2).html());
|
||||
$("#shareRow" + do2).html(tempContent);
|
||||
*/
|
||||
|
||||
|
||||
//Redraw the charts on both rows
|
||||
redrawShareRowCharts(Instruments.Data[i1]);
|
||||
redrawShareRowCharts(Instruments.Data[i2]);
|
||||
@ -808,12 +787,6 @@ function createLongChart(Instrument) {
|
||||
}
|
||||
function createMidChart(Instrument) {
|
||||
let rowNo = Instrument.DisplayOrder;
|
||||
/*
|
||||
let monthStartDate = new Date().setHours(0, 0, 0) - timespans.oneMonth;
|
||||
let monthEndDate = new Date().getTime();
|
||||
try { Instrument.MidChart.destroy(); } catch (ex) { }
|
||||
Instrument.MidChart = createChart(Instrument, monthStartDate, monthEndDate, 'divMidChart' + rowNo.toString(), 'divMidSummary' + rowNo.toString());
|
||||
*/
|
||||
let quarterStartDate = new Date().setHours(0, 0, 0) - (timespans.oneMonth * 3);
|
||||
let quarterEndDate = new Date().getTime();
|
||||
try { Instrument.MidChart.destroy(); } catch (ex) { }
|
||||
@ -821,12 +794,6 @@ function createMidChart(Instrument) {
|
||||
}
|
||||
function createShortChart(Instrument) {
|
||||
let rowNo = Instrument.DisplayOrder;
|
||||
/*
|
||||
let weekStartDate = new Date().setHours(0, 0, 0) - timespans.oneWeek;
|
||||
let weekEndDate = new Date().getTime();
|
||||
try { Instrument.ShortChart.destroy(); } catch (ex) { }
|
||||
Instrument.ShortChart = createChart(Instrument, weekStartDate, weekEndDate, 'divShortChart' + rowNo.toString(), 'divShortSummary' + rowNo.toString());
|
||||
*/
|
||||
let fortnightStartDate = new Date().setHours(0, 0, 0) - (timespans.oneWeek * 2);
|
||||
let fortnightEndDate = new Date().getTime();
|
||||
try { Instrument.ShortChart.destroy(); } catch (ex) { }
|
||||
@ -876,14 +843,6 @@ function createChart_Flot(Instrument, startDate, endDate, chartContainerID, summ
|
||||
//Back-fill with daily data if the intraday data doesn't cover the whole date range
|
||||
let minFoundDate = new Date(foundDates.min).setHours(0, 0, 0);
|
||||
if (minFoundDate > dateFrom) {
|
||||
/*for (let i = 0; i < Instrument.DailyData.length; i++) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
result.push(quote);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
for (let i = Instrument.DailyData.length - 1; i > 0; i--) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
@ -913,27 +872,11 @@ function createChart_Flot(Instrument, startDate, endDate, chartContainerID, summ
|
||||
result.push([dateTo, currentPrice]);
|
||||
}
|
||||
|
||||
/*
|
||||
if (Instrument.Symbol == 'FLT.AX') {
|
||||
console.info("Before removing:");
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
console.info(new Date(result[i][0]).yyyymmddhhmmss() + ' = ' + String(result[i][1]));
|
||||
}
|
||||
}
|
||||
*/
|
||||
//Remove all points before the start of the date range
|
||||
let i = result.length - 1;
|
||||
while (i >= 0 && result[i][0] >= startDate) i--;
|
||||
while (i > 0) { result.shift(); i--; }
|
||||
/*
|
||||
if (Instrument.Symbol == 'FLT.AX') {
|
||||
console.info("After removing:");
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
console.info(new Date(result[i][0]).yyyymmddhhmmss() + ' = ' + String(result[i][1]));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
function transformAndSummariseChartData(cd) {
|
||||
@ -985,7 +928,6 @@ function createChart_Flot(Instrument, startDate, endDate, chartContainerID, summ
|
||||
|
||||
let chartContainer = $("#" + chartContainerID);
|
||||
let priceType = $('#displayAsPercent').prop('checked') ? 'percent' : '';
|
||||
//let chartData = getChartDataSubset(Instrument, startDate, endDate);
|
||||
let chartData = [];
|
||||
if (endDate - endDate <= timespans.oneDay) {
|
||||
chartData = getChartDataSubset(Instrument, startDate, endDate);
|
||||
@ -993,15 +935,9 @@ function createChart_Flot(Instrument, startDate, endDate, chartContainerID, summ
|
||||
chartData = getChartDataSubset(Instrument, startDate - (timespans.oneDay * 3), endDate);
|
||||
}
|
||||
|
||||
//console.info(new Date().yyyymmddhhmmss() + ' - createChart ' + Instrument.Symbol + ' ' + chartContainerID + ' ' + new Date(startDate).yyyymmddhhmmss() + ' -> ' + new Date(endDate).yyyymmddhhmmss());
|
||||
let seriesData = [];
|
||||
let volumeData = [];
|
||||
if (chartData.length > 1) {
|
||||
/*let transformedAndSummarisedData = transformAndSummariseChartData(chartData);
|
||||
let summaryData = transformedAndSummarisedData.summaryData;
|
||||
let basePrice = transformedAndSummarisedData.basePrice;
|
||||
seriesData = transformedAndSummarisedData.seriesData;*/
|
||||
|
||||
//Summarise the data and transform values to percentage if required
|
||||
let summaryData = {
|
||||
StartDT: chartData[0].DT,
|
||||
@ -1037,15 +973,12 @@ function createChart_Flot(Instrument, startDate, endDate, chartContainerID, summ
|
||||
let series = [{ data: volumeData, yaxis: 2, color: "#304e57", bars: { show: true } }];
|
||||
|
||||
//Add the breakeven price line
|
||||
//if ($('#showBreakevenLine').prop('checked')) {
|
||||
if ((Instrument.ShowBreakevenLine | 0) == 1) {
|
||||
if (priceType == 'percent') {
|
||||
series.unshift({ data: [[startDate, ((Instrument.BreakevenPrice / basePrice) - 1) * 100], [endDate, ((Instrument.BreakevenPrice / basePrice) - 1) * 100]], color: '#24BCC7', shadowSize: 0, lines: { lineWidth: 1 } });
|
||||
} else {
|
||||
//series.unshift({ data: [[startDate, Instrument.BreakevenPrice], [endDate, Instrument.BreakevenPrice]], color: '#24BCC7', shadowSize: 0, lines: { lineWidth: 1 } });
|
||||
let b = getBreakevenLine(Instrument, startDate, endDate);
|
||||
if (b.length > 0 && b[0][0]<endDate && b[b.length-1][0]>startDate) { //Only add the series if it falls within the chart date range
|
||||
//series.unshift({ data: b, color: '#00cc00', shadowSize: 0, lines: { lineWidth: 1.5 } });
|
||||
series.push({ data: b, color: 'green', shadowSize: 0, lines: { lineWidth: 1.5 } });
|
||||
}
|
||||
}
|
||||
@ -1054,10 +987,8 @@ function createChart_Flot(Instrument, startDate, endDate, chartContainerID, summ
|
||||
//Add the previousClose line to the series
|
||||
if (previousClose) {
|
||||
if (priceType == 'percent') {
|
||||
//series.unshift({ data: [[startDate, ((previousClose / basePrice) - 1) * 100], [endDate, ((previousClose / basePrice) - 1) * 100]], color: 'blue', shadowSize: 0, lines: { lineWidth: 1 } });
|
||||
series.unshift({ data: [[startDate, ((previousClose / basePrice) - 1) * 100], [endDate, ((previousClose / basePrice) - 1) * 100]], color: '#3b88ff', shadowSize: 0, lines: { lineWidth: 1 } });
|
||||
} else {
|
||||
//series.unshift({ data: [[startDate, previousClose], [endDate, previousClose]], color: 'blue', shadowSize: 0, lines: { lineWidth: 1 } });
|
||||
series.unshift({ data: [[startDate, previousClose], [endDate, previousClose]], color: '#3b88ff', shadowSize: 0, lines: { lineWidth: 1 } });
|
||||
}
|
||||
}
|
||||
@ -1097,9 +1028,7 @@ function createChart_Flot(Instrument, startDate, endDate, chartContainerID, summ
|
||||
mode: "time",
|
||||
timezone: 'browser',
|
||||
min: chartTimespan > timespans.oneDay ? summaryData.StartDT : startDate,
|
||||
/*min: startDate, */
|
||||
max: chartTimespan > timespans.oneDay ? summaryData.EndDT : endDate,
|
||||
/*max: endDate,*/
|
||||
transform: function (v) { return mapChartXValue(v, gapMap); },
|
||||
inverseTransform: function (v) { return unmapChartXValue(v, gapMap); }
|
||||
},
|
||||
@ -1193,14 +1122,6 @@ function createChart(Instrument, startDate, endDate, chartContainerID, summaryCo
|
||||
//Back-fill with daily data if the intraday data doesn't cover the whole date range
|
||||
let minFoundDate = new Date(foundDates.min).setHours(0, 0, 0);
|
||||
if (minFoundDate > dateFrom) {
|
||||
/*for (let i = 0; i < Instrument.DailyData.length; i++) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
result.push(quote);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
for (let i = Instrument.DailyData.length - 1; i > 0; i--) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
@ -1230,27 +1151,11 @@ function createChart(Instrument, startDate, endDate, chartContainerID, summaryCo
|
||||
result.push([dateTo, currentPrice]);
|
||||
}
|
||||
|
||||
/*
|
||||
if (Instrument.Symbol == 'FLT.AX') {
|
||||
console.info("Before removing:");
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
console.info(new Date(result[i][0]).yyyymmddhhmmss() + ' = ' + String(result[i][1]));
|
||||
}
|
||||
}
|
||||
*/
|
||||
//Remove all points before the start of the date range
|
||||
let i = result.length - 1;
|
||||
while (i >= 0 && result[i][0] >= startDate) i--;
|
||||
while (i > 0) { result.shift(); i--; }
|
||||
/*
|
||||
if (Instrument.Symbol == 'FLT.AX') {
|
||||
console.info("After removing:");
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
console.info(new Date(result[i][0]).yyyymmddhhmmss() + ' = ' + String(result[i][1]));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
function transformAndSummariseChartData(cd) {
|
||||
@ -1303,7 +1208,6 @@ function createChart(Instrument, startDate, endDate, chartContainerID, summaryCo
|
||||
let chartContainer = $('#' + chartContainerID);
|
||||
if (chartContainer.length > 0) {
|
||||
let chart = {};
|
||||
//let chartContainer = $("#" + chartContainerID);
|
||||
let priceType = $('#displayAsPercent').prop('checked') ? 'percent' : '';
|
||||
|
||||
let chartData = [];
|
||||
@ -1316,11 +1220,7 @@ function createChart(Instrument, startDate, endDate, chartContainerID, summaryCo
|
||||
let seriesData = [];
|
||||
let volumeData = [];
|
||||
if (chartData && chartData.length > 1) {
|
||||
/*let transformedAndSummarisedData = transformAndSummariseChartData(chartData);
|
||||
let summaryData = transformedAndSummarisedData.summaryData;
|
||||
let basePrice = transformedAndSummarisedData.basePrice;
|
||||
seriesData = transformedAndSummarisedData.seriesData;*/
|
||||
|
||||
|
||||
//Summarise the data and transform values to percentage if required
|
||||
let summaryData = {
|
||||
StartDT: chartData[0].DT,
|
||||
@ -1378,33 +1278,13 @@ function createChart(Instrument, startDate, endDate, chartContainerID, summaryCo
|
||||
let color = (summaryData.Close > basePrice) ? "#00cc00" : (summaryData.Close < basePrice) ? "red" : "blue";
|
||||
series.push({ name: 'Price', type: 'line', color: color, lineWidth: 1, data: seriesData /* shadowSize: 0 */ });
|
||||
|
||||
/*
|
||||
//Dispose of any previous flot chart to prevent memory leaks (orphaaned DOM nodes)
|
||||
let oldChart = chartContainer.data('plot');
|
||||
if (oldChart) {// If it's destroyed, then data('plot') will be undefined
|
||||
oldChart.destroy();
|
||||
}
|
||||
*/
|
||||
|
||||
//Draw the chart
|
||||
let chartTimespan = endDate - startDate;
|
||||
let xAxisBreaks = [];
|
||||
if (chartTimespan > timespans.oneDay && chartTimespan < timespans.oneMonth * 3) {
|
||||
xAxisBreaks = generateAxisBreaks(seriesData, timespans.oneHour, timespans.oneHour);
|
||||
}
|
||||
/*
|
||||
function volumeAxisFormatter(val, axis) {
|
||||
if (val >= 1000000000)
|
||||
return (val / 1000000000).toFixed(axis.tickDecimals) + "b";
|
||||
else if (val >= 1000000)
|
||||
return (val / 1000000).toFixed(axis.tickDecimals) + "m";
|
||||
else if (val >= 1000)
|
||||
return (val / 1000).toFixed(axis.tickDecimals) + "k";
|
||||
else
|
||||
return val.toFixed(axis.tickDecimals);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
try {
|
||||
chart = Highcharts.chart(chartContainerID, {
|
||||
series: series,
|
||||
@ -1445,14 +1325,6 @@ function createChart(Instrument, startDate, endDate, chartContainerID, summaryCo
|
||||
labels: { style: { color: '#b0b0b0', fontSize: 'x-small' } }
|
||||
}],
|
||||
credits: { enabled: false }
|
||||
/*grid: { show: true, hoverable: true, color: 'white', borderColor: '#505050' },*/
|
||||
/*crosshair: { mode: 'x', snapX: true, showXValue: false },*/
|
||||
/*xaxis: {
|
||||
timezone: 'browser',
|
||||
transform: function (v) { return mapChartXValue(v, gapMap); },
|
||||
inverseTransform: function (v) { return unmapChartXValue(v, gapMap); }
|
||||
},*/
|
||||
/*yaxes: [{ position: 'left' }, { position: 'right', tickFormatter: volumeAxisFormatter }]*/
|
||||
});
|
||||
}
|
||||
catch (ex) {
|
||||
@ -1494,63 +1366,29 @@ function createFullScreenChart(Instrument, startDate, endDate) {
|
||||
if (dateTo - dateFrom <= timespans.oneDay) {
|
||||
result = Instrument.SingleDayData;
|
||||
} else {
|
||||
//Anything over 3 months should only use daily data
|
||||
/*if (dateTo - dateFrom > ((3 * timespans.oneMonth) + (timespans.oneDay * 4))) {
|
||||
for (let i = 0; i < Instrument.DailyData.length; i++) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT <= dateTo) {
|
||||
result.push(quote);
|
||||
}
|
||||
//Get all in-date-range intraday data
|
||||
let foundDates = { min: new Date().getTime(), max: 0 }
|
||||
for (let i = 0; i < Instrument.IntradayData.length; i++) {
|
||||
let quote = Instrument.IntradayData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT <= dateTo) {
|
||||
if (quote.DT > foundDates.max) foundDates.max = quote.DT;
|
||||
if (quote.DT < foundDates.min) foundDates.min = quote.DT;
|
||||
result.push(quote);
|
||||
}
|
||||
} else {*/
|
||||
//Get all in-date-range intraday data
|
||||
let foundDates = { min: new Date().getTime(), max: 0 }
|
||||
for (let i = 0; i < Instrument.IntradayData.length; i++) {
|
||||
let quote = Instrument.IntradayData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT <= dateTo) {
|
||||
if (quote.DT > foundDates.max) foundDates.max = quote.DT;
|
||||
if (quote.DT < foundDates.min) foundDates.min = quote.DT;
|
||||
result.push(quote);
|
||||
}
|
||||
}
|
||||
//Back-fill with daily data if the intraday data doesn't cover the whole date range
|
||||
let minFoundDate = new Date(foundDates.min).setHours(0, 0, 0);
|
||||
}
|
||||
//Back-fill with daily data if the intraday data doesn't cover the whole date range
|
||||
let minFoundDate = new Date(foundDates.min).setHours(0, 0, 0);
|
||||
|
||||
if (minFoundDate > dateFrom) {
|
||||
for (let i = Instrument.DailyData.length - 1; i > 0; i--) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
result.unshift(quote);
|
||||
}
|
||||
if (minFoundDate > dateFrom) {
|
||||
for (let i = Instrument.DailyData.length - 1; i > 0; i--) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
result.unshift(quote);
|
||||
}
|
||||
}
|
||||
/*}*/
|
||||
}
|
||||
/*
|
||||
//Add an entry for today's latest data from SingleDayData
|
||||
if (Instrument.SingleDayData) {
|
||||
if (Instrument.SingleDayData.length > 0) {
|
||||
if (Instrument.SingleDayData.length > 1) {
|
||||
//Aggregate all of the SingleDayData into a single entry
|
||||
let e = Instrument.SingleDayData[0];
|
||||
let o = e.open;
|
||||
let h = e.high;
|
||||
let l = e.low;
|
||||
let v = e.volume;
|
||||
for (let x = 1; x < Instrument.SingleDayData.length; x++) {
|
||||
e = Instrument.SingleDayData[x];
|
||||
if (e.high > h) {h = e.high}
|
||||
if (e.low < l) { l = e.low }
|
||||
v += e.volume;
|
||||
}
|
||||
let c = e.close;
|
||||
result.push({DT: e.DT, open: o, high: h, low: l, close: c, volume: v});
|
||||
} else {
|
||||
result.push(Instrument.SingleDayData[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return result;
|
||||
}
|
||||
function getBreakevenLine(Instrument, dateFrom, dateTo) {
|
||||
@ -1671,7 +1509,6 @@ function createFullScreenChart(Instrument, startDate, endDate) {
|
||||
},
|
||||
/*gridLineColor: '#505050',*/
|
||||
gridLineWidth: 0,
|
||||
//tickPixelInterval: 30,
|
||||
endOnTick: false,
|
||||
opposite: true,
|
||||
labels: { style: { color: '#b0b0b0' /*, fontSize: 'x-small'*/ } }
|
||||
@ -1711,14 +1548,6 @@ function createFullScreenChart_Flot(Instrument, startDate, endDate) {
|
||||
//Back-fill with daily data if the intraday data doesn't cover the whole date range
|
||||
let minFoundDate = new Date(foundDates.min).setHours(0, 0, 0);
|
||||
if (minFoundDate > dateFrom) {
|
||||
/*for (let i = 0; i < Instrument.DailyData.length; i++) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
result.push(quote);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
for (let i = Instrument.DailyData.length - 1; i > 0; i--) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
@ -1728,31 +1557,7 @@ function createFullScreenChart_Flot(Instrument, startDate, endDate) {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
//Add an entry for today's latest data from SingleDayData
|
||||
if (Instrument.SingleDayData) {
|
||||
if (Instrument.SingleDayData.length > 0) {
|
||||
if (Instrument.SingleDayData.length > 1) {
|
||||
//Aggregate all of the SingleDayData into a single entry
|
||||
let e = Instrument.SingleDayData[0];
|
||||
let o = e.open;
|
||||
let h = e.high;
|
||||
let l = e.low;
|
||||
let v = e.volume;
|
||||
for (let x = 1; x < Instrument.SingleDayData.length; x++) {
|
||||
e = Instrument.SingleDayData[x];
|
||||
if (e.high > h) {h = e.high}
|
||||
if (e.low < l) { l = e.low }
|
||||
v += e.volume;
|
||||
}
|
||||
let c = e.close;
|
||||
result.push({DT: e.DT, open: o, high: h, low: l, close: c, volume: v});
|
||||
} else {
|
||||
result.push(Instrument.SingleDayData[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return result;
|
||||
}
|
||||
function getBreakevenLine(Instrument, dateFrom, dateTo) {
|
||||
@ -1934,14 +1739,6 @@ function createFullScreenComparisonChart(Instrument1, Instrument2, startDate, en
|
||||
//Back-fill with daily data if the intraday data doesn't cover the whole date range
|
||||
let minFoundDate = new Date(foundDates.min).setHours(0, 0, 0);
|
||||
if (minFoundDate > dateFrom) {
|
||||
/*for (let i = 0; i < Instrument.DailyData.length; i++) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
result.push(quote);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
for (let i = Instrument.DailyData.length - 1; i > 0; i--) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
@ -1951,31 +1748,7 @@ function createFullScreenComparisonChart(Instrument1, Instrument2, startDate, en
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
//Add an entry for today's latest data from SingleDayData
|
||||
if (Instrument.SingleDayData) {
|
||||
if (Instrument.SingleDayData.length > 0) {
|
||||
if (Instrument.SingleDayData.length > 1) {
|
||||
//Aggregate all of the SingleDayData into a single entry
|
||||
let e = Instrument.SingleDayData[0];
|
||||
let o = e.open;
|
||||
let h = e.high;
|
||||
let l = e.low;
|
||||
let v = e.volume;
|
||||
for (let x = 1; x < Instrument.SingleDayData.length; x++) {
|
||||
e = Instrument.SingleDayData[x];
|
||||
if (e.high > h) { h = e.high }
|
||||
if (e.low < l) { l = e.low }
|
||||
v += e.volume;
|
||||
}
|
||||
let c = e.close;
|
||||
result.push({ DT: e.DT, open: o, high: h, low: l, close: c, volume: v });
|
||||
} else {
|
||||
result.push(Instrument.SingleDayData[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return result;
|
||||
}
|
||||
function transformAndSummariseData(chartData, priceType) {
|
||||
@ -2013,9 +1786,7 @@ function createFullScreenComparisonChart(Instrument1, Instrument2, startDate, en
|
||||
}
|
||||
|
||||
let chartContainerID = 'divFullScreenChart';
|
||||
//let chartContainer = $("#" + chartContainerID);
|
||||
|
||||
//let priceType = 'percent';
|
||||
let instrument1Data = getChartDataSubset(Instrument1, startDate, endDate);
|
||||
let instrument2Data = getChartDataSubset(Instrument2, startDate, endDate);
|
||||
|
||||
@ -2051,7 +1822,6 @@ function createFullScreenComparisonChart(Instrument1, Instrument2, startDate, en
|
||||
type: 'datetime',
|
||||
lineColor: '#505050',
|
||||
tickColor: '#505050',
|
||||
//tickPixelInterval: 60,
|
||||
min: chartTimespan > timespans.oneDay ? price1Summary.StartDT : startDate,
|
||||
max: chartTimespan > timespans.oneDay ? price1Summary.EndDT : endDate,
|
||||
breaks: xAxisBreaks,
|
||||
@ -2063,7 +1833,6 @@ function createFullScreenComparisonChart(Instrument1, Instrument2, startDate, en
|
||||
style: { color: '#b0b0b0' }
|
||||
},
|
||||
gridLineColor: '#505050',
|
||||
//endOnTick: false,
|
||||
labels: { style: { color: '#b0b0b0' /*, fontSize: 'x-small'*/ } }
|
||||
}],
|
||||
credits: { enabled: false }
|
||||
@ -2102,14 +1871,6 @@ function createFullScreenComparisonChart_Flot(Instrument1, Instrument2, startDat
|
||||
//Back-fill with daily data if the intraday data doesn't cover the whole date range
|
||||
let minFoundDate = new Date(foundDates.min).setHours(0, 0, 0);
|
||||
if (minFoundDate > dateFrom) {
|
||||
/*for (let i = 0; i < Instrument.DailyData.length; i++) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
result.push(quote);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
for (let i = Instrument.DailyData.length - 1; i > 0; i--) {
|
||||
let quote = Instrument.DailyData[i];
|
||||
if (quote.DT >= dateFrom && quote.DT < minFoundDate) {
|
||||
@ -2119,31 +1880,7 @@ function createFullScreenComparisonChart_Flot(Instrument1, Instrument2, startDat
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
//Add an entry for today's latest data from SingleDayData
|
||||
if (Instrument.SingleDayData) {
|
||||
if (Instrument.SingleDayData.length > 0) {
|
||||
if (Instrument.SingleDayData.length > 1) {
|
||||
//Aggregate all of the SingleDayData into a single entry
|
||||
let e = Instrument.SingleDayData[0];
|
||||
let o = e.open;
|
||||
let h = e.high;
|
||||
let l = e.low;
|
||||
let v = e.volume;
|
||||
for (let x = 1; x < Instrument.SingleDayData.length; x++) {
|
||||
e = Instrument.SingleDayData[x];
|
||||
if (e.high > h) { h = e.high }
|
||||
if (e.low < l) { l = e.low }
|
||||
v += e.volume;
|
||||
}
|
||||
let c = e.close;
|
||||
result.push({ DT: e.DT, open: o, high: h, low: l, close: c, volume: v });
|
||||
} else {
|
||||
result.push(Instrument.SingleDayData[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return result;
|
||||
}
|
||||
function transformAndSummariseData(chartData, priceType) {
|
||||
@ -2183,7 +1920,6 @@ function createFullScreenComparisonChart_Flot(Instrument1, Instrument2, startDat
|
||||
let chartContainerID = 'divFullScreenChart';
|
||||
let chartContainer = $("#" + chartContainerID);
|
||||
|
||||
//let priceType = $('#displayAsPercent').prop('checked') ? 'percent' : '';
|
||||
let priceType = 'percent';
|
||||
let instrument1Data = getChartDataSubset(Instrument1, startDate, endDate);
|
||||
let instrument2Data = getChartDataSubset(Instrument2, startDate, endDate);
|
||||
@ -2349,29 +2085,6 @@ function getYahooIntradayData(Instrument) {
|
||||
let newData = [];
|
||||
if (response.chart && response.chart.result) {
|
||||
let dataSeries = response.chart.result[0];
|
||||
/*
|
||||
let priceHint = dataSeries.meta.priceHint;
|
||||
let scale = dataSeries.meta.scale || 1;
|
||||
if (priceHint != 2 || scale != 1) {
|
||||
let minDT = dataSeries.timestamp[0] * 1000;
|
||||
let maxDT = dataSeries.timestamp[dataSeries.timestamp.length - 1] * 1000;
|
||||
let prices = [];
|
||||
for (let t = 0; t < dataSeries.timestamp.length - 1; t++) {
|
||||
let DT = dataSeries.timestamp[t] * 1000;
|
||||
prices.push({ DT: DT, Date: new Date(DT).yyyymmddhhmmss(), price: dataSeries.indicators.quote[0].close[t]});
|
||||
}
|
||||
console.info({
|
||||
priceHint: priceHint,
|
||||
scale: scale,
|
||||
symbol: Instrument.Symbol,
|
||||
minDT: minDT,
|
||||
maxDT: maxDT,
|
||||
minDate: new Date(minDT).yyyymmddhhmmss(),
|
||||
maxDate: new Date(maxDT).yyyymmddhhmmss(),
|
||||
prices: prices
|
||||
});
|
||||
}
|
||||
*/
|
||||
let nonSubmittedEntries = 0;
|
||||
if (dataSeries.timestamp) {
|
||||
for (let i = 0; i < dataSeries.timestamp.length; i++) {
|
||||
@ -2380,7 +2093,6 @@ function getYahooIntradayData(Instrument) {
|
||||
nonSubmittedEntries += 1;
|
||||
//console.info("Not submitting entry with null values: " + JSON.stringify({ DT: dataSeries.timestamp[i] * 1000, open: quote.open[i], high: quote.high[i], low: quote.low[i], close: quote.close[i], volume: quote.volume[i] }));
|
||||
} else {
|
||||
//newData.push({ DT: dataSeries.timestamp[i] * 1000, open: quote.open[i], high: quote.high[i], low: quote.low[i], close: quote.close[i], volume: quote.volume[i] });
|
||||
if (Instrument.InstrumentType == 'CRYPTOCURRENCY') {
|
||||
newData.push({ DT: dataSeries.timestamp[i] * 1000,
|
||||
open: quote.open[i],
|
||||
@ -2504,66 +2216,7 @@ function getLseSingleDayData(Instrument) {
|
||||
data: JSON.stringify({ Symbol: Instrument.Symbol, FromDate: fromDate, ToDate: toDate }),
|
||||
success: function (response) {
|
||||
console.info("getLseSingleDayData: " + JSON.stringify(response));
|
||||
/*
|
||||
let newData = [];
|
||||
if (response.chart && response.chart.result) {
|
||||
|
||||
let dataSeries = response.chart.result[0];
|
||||
|
||||
if (dataSeries.meta) {
|
||||
Instrument.SingleDayPreviousClose = dataSeries.meta.previousClose;
|
||||
Instrument.SingleDayStartDate = dataSeries.meta.currentTradingPeriod.regular.start * 1000;
|
||||
Instrument.SingleDayEndDate = dataSeries.meta.currentTradingPeriod.regular.end * 1000;
|
||||
Instrument.GMTOffset = dataSeries.meta.gmtoffset;
|
||||
Instrument.InstrumentType = dataSeries.meta.instrumentType;
|
||||
Instrument.Currency = dataSeries.meta.currency;
|
||||
Instrument.CurrentPrice = dataSeries.meta.regularMarketPrice;
|
||||
}
|
||||
|
||||
if (response.chart.result[0].timestamp) {
|
||||
let ignoredEntries = 0;
|
||||
for (let i = 0; i < dataSeries.timestamp.length; i++) {
|
||||
let quote = dataSeries.indicators.quote[0];
|
||||
if (quote.open[i] == null || quote.high[i] == null || quote.low[i] == null || quote.close[i] == null || quote.volume[i] == null) {
|
||||
ignoredEntries++;
|
||||
} else {
|
||||
newData.push({ DT: dataSeries.timestamp[i] * 1000, open: quote.open[i], high: quote.high[i], low: quote.low[i], close: quote.close[i], volume: quote.volume[i] });
|
||||
}
|
||||
}
|
||||
if (ignoredEntries > 0) {
|
||||
//console.warn("Ignored " + ignoredEntries.toString() + " entries (" + newData.length.toString() + " OK) with null values for " + Instrument.Symbol);
|
||||
}
|
||||
if (newData.length > 0) {
|
||||
lastSuccessfulFetch = new Date();
|
||||
}
|
||||
|
||||
if (!Instrument.SingleDayData || Instrument.SingleDayData[0].DT != newData[0].DT || newData.length > Instrument.SingleDayData.length) {
|
||||
Instrument.SingleDayData = newData;
|
||||
|
||||
createSingleDayChart(Instrument);
|
||||
//updateHoldingsTable();
|
||||
//updateAnalysisTable();
|
||||
tablesUpdateTimings.updateNeeded = true;
|
||||
}
|
||||
|
||||
Instrument.SingleDayOpenPrice = dataSeries.indicators.quote[0].open[0];
|
||||
|
||||
$('#divCurrentValue' + Instrument.DisplayOrder).html(getCurrentValueContent(Instrument));
|
||||
|
||||
if (Instrument.InstrumentType == "CURRENCY") {
|
||||
Currencies.updateSymbol(Instrument.Symbol, Instrument.InstrumentName, Instrument.CurrentPrice);
|
||||
}
|
||||
} else {
|
||||
//console.warn("No timestamp series received for symbol: " + Instrument.Symbol);
|
||||
//logWarning("No timestamp series received for symbol: " + Instrument.Symbol);
|
||||
logWarning({ MSG: "No timestamp series received for symbol: " + Instrument.Symbol, response: response });
|
||||
}
|
||||
} else {
|
||||
//console.info("No data received for symbol: " + Instrument.Symbol);
|
||||
//logInfo("No data received for symbol: " + Instrument.Symbol);
|
||||
logWarning({ MSG: "No data received for symbol: " + Instrument.Symbol, response: response });
|
||||
}
|
||||
*/
|
||||
|
||||
},
|
||||
failure: function (response) { console.error("getLseSingleDayData error:"); console.info(response); }
|
||||
});
|
||||
@ -2602,7 +2255,7 @@ function submitNewDailyData(Instrument, NewData) {
|
||||
}
|
||||
}
|
||||
}
|
||||
//Resort the DailyData by date if required
|
||||
//Re-sort the DailyData by date if required
|
||||
if (resortRequired) {
|
||||
Instrument.DailyData.sort(function compare(a, b) {
|
||||
if (a.DT < b.DT) {
|
||||
@ -2616,14 +2269,6 @@ function submitNewDailyData(Instrument, NewData) {
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
for (let i = 0; i < NewData.length; i++) {
|
||||
if (NewData[i].DT > currentMaxDT || NewData[i].DT < currentMinDT) {
|
||||
Instrument.DailyData.push(NewData[i]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
@ -3176,15 +2821,6 @@ function createHoldingsTable() {
|
||||
var resort = true;
|
||||
$("#tblMainHoldings").trigger("update", [resort]);
|
||||
|
||||
/*
|
||||
//Update the total holdings span in the site banner
|
||||
let formattedAmount = formatAmount(totalValueGBP, "GBP", 0);
|
||||
$("#spnTotalHoldings").html("Total holdings: " + formattedAmount);
|
||||
//Set the page title
|
||||
document.title = formattedAmount + ' - ' + initialPageTitle;
|
||||
*/
|
||||
|
||||
|
||||
//Update the daily holdings value table in the DB
|
||||
if (totalValueGBP != lastTotalHoldingsValue) {
|
||||
$.ajax({
|
||||
@ -3201,11 +2837,6 @@ function createHoldingsTable() {
|
||||
|
||||
//Update the total holdings span in the site banner
|
||||
let formattedAmount = formatAmount(totalValueGBP, "GBP", 0);
|
||||
/*let holdingsHTML = '<table><tr><td><span style="font-size: small;">Total holdings: </span>' + '<span style="font-size: large">' + formattedAmount + '</span></td>';
|
||||
holdingsHTML += '<td style="font-size: small;"><span class="' + (previousClose < totalValueGBP ? 'profit">+' : 'loss">') + formatAmount(totalValueGBP - previousClose, "GBP", 0) + '</span> (d)';
|
||||
holdingsHTML += ' / <span class="' + (previousWeekClose < totalValueGBP ? 'profit">+' : 'loss">') + formatAmount(totalValueGBP - previousWeekClose, "GBP", 0) + '</span> (w)</td></tr>';
|
||||
holdingsHTML += '</table>';
|
||||
*/
|
||||
let holdingsHTML = '<span style="font-size: small;">Total holdings: </span>' + '<span style="font-size: large">' + formattedAmount + '</span> ';
|
||||
holdingsHTML += '<span style="font-size: small;"><span class="' + (previousClose < totalValueGBP ? 'profit">+' : 'loss">') + formatAmount(totalValueGBP - previousClose, "GBP", 0) + '</span> (d)';
|
||||
holdingsHTML += ' / <span class="' + (previousWeekClose < totalValueGBP ? 'profit">+' : 'loss">') + formatAmount(totalValueGBP - previousWeekClose, "GBP", 0) + '</span> (w)</span>';
|
||||
@ -3358,14 +2989,7 @@ function createAccountsTables() {
|
||||
let profitOrLoss = a.totalGainGBP < 0 ? 'loss' : 'profit';
|
||||
if (a.holdings.length > 0) {
|
||||
altRow = !altRow;
|
||||
/*summaryTable += "<tr" + (altRow ? ' class="altShareRow"' : '') + "><td>" + a.accountName + "</td>" +
|
||||
"<td>" + a.holdings.length + "</td>" +
|
||||
"<td class='num'>" + formatAmount(a.totalCostGBP || 0, 'GBP', 2) + "</td>" +
|
||||
"<td class='num'>" + formatAmount(a.totalValueGBP || 0, 'GBP', 2) + "</td>" +
|
||||
"<td class='num " + profitOrLoss + "'>" + formatAmount(a.totalGainGBP || 0, 'GBP', 2) + "</td>" +
|
||||
"</tr>";
|
||||
*/
|
||||
|
||||
|
||||
accountsTables += '<br>' + a.accountName + '<br>'
|
||||
let tableID = 'accountTable' + ax;
|
||||
tableIDs.push(tableID);
|
||||
@ -3385,9 +3009,6 @@ function createAccountsTables() {
|
||||
'<th>Gain £</th>' +
|
||||
'<th>Gain %</th>' +
|
||||
'</tr></thead><tbody>';
|
||||
//let accountGainsGBP = 0;
|
||||
//let accountLossesGBP = 0;
|
||||
//let accountValueGBP = 0;
|
||||
let accountAltRow = 1;
|
||||
for (let hx = 0; hx < a.holdings.length; hx++) {
|
||||
let h = a.holdings[hx];
|
||||
@ -4216,29 +3837,6 @@ function refreshHistoryChart() {
|
||||
|
||||
chartContainer.html(response);
|
||||
|
||||
/*
|
||||
Highcharts.stockChart('histDiv', {
|
||||
title: {
|
||||
text: 'Total Holdings History'
|
||||
},
|
||||
|
||||
series: [{
|
||||
type: 'ohlc',
|
||||
name: 'Total Holdings',
|
||||
data: seriesData,
|
||||
lineWidth: 4
|
||||
}],
|
||||
|
||||
plotOptions: {
|
||||
ohlc: {
|
||||
color: 'red',
|
||||
upColor: 'green'
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
Highcharts.stockChart('histDiv', {
|
||||
chart: {
|
||||
backgroundColor: 'rgba(0,0,0,0)'/*,
|
||||
|
Loading…
Reference in New Issue
Block a user