github.com/polygon-io/client-go@v1.16.4/rest/models/indicators_test.go (about) 1 package models_test 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/polygon-io/client-go/rest/models" 8 ) 9 10 func TestGetSMAParams(t *testing.T) { 11 timespan := models.Week 12 timestamp := models.Millis(time.Date(2022, 7, 25, 0, 0, 0, 0, time.UTC)) 13 series := models.Close 14 expand := true 15 adjusted := true 16 order := models.Asc 17 limit := 100 18 window := 5 19 expect := models.GetSMAParams{ 20 Timespan: ×pan, 21 TimestampEQ: ×tamp, 22 TimestampLT: ×tamp, 23 TimestampLTE: ×tamp, 24 TimestampGT: ×tamp, 25 TimestampGTE: ×tamp, 26 SeriesType: &series, 27 ExpandUnderlying: &expand, 28 Adjusted: &adjusted, 29 Order: &order, 30 Limit: &limit, 31 Window: &window, 32 } 33 actual := models.GetSMAParams{}. 34 WithTimespan(timespan). 35 WithTimestamp(models.EQ, timestamp). 36 WithTimestamp(models.LT, timestamp). 37 WithTimestamp(models.LTE, timestamp). 38 WithTimestamp(models.GT, timestamp). 39 WithTimestamp(models.GTE, timestamp). 40 WithSeriesType(series). 41 WithExpandUnderlying(expand). 42 WithAdjusted(adjusted). 43 WithOrder(order). 44 WithLimit(limit). 45 WithWindow(window) 46 47 checkParams(t, expect, *actual) 48 } 49 50 func TestGetEMAParams(t *testing.T) { 51 timespan := models.Week 52 timestamp := models.Millis(time.Date(2022, 7, 25, 0, 0, 0, 0, time.UTC)) 53 series := models.Close 54 expand := true 55 adjusted := true 56 order := models.Asc 57 limit := 100 58 window := 5 59 expect := models.GetEMAParams{ 60 Timespan: ×pan, 61 TimestampEQ: ×tamp, 62 TimestampLT: ×tamp, 63 TimestampLTE: ×tamp, 64 TimestampGT: ×tamp, 65 TimestampGTE: ×tamp, 66 SeriesType: &series, 67 ExpandUnderlying: &expand, 68 Adjusted: &adjusted, 69 Order: &order, 70 Limit: &limit, 71 Window: &window, 72 } 73 actual := models.GetEMAParams{}. 74 WithTimespan(timespan). 75 WithTimestamp(models.EQ, timestamp). 76 WithTimestamp(models.LT, timestamp). 77 WithTimestamp(models.LTE, timestamp). 78 WithTimestamp(models.GT, timestamp). 79 WithTimestamp(models.GTE, timestamp). 80 WithSeriesType(series). 81 WithExpandUnderlying(expand). 82 WithAdjusted(adjusted). 83 WithOrder(order). 84 WithLimit(limit). 85 WithWindow(window) 86 87 checkParams(t, expect, *actual) 88 } 89 90 func TestGetRSIParams(t *testing.T) { 91 timespan := models.Week 92 timestamp := models.Millis(time.Date(2022, 7, 25, 0, 0, 0, 0, time.UTC)) 93 series := models.Close 94 expand := true 95 adjusted := true 96 order := models.Asc 97 limit := 100 98 window := 5 99 expect := models.GetRSIParams{ 100 Timespan: ×pan, 101 TimestampEQ: ×tamp, 102 TimestampLT: ×tamp, 103 TimestampLTE: ×tamp, 104 TimestampGT: ×tamp, 105 TimestampGTE: ×tamp, 106 SeriesType: &series, 107 ExpandUnderlying: &expand, 108 Adjusted: &adjusted, 109 Order: &order, 110 Limit: &limit, 111 Window: &window, 112 } 113 actual := models.GetRSIParams{}. 114 WithTimespan(timespan). 115 WithTimestamp(models.EQ, timestamp). 116 WithTimestamp(models.LT, timestamp). 117 WithTimestamp(models.LTE, timestamp). 118 WithTimestamp(models.GT, timestamp). 119 WithTimestamp(models.GTE, timestamp). 120 WithSeriesType(series). 121 WithExpandUnderlying(expand). 122 WithAdjusted(adjusted). 123 WithOrder(order). 124 WithLimit(limit). 125 WithWindow(window) 126 127 checkParams(t, expect, *actual) 128 } 129 130 func TestGetMACDParams(t *testing.T) { 131 timespan := models.Week 132 timestamp := models.Millis(time.Date(2022, 7, 25, 0, 0, 0, 0, time.UTC)) 133 series := models.Close 134 expand := true 135 adjusted := true 136 order := models.Asc 137 limit := 100 138 shortWindow := 12 139 longWindow := 26 140 signalWindow := 9 141 expect := models.GetMACDParams{ 142 Timespan: ×pan, 143 TimestampEQ: ×tamp, 144 TimestampLT: ×tamp, 145 TimestampLTE: ×tamp, 146 TimestampGT: ×tamp, 147 TimestampGTE: ×tamp, 148 SeriesType: &series, 149 ExpandUnderlying: &expand, 150 Adjusted: &adjusted, 151 Order: &order, 152 Limit: &limit, 153 ShortWindow: &shortWindow, 154 LongWindow: &longWindow, 155 SignalWindow: &signalWindow, 156 } 157 actual := models.GetMACDParams{}. 158 WithTimespan(timespan). 159 WithTimestamp(models.EQ, timestamp). 160 WithTimestamp(models.LT, timestamp). 161 WithTimestamp(models.LTE, timestamp). 162 WithTimestamp(models.GT, timestamp). 163 WithTimestamp(models.GTE, timestamp). 164 WithSeriesType(series). 165 WithExpandUnderlying(expand). 166 WithAdjusted(adjusted). 167 WithOrder(order). 168 WithLimit(limit). 169 WithShortWindow(shortWindow). 170 WithLongWindow(longWindow). 171 WithSignalWindow(signalWindow) 172 173 checkParams(t, expect, *actual) 174 }