| 12345678910111213141516171819202122232425262728293031 |
- import { QueryTradePositionRsp } from "../go/ermcp/order/interface";
- import { getQuoteDayInfoByCodeFindPrice } from "./goods";
- // 持仓盈亏
- // 浮动盈亏 持仓单:
- // 收益权=(最新价-持仓价)*持仓数量*合约单位*方向(买[1]:卖[-1])(*汇率)
- // 所有权=(最新价*持仓数量*合约单位(*汇率) - 持仓金额)
- export const useProfitloss = (record: QueryTradePositionRsp) => {
- // 最新价
- const lastPrice = getQuoteDayInfoByCodeFindPrice(record.goodscode);
- if (lastPrice !== '--') {
- const { averageprice, decimalplace, agreeunit, curpositionqty } = record;
- return ((+lastPrice - averageprice) * curpositionqty * agreeunit).toFixed(decimalplace);
- } else {
- return lastPrice;
- }
- }
- // 市值(所有权) = 数量 * 现价 * 合约单位
- export const useHolderprice = (record: QueryTradePositionRsp) => {
- // 最新价
- const lastPrice = getQuoteDayInfoByCodeFindPrice(record.goodscode);
- if (lastPrice !== '--') {
- const { decimalplace, agreeunit, curpositionqty } = record;
- return (+lastPrice * curpositionqty * agreeunit).toFixed(decimalplace);
- } else {
- return lastPrice
- }
- }
|