fix bug
This commit is contained in:
@@ -31,6 +31,7 @@ type CollectorOrder struct {
|
|||||||
Ymd int `json:"ymd" gorm:"not null;index;comment:采集日期(年月日数字格式,如20260407)"`
|
Ymd int `json:"ymd" gorm:"not null;index;comment:采集日期(年月日数字格式,如20260407)"`
|
||||||
Price float64 `json:"price" gorm:"type:decimal(10,4);not null;default:0;comment:委托价格"`
|
Price float64 `json:"price" gorm:"type:decimal(10,4);not null;default:0;comment:委托价格"`
|
||||||
Volume int `json:"volume" gorm:"not null;default:0;comment:委托数量"`
|
Volume int `json:"volume" gorm:"not null;default:0;comment:委托数量"`
|
||||||
|
OpenPrice float64 `json:"open_price" gorm:"type:decimal(10,4);not null;default:0;column:open_price;comment:开仓价格"`
|
||||||
TradedPrice float64 `json:"traded_price" gorm:"type:decimal(10,4);not null;default:0;column:traded_price;comment:成交均价"`
|
TradedPrice float64 `json:"traded_price" gorm:"type:decimal(10,4);not null;default:0;column:traded_price;comment:成交均价"`
|
||||||
TradedVolume int `json:"traded_volume" gorm:"not null;default:0;column:traded_volume;comment:成交数量"`
|
TradedVolume int `json:"traded_volume" gorm:"not null;default:0;column:traded_volume;comment:成交数量"`
|
||||||
OrderStatus int `json:"order_status" gorm:"not null;default:0;column:order_status;comment:订单状态"`
|
OrderStatus int `json:"order_status" gorm:"not null;default:0;column:order_status;comment:订单状态"`
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package storage
|
package storage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
@@ -138,6 +139,12 @@ func (s *Storage) SaveStatus(status *types.Status, dataHash string) error {
|
|||||||
if order.StockCode == "" {
|
if order.StockCode == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
var open_price float64
|
||||||
|
var info types.OrderInfo
|
||||||
|
err = json.Unmarshal([]byte(order.OrderRemark), &info)
|
||||||
|
if err == nil {
|
||||||
|
open_price = info.Op
|
||||||
|
}
|
||||||
|
|
||||||
// 查询是否存在
|
// 查询是否存在
|
||||||
var existingOrder models.CollectorOrder
|
var existingOrder models.CollectorOrder
|
||||||
@@ -151,6 +158,7 @@ func (s *Storage) SaveStatus(status *types.Status, dataHash string) error {
|
|||||||
Ymd: ymd,
|
Ymd: ymd,
|
||||||
Price: order.Price,
|
Price: order.Price,
|
||||||
Volume: order.Volume,
|
Volume: order.Volume,
|
||||||
|
OpenPrice: open_price,
|
||||||
TradedPrice: order.TradedPrice,
|
TradedPrice: order.TradedPrice,
|
||||||
TradedVolume: order.TradedVolume,
|
TradedVolume: order.TradedVolume,
|
||||||
OrderStatus: order.OrderStatus,
|
OrderStatus: order.OrderStatus,
|
||||||
|
|||||||
@@ -82,3 +82,9 @@ type Config struct {
|
|||||||
QmtStatus string `json:"qmt_status"`
|
QmtStatus string `json:"qmt_status"`
|
||||||
StartTime int64 `json:"start_time"`
|
StartTime int64 `json:"start_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OrderInfo struct {
|
||||||
|
Op float64 `json:"op"`
|
||||||
|
Pnl float64 `json:"pnl"`
|
||||||
|
Ac int `json:"ac"`
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user