Skip to content

Commit

Permalink
Merge pull request #420 from lmhtolin/stock-profit-update
Browse files Browse the repository at this point in the history
fix: issue#399当日收益计算字段更换
  • Loading branch information
giscafer authored Mar 9, 2024
2 parents 0982a61 + 13bd2bd commit 1294588
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/statusbar/Profit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class ProfitStatusBar {
stockList.forEach((s) => {
let tmp = {} as StockInfoType;
const { id, info } = s;
const { high, low, open, percent, price, name } = info;
const { high, low, open, yestclose, percent, price, name } = info;
if (id && open && price) {
const config = stockPrice[id];
if (!config || config.amount === 0 || config.unitPrice === 0) {
Expand All @@ -137,7 +137,8 @@ export class ProfitStatusBar {
// const incomeTotal = amount * (Number(price).toFixed(2) - unitPrice.toFixed(2));
// const incomeToday = amount * (Number(price).toFixed(2) - Number(open).toFixed(2));
const incomeTotal = (amount * (Number(price) - unitPrice)).toFixed(2);
const incomeToday = (amount * (Number(price) - Number(open))).toFixed(2);
// fix #399,在昨日收盘价没有的时候使用今日开盘价
const incomeToday = (amount * (Number(price) - Number(yestclose || open))).toFixed(2);
const percentTotal = ((Number(incomeTotal) / (unitPrice * amount)) * 100).toFixed(2);
tmp = {
id,
Expand Down

0 comments on commit 1294588

Please sign in to comment.