market.go 827 B

1234567891011121314151617181920212223242526272829303132333435
  1. package sentio
  2. import (
  3. "context"
  4. "errors"
  5. "time"
  6. )
  7. var (
  8. ErrMarketClosed = errors.New("market is closed")
  9. ErrTooSmallOrder = errors.New("too small order size")
  10. )
  11. type Market interface {
  12. Connect(done chan struct{}) (chan MarketConnection, error)
  13. Subscribe(symbol string) error
  14. IsMarketOpened() bool
  15. Time() Clock
  16. Buy(ctx context.Context, symbol string, ratio float64) (float64, Order, error)
  17. Sell(ctx context.Context, symbol string, ratio float64) (float64, Order, error)
  18. CancelOrder(id string) error
  19. Orders() ([]Order, error)
  20. Portfolio() (Portfolio, error)
  21. PortfolioHistory() ([]PortfolioRecord, error)
  22. HistoricalBars(symbol string, interval time.Duration, from *time.Time) ([]Bar, error)
  23. Quote(symbol string) (*Quote, error)
  24. Account() (MarketAccount, error)
  25. MaxBudget() float64
  26. Cooldown() uint8
  27. }