get huge eth price
continuous-integration/drone/push Build is passing Details

master
dustoair 3 years ago
parent a175f800cc
commit d2a507dece

@ -23,3 +23,18 @@ func GetBinanceLatestPrice(symbol string) float64 {
global.DB.Where("symbol = ?", symbol).Last(&binancePrice) global.DB.Where("symbol = ?", symbol).Last(&binancePrice)
return binancePrice.Price return binancePrice.Price
} }
func GetBinanceLatestPrices(symbol string) []BinancePrice {
var binancePrices []BinancePrice
global.DB.Where("symbol = ?", symbol).Find(&binancePrices)
return binancePrices
}
func GetSerivers(symbol string) (timeUpdate []string, symbolPrice []float64) {
binancePrices := GetBinanceLatestPrices(symbol)
for _, binancePrice := range binancePrices {
timeUpdate = append(timeUpdate, binancePrice.UpdatedAt.Format("2006-01-02 15:04:05"))
symbolPrice = append(symbolPrice, binancePrice.Price)
}
return
}

@ -9,6 +9,7 @@ package goCharts
*/ */
import ( import (
"WechatGateWay/api"
"github.com/vicanso/go-charts/v2" "github.com/vicanso/go-charts/v2"
"math/rand" "math/rand"
"time" "time"
@ -24,11 +25,12 @@ func getRand(len int) []float64 {
} }
func Draw() { func Draw() {
timeUpdate, symbolPrice := api.GetSerivers("ETHUSDT")
values := [][]float64{ values := [][]float64{
getRand(30), symbolPrice,
getRand(30), //getRand(30),
getRand(30), //getRand(30),
getRand(30), //getRand(30),
} }
p, err := charts.LineRender( p, err := charts.LineRender(
values, values,
@ -37,12 +39,13 @@ func Draw() {
charts.WidthOptionFunc(720), charts.WidthOptionFunc(720),
charts.HeightOptionFunc(1280), charts.HeightOptionFunc(1280),
charts.TitleTextOptionFunc("symbol price"), charts.TitleTextOptionFunc("symbol price"),
charts.XAxisDataOptionFunc(getLastDays(30)), charts.XAxisDataOptionFunc(timeUpdate),
//charts.XAxisDataOptionFunc(getLastDays(30)),
charts.LegendLabelsOptionFunc([]string{ charts.LegendLabelsOptionFunc([]string{
"BTC",
"ETH", "ETH",
"BNB", //"ETH",
"TRX", //"BNB",
//"TRX",
}, "150"), }, "150"),
func(opt *charts.ChartOption) { func(opt *charts.ChartOption) {
opt.Legend.Padding = charts.Box{ opt.Legend.Padding = charts.Box{

@ -1,5 +1,6 @@
[![Build Status](https://ci.yangqiao.org/api/badges/go/WechatGateWay/status.svg)](https://ci.yangqiao.org/go/WechatGateWay) [![Build Status](https://ci.yangqiao.org/api/badges/go/WechatGateWay/status.svg)](https://ci.yangqiao.org/go/WechatGateWay)
![](https://i.niupic.com/images/2022/09/17/a5ia.png)
![](https://cnjdmh6kwm1w.compat.objectstorage.ap-seoul-1.oraclecloud.com/s3/2022/07/29d6e88c6061f4d56315cb36f2c66036.png) ![](https://cnjdmh6kwm1w.compat.objectstorage.ap-seoul-1.oraclecloud.com/s3/2022/07/29d6e88c6061f4d56315cb36f2c66036.png)
# 接收消息与事件 # 接收消息与事件
https://developer.work.weixin.qq.com/document/10514 https://developer.work.weixin.qq.com/document/10514

Loading…
Cancel
Save