2
0

market.go 693 B

12345678910111213141516171819202122232425262728293031
  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. Account() (MarketAccount, error)
  22. MaxBudget() float64
  23. Cooldown() uint8
  24. }