@rivascva/dt-idl 1.1.192 → 1.1.193
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/go/models/constants.go +100 -0
- package/go/models/structs.go +12 -0
- package/go/utils/market.go +19 -0
- package/package.json +1 -1
package/go/models/constants.go
CHANGED
|
@@ -40,6 +40,106 @@ const (
|
|
|
40
40
|
MarketCloseGracePeriod = 2 * time.Minute
|
|
41
41
|
)
|
|
42
42
|
|
|
43
|
+
var (
|
|
44
|
+
// MarketHolidays is a map of future market holidays.
|
|
45
|
+
// The key is the date of the holiday in YYYY-MM-DD format (based on the timezone specified in MarketTimezone).
|
|
46
|
+
// The value is the information about the holiday.
|
|
47
|
+
MarketHolidays = map[string]MarketHolidayInfo{
|
|
48
|
+
"2026-01-01": {
|
|
49
|
+
Name: "New Year's Day",
|
|
50
|
+
CloseTime: "",
|
|
51
|
+
},
|
|
52
|
+
"2026-01-19": {
|
|
53
|
+
Name: "Martin Luther King, Jr. Day",
|
|
54
|
+
CloseTime: "",
|
|
55
|
+
},
|
|
56
|
+
"2026-02-16": {
|
|
57
|
+
Name: "Presidents' Day",
|
|
58
|
+
CloseTime: "",
|
|
59
|
+
},
|
|
60
|
+
"2026-04-03": {
|
|
61
|
+
Name: "Good Friday",
|
|
62
|
+
CloseTime: "",
|
|
63
|
+
},
|
|
64
|
+
"2026-05-25": {
|
|
65
|
+
Name: "Memorial Day",
|
|
66
|
+
CloseTime: "",
|
|
67
|
+
},
|
|
68
|
+
"2026-06-19": {
|
|
69
|
+
Name: "Juneteenth National Independence Day",
|
|
70
|
+
CloseTime: "",
|
|
71
|
+
},
|
|
72
|
+
"2026-07-03": {
|
|
73
|
+
Name: "Independence Day (Observed)",
|
|
74
|
+
CloseTime: "",
|
|
75
|
+
},
|
|
76
|
+
"2026-09-07": {
|
|
77
|
+
Name: "Labor Day",
|
|
78
|
+
CloseTime: "",
|
|
79
|
+
},
|
|
80
|
+
"2026-11-26": {
|
|
81
|
+
Name: "Thanksgiving Day",
|
|
82
|
+
CloseTime: "",
|
|
83
|
+
},
|
|
84
|
+
"2026-11-27": {
|
|
85
|
+
Name: "Friday after Thanksgiving",
|
|
86
|
+
CloseTime: "13:00",
|
|
87
|
+
},
|
|
88
|
+
"2026-12-24": {
|
|
89
|
+
Name: "Christmas Eve",
|
|
90
|
+
CloseTime: "13:00",
|
|
91
|
+
},
|
|
92
|
+
"2026-12-25": {
|
|
93
|
+
Name: "Christmas Day",
|
|
94
|
+
CloseTime: "",
|
|
95
|
+
},
|
|
96
|
+
"2027-01-01": {
|
|
97
|
+
Name: "New Year's Day",
|
|
98
|
+
CloseTime: "",
|
|
99
|
+
},
|
|
100
|
+
"2027-01-18": {
|
|
101
|
+
Name: "Martin Luther King, Jr. Day",
|
|
102
|
+
CloseTime: "",
|
|
103
|
+
},
|
|
104
|
+
"2027-02-15": {
|
|
105
|
+
Name: "Presidents' Day",
|
|
106
|
+
CloseTime: "",
|
|
107
|
+
},
|
|
108
|
+
"2027-03-26": {
|
|
109
|
+
Name: "Good Friday",
|
|
110
|
+
CloseTime: "",
|
|
111
|
+
},
|
|
112
|
+
"2027-05-31": {
|
|
113
|
+
Name: "Memorial Day",
|
|
114
|
+
CloseTime: "",
|
|
115
|
+
},
|
|
116
|
+
"2027-06-18": {
|
|
117
|
+
Name: "Juneteenth National Independence Day (Observed)",
|
|
118
|
+
CloseTime: "",
|
|
119
|
+
},
|
|
120
|
+
"2027-07-05": {
|
|
121
|
+
Name: "Independence Day (Observed)",
|
|
122
|
+
CloseTime: "",
|
|
123
|
+
},
|
|
124
|
+
"2027-09-06": {
|
|
125
|
+
Name: "Labor Day",
|
|
126
|
+
CloseTime: "",
|
|
127
|
+
},
|
|
128
|
+
"2027-11-25": {
|
|
129
|
+
Name: "Thanksgiving Day",
|
|
130
|
+
CloseTime: "",
|
|
131
|
+
},
|
|
132
|
+
"2027-11-26": {
|
|
133
|
+
Name: "Friday after Thanksgiving",
|
|
134
|
+
CloseTime: "13:00",
|
|
135
|
+
},
|
|
136
|
+
"2027-12-24": {
|
|
137
|
+
Name: "Christmas Day (Observed)",
|
|
138
|
+
CloseTime: "",
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
|
|
43
143
|
var (
|
|
44
144
|
// PortfolioDefaultCash is the default cash for new portfolios.
|
|
45
145
|
PortfolioDefaultCash = float64(50000)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package models
|
|
2
|
+
|
|
3
|
+
// MarketHolidayInfo contains information about a market holiday.
|
|
4
|
+
type MarketHolidayInfo struct {
|
|
5
|
+
// Name is the name of the holiday.
|
|
6
|
+
Name string
|
|
7
|
+
// CloseTime is the time the market closes on the holiday in a 24-hour format (HH:mm).
|
|
8
|
+
// Based on the timezone specified in MarketTimezone.
|
|
9
|
+
// For some holidays, the market may simply close early.
|
|
10
|
+
// The value will be empty if the market closes the entire day.
|
|
11
|
+
CloseTime string
|
|
12
|
+
}
|
package/go/utils/market.go
CHANGED
|
@@ -66,6 +66,25 @@ func isMarketHoursWithOpenAndCloseOffsets(now time.Time, openOffset time.Duratio
|
|
|
66
66
|
return false, fmt.Errorf("unable to parse the close minute: %w", err)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// check if on a market holiday
|
|
70
|
+
if holidayInfo, ok := models.MarketHolidays[now.Format("2006-01-02")]; ok {
|
|
71
|
+
if holidayInfo.CloseTime == "" {
|
|
72
|
+
// the market closes the entire day
|
|
73
|
+
return false, nil
|
|
74
|
+
} else {
|
|
75
|
+
// the market closes early, so set the close time to the holiday close time
|
|
76
|
+
holidayCloseTimeParts := strings.Split(holidayInfo.CloseTime, ":")
|
|
77
|
+
closeHour, err = strconv.Atoi(holidayCloseTimeParts[0])
|
|
78
|
+
if err != nil {
|
|
79
|
+
return false, fmt.Errorf("unable to parse the holiday close hour: %w", err)
|
|
80
|
+
}
|
|
81
|
+
closeMinute, err = strconv.Atoi(holidayCloseTimeParts[1])
|
|
82
|
+
if err != nil {
|
|
83
|
+
return false, fmt.Errorf("unable to parse the holiday close minute: %w", err)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
69
88
|
// create the open time with the offset
|
|
70
89
|
openTime := time.Date(now.Year(), now.Month(), now.Day(), openHour, openMinute, 0, 0, loc)
|
|
71
90
|
openWithOffset := openTime.Add(openOffset)
|