2
0

market.go 711 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. Buy(ctx context.Context, symbol string, ratio float64) (float64, Order, error)
  16. Sell(ctx context.Context, symbol string, ratio float64) (float64, Order, error)
  17. CancelOrder(id string) error
  18. Orders() ([]Order, error)
  19. Portfolio() (Portfolio, error)
  20. PortfolioHistory() ([]PortfolioRecord, error)
  21. Cash() (float64, error)
  22. Equity() (float64, error)
  23. MaxBudget() float64
  24. Cooldown() uint8
  25. }