fix
This commit is contained in:
63
cmd/top/main.go
Normal file
63
cmd/top/main.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.apinb.com/quant/gostock/internal/config"
|
||||
"git.apinb.com/quant/gostock/internal/impl"
|
||||
"git.apinb.com/quant/gostock/internal/logic/strategy"
|
||||
)
|
||||
|
||||
var (
|
||||
ServiceKey = "gostock"
|
||||
)
|
||||
|
||||
func main() {
|
||||
config.New(ServiceKey)
|
||||
impl.NewImpl()
|
||||
|
||||
fmt.Println("")
|
||||
ymd := lastYmd()
|
||||
strategy.TotalScore(ymd)
|
||||
//run(lastYmd())
|
||||
fmt.Println("")
|
||||
}
|
||||
|
||||
func lastYmd() int {
|
||||
var ymd int
|
||||
sql := "select ymd from strat_model sm group by ymd order by ymd desc limit 1"
|
||||
impl.DBService.Raw(sql).Scan(&ymd)
|
||||
return ymd
|
||||
}
|
||||
|
||||
func run(ymd int) {
|
||||
// tw := table.NewWriter()
|
||||
// tw.SetStyle(table.StyleLight)
|
||||
// tw.AppendHeader(table.Row{"ID", "Code", "Name", "OpenDate", "OpenPrice", "TodayPrice", "PNL/Per", "PNLRate(%)"})
|
||||
// var data []models.StratModel
|
||||
// impl.DBService.Where("status=?", 0).Find(&data)
|
||||
// var tPNL, tPNLR, cost, sell float64
|
||||
// for _, item := range data {
|
||||
// var stock models.StockBasic
|
||||
// impl.DBService.Where("ts_code=?", item.Code).First(&stock)
|
||||
|
||||
// var daily models.StockDaily
|
||||
// impl.DBService.Model(&models.StockDaily{}).Where("ts_code=?", item.Code).Order("id desc").Limit(1).First(&daily)
|
||||
|
||||
// high := utils.FloatRound(daily.High*0.995, 2)
|
||||
// pnl := utils.FloatRound(high-item.OpenPrice, 2)
|
||||
// pnlRate := utils.FloatRound(pnl/item.OpenPrice*100, 2)
|
||||
|
||||
// tPNL = tPNL + pnl
|
||||
// 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})
|
||||
// }
|
||||
|
||||
// tPNLR = utils.FloatRound(((sell-cost)/cost)*100, 2)
|
||||
|
||||
// tw.AppendFooter(table.Row{"", "", "", "TOTAL", utils.FloatRound(cost, 2), utils.FloatRound(sell, 2), utils.FloatRound(tPNL, 2), tPNLR})
|
||||
|
||||
// fmt.Println(tw.Render())
|
||||
}
|
||||
Reference in New Issue
Block a user