market.go 658 B

123456789101112131415161718192021222324252627282930313233
  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. Talib
  12. Connect(done chan struct{}) (chan MarketConnection, error)
  13. Subscribe(symbol string) error
  14. IsMarketOpened() bool
  15. Time() Clock
  16. LatestBar(symbol string) (Bar, error)
  17. Buy(ctx context.Context, symbol string, ratio float64) (Order, error)
  18. Sell(ctx context.Context, symbol string, ratio float64) (Order, error)
  19. CancelOrder(id string) error
  20. Orders() ([]Order, error)
  21. Portfolio() (Portfolio, error)
  22. AvailableCash() (float64, error)
  23. MaxBudget() float64
  24. }