Skip to content

Commit

Permalink
Add Price helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ammario committed Jan 5, 2024
1 parent 130bd86 commit 2ca560b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ func (c *CreateOrderRequest) SetPrice(p Cents) {
}
}

func (o *CreateOrderRequest) Price() Cents {
switch o.Side {
case Yes:
return o.YesPrice
case No:
return o.NoPrice
default:
panic("invalid side: " + string(o.Side))
}
}

// String returns a human-readable representation of the order.
func (c *CreateOrderRequest) String() string {
var price Cents
Expand Down

0 comments on commit 2ca560b

Please sign in to comment.