|
@@ -0,0 +1,52 @@
|
|
|
+package sentio
|
|
|
+
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
+
|
|
|
+// TimeInForce Specifies how long the order remains in effect. Absence of this field is interpreted as DAY.
|
|
|
+// See more at https://www.onixs.biz/fix-dictionary/4.2/tagNum_59.html
|
|
|
+type TimeInForce int
|
|
|
+
|
|
|
+var tifs = map[TimeInForce]string{
|
|
|
+ TIFDay: "DAY",
|
|
|
+ TIFGoodTillCancel: "GTC",
|
|
|
+ TIFOpenPriceGuarantee: "OPG",
|
|
|
+ TIFImmediateOrCancel: "IOC",
|
|
|
+ TIFFillOrKill: "FOK",
|
|
|
+ TIFGoodTillCrossing: "GTX",
|
|
|
+ TIFGoodTillDate: "GTD",
|
|
|
+}
|
|
|
+
|
|
|
+func (tif TimeInForce) String() string {
|
|
|
+ t, ok := tifs[tif]
|
|
|
+ if !ok {
|
|
|
+ return "undefined"
|
|
|
+ }
|
|
|
+
|
|
|
+ return t
|
|
|
+}
|
|
|
+
|
|
|
+func ParseTimeInForce(s string) (TimeInForce, error) {
|
|
|
+ s = strings.TrimSpace(s)
|
|
|
+ s = strings.ToUpper(s)
|
|
|
+
|
|
|
+ for t, l := range tifs {
|
|
|
+ if s == l {
|
|
|
+ return t, nil
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return -1, fmt.Errorf("`tif.Parse`: undefined TimeInForce `%s`", s)
|
|
|
+}
|
|
|
+
|
|
|
+const (
|
|
|
+ TIFDay TimeInForce = 0
|
|
|
+ TIFGoodTillCancel TimeInForce = 1
|
|
|
+ TIFOpenPriceGuarantee TimeInForce = 2
|
|
|
+ TIFImmediateOrCancel TimeInForce = 3
|
|
|
+ TIFFillOrKill TimeInForce = 4
|
|
|
+ TIFGoodTillCrossing TimeInForce = 5
|
|
|
+ TIFGoodTillDate TimeInForce = 6
|
|
|
+)
|