market.go 866 B

123456789101112131415161718192021222324252627282930313233
  1. package sentio
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. var (
  7. ErrMarketClosed = errors.New("market is closed")
  8. ErrTooSmallOrder = errors.New("too small order size")
  9. )
  10. type Market interface {
  11. Clock() Clock
  12. IsOpen() bool
  13. Cooldown() uint8
  14. Connect(done chan struct{}) (chan MarketConnection, error)
  15. Subscribe(symbols ...string) error
  16. Account() (MarketAccount, error)
  17. CreateOrder(symbol string, quantity uint, sl float64) (Order, error)
  18. UpdateOrder(orderID string, sl float64) error
  19. CloseOrder(orderID string) (Order, error)
  20. Order(orderID string, nested bool) (Order, error)
  21. Orders(criteria OrderListCriteria) ([]Order, error)
  22. Portfolio() (Portfolio, error)
  23. PortfolioHistory() ([]PortfolioRecord, error)
  24. Quotes(symbols ...string) (map[string]Quote, error)
  25. HistoricalBars(symbols []string, interval time.Duration, from *time.Time) (map[string][]Bar, error)
  26. }