fix bug
This commit is contained in:
@@ -32,7 +32,8 @@ func ClosedTable() {
|
||||
var data []models.MockPosition
|
||||
impl.DBService.Where("status=?", 1).Find(&data)
|
||||
var tPNL, tPNLR, cost, sell float64
|
||||
for _, item := range data {
|
||||
|
||||
for idx, item := range data {
|
||||
var stock models.StockBasic
|
||||
impl.DBService.Where("ts_code=?", item.Code).First(&stock)
|
||||
|
||||
@@ -43,7 +44,7 @@ func ClosedTable() {
|
||||
cost = cost + item.OpenPrice
|
||||
sell = sell + item.ClosePrice
|
||||
|
||||
tw.AppendRow(table.Row{item.ID, item.Code, stock.Name, item.CreatedAt.Format("2006-01-02"), item.OpenPrice, item.UpdatedAt.Format("2006-01-02"), item.ClosePrice, pnl, pnlRate})
|
||||
tw.AppendRow(table.Row{idx + 1, item.Code, stock.Name, item.CreatedAt.Format("2006-01-02"), item.OpenPrice, item.UpdatedAt.Format("2006-01-02"), item.ClosePrice, pnl, pnlRate})
|
||||
}
|
||||
|
||||
tPNLR = utils.FloatRound(((sell-cost)/cost)*100, 2)
|
||||
@@ -61,7 +62,8 @@ func UnclosedTable() {
|
||||
var data []models.MockPosition
|
||||
impl.DBService.Where("status=?", 0).Find(&data)
|
||||
var tPNL, tPNLR, cost, sell float64
|
||||
for _, item := range data {
|
||||
|
||||
for idx, item := range data {
|
||||
var stock models.StockBasic
|
||||
impl.DBService.Where("ts_code=?", item.Code).First(&stock)
|
||||
|
||||
@@ -76,7 +78,7 @@ func UnclosedTable() {
|
||||
cost = cost + item.OpenPrice
|
||||
sell = sell + high
|
||||
|
||||
tw.AppendRow(table.Row{item.ID, item.Code, stock.Name, item.CreatedAt.Format("2006-01-02"), item.OpenPrice, high, pnl, pnlRate})
|
||||
tw.AppendRow(table.Row{idx + 1, item.Code, stock.Name, item.CreatedAt.Format("2006-01-02"), item.OpenPrice, high, pnl, pnlRate})
|
||||
}
|
||||
|
||||
tPNLR = utils.FloatRound(((sell-cost)/cost)*100, 2)
|
||||
|
||||
Reference in New Issue
Block a user