@@ -214,3 +214,62 @@ func TestMinPrice(t *testing.T) {
214214 assert .Nil (t , price )
215215 })
216216}
217+
218+ func TestMaxPrice (t * testing.T ) {
219+ t .Run ("BTCUSDT max price" , func (t * testing.T ) {
220+ memory := storage .NewMemory [connector.TickerUpdate ]()
221+ api := & API {
222+ store : memory ,
223+ }
224+
225+ api .store .Store ("binance:BTCUSDT:spot" , connector.TickerUpdate {
226+ Spot : & connector.SpotPriceUpdate {
227+ Price : big .NewFloat (10000 ),
228+ },
229+ })
230+
231+ api .store .Store ("okx:BTCUSDT:spot" , connector.TickerUpdate {
232+ Spot : & connector.SpotPriceUpdate {
233+ Price : big .NewFloat (10010 ),
234+ },
235+ })
236+
237+ price , err := api .maxPrice ("BTCUSDT" , []string {"binance" , "okx" }, "spot" )
238+ assert .NoError (t , err )
239+ assert .Equal (t , big .NewFloat (10010 ), price )
240+ })
241+
242+ t .Run ("Exchange not found" , func (t * testing.T ) {
243+ memory := storage .NewMemory [connector.TickerUpdate ]()
244+ api := & API {
245+ store : memory ,
246+ }
247+
248+ api .store .Store ("binance:BTCUSDT:spot" , connector.TickerUpdate {
249+ Spot : & connector.SpotPriceUpdate {
250+ Price : big .NewFloat (10000 ),
251+ },
252+ })
253+
254+ price , err := api .maxPrice ("BTCUSDT" , []string {"binance" , "okx" }, "spot" )
255+ assert .Error (t , err )
256+ assert .Nil (t , price )
257+ })
258+
259+ t .Run ("Symbol not found" , func (t * testing.T ) {
260+ memory := storage .NewMemory [connector.TickerUpdate ]()
261+ api := & API {
262+ store : memory ,
263+ }
264+
265+ api .store .Store ("binance:BTCUSDT:spot" , connector.TickerUpdate {
266+ Spot : & connector.SpotPriceUpdate {
267+ Price : big .NewFloat (10000 ),
268+ },
269+ })
270+
271+ price , err := api .maxPrice ("ETHUSDT" , []string {"binance" }, "spot" )
272+ assert .Error (t , err )
273+ assert .Nil (t , price )
274+ })
275+ }
0 commit comments