market.go 677 B

12345678910111213141516171819202122232425262728293031323334
  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. Cash() (float64, error)
  23. Equity() (float64, error)
  24. MaxBudget() float64
  25. }