1234567891011121314151617181920212223242526272829303132333435 |
- package sentio
- import (
- "fmt"
- "strings"
- )
- type OrderAction string
- func (oa OrderAction) String() string {
- return string(oa)
- }
- const (
- OrderBuy OrderAction = "BUY"
- OrderSell OrderAction = "SELL"
- )
- func ParseOrderAction(s string) (OrderAction, error) {
- s = strings.TrimSpace(s)
- s = strings.ToUpper(s)
- switch s {
- case "BUY":
- return OrderBuy, nil
- case "B":
- return OrderBuy, nil
- case "SELL":
- return OrderSell, nil
- case "S":
- return OrderSell, nil
- }
- return "undefined", fmt.Errorf("ParseOrderAction: undefined `%s`", s)
- }
|