market.go 669 B

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