JSFiddle - React, Tailwind, and code Playground
by Viet27th
JavaScript
let getLastPrice = function (e){
let t = e.split("|");
let n = {
floorCode:t[0],
tradingDate:t[1],
time:t[2],
code:t[3],
companyName:t[4],
stockType:t[5],
totalRoom:parseInt(t[6]),
currentRoom:parseInt(t[7]),
basicPrice:parseFloat(t[8]),
openPrice:parseFloat(t[9]),
closePrice:parseFloat(t[10]),
currentPrice:parseFloat(t[11]),
currentQtty:parseInt(t[12]),
highestPrice:parseFloat(t[13]),
lowestPrice:parseFloat(t[14]),
ceilingPrice:parseFloat(t[15]),
floorPrice:parseFloat(t[16]),
totalOfferQtty:parseInt(t[17]),
totalBidQtty:parseInt(t[18]),
matchPrice:parseFloat(t[19]),
matchQtty:parseInt(t[20]),
matchValue:parseInt(t[21]),
averagePrice:parseFloat(t[22]),
bidPrice01:parseFloat(t[23]),
bidQtty01:parseInt(t[24]),
bidPrice02:parseFloat(t[25]),
bidQtty02:parseInt(t[26]),
bidPrice03:parseFloat(t[27]),
bidQtty03:parseInt(t[28]),
offerPrice01:parseFloat(t[29]),
offerQtty01:parseInt(t[30]),
offerPrice02:parseFloat(t[31]),
offerQtty02:parseInt(t[32]),
offerPrice03:parseFloat(t[33]),
offerQtty03:parseInt(t[34]),
accumulatedVal:parseFloat(t[35]),
accumulatedVol:parseFloat(t[36]),
buyForeignQtty:parseInt(t[37]),
sellForeignQtty:parseInt(t[38]),
projectOpen:parseFloat(t[39]),
sequence:t[40]
};
return 0 === n.accumulatedVol &&
(
n.matchPrice = n.basicPrice,
n.highestPrice = NaN,
n.lowestPrice = NaN,
n.accumulatedVal = NaN,
n.accumulatedVol=NaN
),n;
};
let x = getLastPrice("02|1591660800000|15:02:39|ART||ST||4239118.3|3|3.1|2.9|2.9|24790|3.1|2.8|3.3|2.7|702030|525340|2.9|90|0.00261|2.909|2.9|0|2.8|91000|2.7|127170|3|510|3.1|108350|3.2|68660|8.86499|304830|800||||||||");
console.log(1, x)