Petersoj / alpaca-java

A Java API for Alpaca, the commission free, algo friendly, stock trading broker. https://alpaca.markets
https://petersoj.github.io/alpaca-java/
MIT License
203 stars 83 forks source link

java.util.NoSuchElementException: List is empty #109

Closed uchitel closed 3 years ago

uchitel commented 3 years ago

I am using web sockets to stream market data. Somedays the SDK starts writing error messages for all tickers and I can't get any market data. Not sure if it is SDK or Alpaca issue. Here is an error message:

onNewData() time: 2021-11-12T11:59:25.869198-05:00[America/New_York]
Invalid message: TRADE: net.jacobpeterson.alpaca.model.endpoint.marketdata.realtime.trade.TradeMessage@2e157b16[messageType=t,symbol=PATH,tradeID=1431065906,exchange=D,price=52.8584,size=10,timestamp=2021-11-12T16:59:25.869Z,conditions=[ , I],tape=A]
java.util.NoSuchElementException: List is empty.
onNewData() time: 2021-11-12T11:59:25.905803-05:00[America/New_York]
Invalid message: TRADE: net.jacobpeterson.alpaca.model.endpoint.marketdata.realtime.trade.TradeMessage@6711d90b[messageType=t,symbol=MGM,tradeID=1431065925,exchange=D,price=45.1,size=70,timestamp=2021-11-12T16:59:25.906Z,conditions=[ , I],tape=A]
java.util.NoSuchElementException: List is empty.
onNewData() time: 2021-11-12T11:59:25.914661-05:00[America/New_York]
Invalid message: QUOTE: net.jacobpeterson.alpaca.model.endpoint.marketdata.realtime.quote.QuoteMessage@5a29ca88[messageType=q,symbol=CRWD,askExchangeCode=P,askPrice=282.5,askSize=1,bidExchangeCode=V,bidPrice=282.32,bidSize=1,timestamp=2021-11-12T16:59:25.916472832Z,conditions=[R],tape=C]
java.util.NoSuchElementException: List is empty.
onNewData() time: 2021-11-12T11:59:25.935371-05:00[America/New_York]
Invalid message: TRADE: net.jacobpeterson.alpaca.model.endpoint.marketdata.realtime.trade.TradeMessage@428aacd0[messageType=t,symbol=SQ,tradeID=1431065928,exchange=D,price=226.685,size=1,timestamp=2021-11-12T16:59:25.786Z,conditions=[ , I],tape=A]
java.util.NoSuchElementException: List is empty.
onNewData() time: 2021-11-12T11:59:26.000035-05:00[America/New_York]
Invalid message: QUOTE: net.jacobpeterson.alpaca.model.endpoint.marketdata.realtime.quote.QuoteMessage@4742b25c[messageType=q,symbol=CRWD,askExchangeCode=Q,askPrice=282.51,askSize=2,bidExchangeCode=V,bidPrice=282.32,bidSize=1,timestamp=2021-11-12T16:59:26.001642496Z,conditions=[R],tape=C]
java.util.NoSuchElementException: List is empty.
onNewData() time: 2021-11-12T11:59:26.004746-05:00[America/New_York]
Invalid message: QUOTE: net.jacobpeterson.alpaca.model.endpoint.marketdata.realtime.quote.QuoteMessage@2e72f23e[messageType=q,symbol=DDOG,askExchangeCode=M,askPrice=191.12,askSize=1,bidExchangeCode=M,bidPrice=190.91,bidSize=1,timestamp=2021-11-12T16:59:26.005673278Z,conditions=[R],tape=C]
java.util.NoSuchElementException: List is empty.
onNewData() time: 2021-11-12T11:59:26.008899-05:00[America/New_York]
Invalid message: TRADE: net.jacobpeterson.alpaca.model.endpoint.marketdata.realtime.trade.TradeMessage@3a9b00f2[messageType=t,symbol=TTD,tradeID=8112,exchange=K,price=98.65,size=9,timestamp=2021-11-12T16:59:26.010408Z,conditions=[@, F, I],tape=C]
java.util.NoSuchElementException: List is empty.
onNewData() time: 2021-11-12T11:59:26.009152-05:00[America/New_York]
Invalid message: QUOTE: net.jacobpeterson.alpaca.model.endpoint.marketdata.realtime.quote.QuoteMessage@2de0d75d[messageType=q,symbol=TTD,askExchangeCode=Q,askPrice=98.7,askSize=5,bidExchangeCode=Q,bidPrice=98.62,bidSize=4,timestamp=2021-11-12T16:59:26.010832051Z,conditions=[R],tape=C]
java.util.NoSuchElementException: List is empty.

Any help is appreciated Thanks. Alex

uchitel commented 3 years ago

I think I found it. Sorry.

Petersoj commented 3 years ago

Hey no worries. I can't see the full stacktrace, so was the exception being thrown by this library or in your application?

uchitel commented 3 years ago

In my app, I missed it somehow. Thanks for lighting fast response:)