1

I have setup streams for transactions, payments, operations, and effects with the method from stellar api guide:

this.server = new StellarSdk.Server('https://horizon.stellar.org');

this.stream = this.server.transactions()
.cursor('now')
.stream({
  onmessage: function (message) {
    console.log(message);
  }
});

I noticed that a lot of the operations stream show manage offers detailing trades that are happening. I'm looking to get a stream of complete trades occurring on the network.

Using this.stream = this.server.trades().stream gives me this error:

Using Firefox can’t establish a connection to the server at https://horizon.stellar.org/trades.

According to the Stellar Laboratory, this should work unless the stream functionality for trades isn't implemented yet.

  • 1
    You forgot to add the error details. horizon.stellar.org/trades endpoint works for me. Maybe it's a rate-limiting issue. – Orbit Lens Apr 17 '18 at 6:36
  • Thats the only error details it provides. Testing horizon.stellar.org/trades in browser and using the stellar laboratory to setup trade queries works for normal request to get past trades. However, the method the sdk uses to setup a stream does not work on the trades endpoint, at least not in the same way. stellar.github.io/js-stellar-sdk/Server.html#trades details this normal query behavior. Looks like this theory is correct as payments, operations, and transactions have stream methods on their builders, but not the trades builder. – Alex F Apr 17 '18 at 23:59
1

The following code works with JS StellarSDK 0.8.0:

this.server.trades().cursor('now').stream({
    onmessage: function (message) {
        console.log(message)
    }
})

It does not throw errors (as TradesCallBuilder is inherited from CallBuilder that features .stream() method), but it never receives any messages either.

I assume that you are right, and streaming mode is not implemented in /trades Horizon endpoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.