瀏覽代碼

Market

- add LatestBar(symbol string) (Bar, error)
Alexey Kim 1 月之前
父節點
當前提交
5ce02a0436
共有 2 個文件被更改,包括 15 次插入0 次删除
  1. 13 0
      bar.go
  2. 2 0
      market.go

+ 13 - 0
bar.go

@@ -0,0 +1,13 @@
+package sentio
+
+import "time"
+
+type Bar struct {
+	Datetime time.Time `json:"datetime" yaml:"datetime"`
+	Open     float64   `json:"open" yaml:"open"`
+	High     float64   `json:"high" yaml:"high"`
+	Low      float64   `json:"low" yaml:"low"`
+	Close    float64   `json:"close" yaml:"close"`
+	Volume   float64   `json:"volume" yaml:"volume"`
+	Trades   int       `json:"trades" yaml:"trades"`
+}

+ 2 - 0
market.go

@@ -19,6 +19,8 @@ type Market interface {
 	IsMarketOpened() bool
 	Time() Clock
 
+	LatestBar(symbol string) (Bar, error)
+
 	Buy(ctx context.Context, symbol string, ratio float64) (Order, error)
 	Sell(ctx context.Context, symbol string, ratio float64) (Order, error)
 	CancelOrder(id string) error