position.go 897 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package sentio
  2. type Position interface {
  3. // GetSize returns the total size of the position
  4. GetSize() float64
  5. // GetAvgPrice returns the average cost of each share in the position when purchased
  6. GetAvgPrice() float64
  7. // GetSymbol returns the ticker symbol of the traded contract
  8. GetSymbol() string
  9. // GetPnL returns unrealized profit/loss in dollars
  10. GetPnL() float64
  11. // GetCurrentPrice returns current asset price per share
  12. GetCurrentPrice() float64
  13. }
  14. type PositionStub struct {
  15. Symbol string
  16. Size float64
  17. Price float64
  18. PnL float64
  19. Current float64
  20. }
  21. func (p PositionStub) GetSize() float64 {
  22. return p.Size
  23. }
  24. func (p PositionStub) GetAvgPrice() float64 {
  25. return p.Price
  26. }
  27. func (p PositionStub) GetSymbol() string {
  28. return p.Symbol
  29. }
  30. func (p PositionStub) GetPnL() float64 {
  31. return p.PnL
  32. }
  33. func (p PositionStub) GetCurrentPrice() float64 {
  34. return p.Current
  35. }