Commit 5edc28b6 authored by wuxiaoli's avatar wuxiaoli

修改价格定义

parent 93a0af97
......@@ -37,9 +37,9 @@ class Trade extends Common
$res['market_value'] = 0;
foreach ($pos as $k => $v ) {
$data = z_market($v['gupiao_code']);
if($data['Price'] == '') continue;
$res['return_money'] += ($data['Price'] - $v['buy_average_price']) * $v['stock_count'];
$res['market_value'] += $data['Price'] * $v['stock_count'];
if($data['current_price'] == '') continue;
$res['return_money'] += ($data['current_price'] - $v['buy_average_price']) * $v['stock_count'];
$res['market_value'] += $data['current_price'] * $v['stock_count'];
}
// 提盈额度计算
$all = $res['market_value'] + $res['avail'];
......@@ -86,16 +86,16 @@ class Trade extends Common
//查询子账户
$data[$k]['sub_account'] = $res['sub_account'];
//提取当前价格
$data[$k]['now_price'] = $Qdata['Price'];
$data[$k]['now_price'] = $Qdata['current_price'];
//市值 = 当前价格*数量
$data[$k]['market_value'] = round((int)$Qdata['Price']*(int)$item['stock_count'],2);
$data[$k]['market_value'] = round((int)$Qdata['current_price']*(int)$item['stock_count'],2);
//参考成本价
$data[$k]['ck_price'] = Position::calculate($subid,$item["gupiao_code"],'price');
//买入均价
$data[$k]['buy_average_price'] = Position::calculate($subid,$item["gupiao_code"],'average');
//参考盈亏
//$data[$k]['ck_profit'] = $item['stock_count'] > 0 ? round(($Qdata['Price']-$data[$k]['buy_average_price'])*$item['stock_count'], 2) : 0;
$data[$k]['ck_profit'] = $item['stock_count'] > 0 ? bcmul(strval((int)$Qdata["Price"]-(int)$data[$k]['buy_average_price']),strval($item['stock_count']),2) : 0;//参考浮动盈亏
$data[$k]['ck_profit'] = $item['stock_count'] > 0 ? bcmul(strval((int)$Qdata["current_price"]-(int)$data[$k]['buy_average_price']),strval($item['stock_count']),2) : 0;//参考浮动盈亏
//盈亏比例
//$data[$k]['profit_rate'] = $item['stock_count'] > 0 ? round(($data[$k]['ck_profit'] / ($data[$k]['buy_average_price'] * $item['stock_count'])) * 100, 2) : 0;
//$data[$k]['profit_rate'] = $item['stock_count'] > 0 ? bcdiv(strval($data[$k]['ck_profit']),strval($data[$k]['buy_average_price']*$item['stock_count']*100),2) : 0;//盈亏比例
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment