Does OKEX futures use websocket market patterns and Go asynchronous functions to switch contract types?

Author: lightring, Created: 2019-09-14 18:06:24, Updated:

Let's say you want to make a spread on BTC in an OKEX futures, contract type is this_week and quarter, and you want to use the websocket market model. Now you can only add one exchange object to exchange, and you must call SetContractType once before each GetTicker, exchange.Go call.

The example code and questions for the websocket are as follows:

exchange.IO("websocket"); exchange.SetContractType(“this_week”); var tickerA = exchange.GetTicker(); exchange.SetContractType(“quarter”); var tickerB = exchange.GetTicker();

Question: Is the websocket reconnected every time exchange.SetContractType (()) is called?

Go function example code and problems are as follows:

exchange.SetContractType(“this_week”); var orderA = exchange.Go(“Sell”,tickerA.Last, 1); exchange.SetContractType(“quarter”); var orderB = exchange.Go(“Buy”,tickerB.Last, 1);

Question: Is it possible, because of the asynchrony, that the actual contract type used when order A is executed is quarter?

Other questions:

  1. If the above problem really exists, is there a way to avoid it?
  2. Can the same transaction pair on the same exchange create two exchange objects without affecting each other? For example, two exchange objects have their own websocket connections and do not affect each other.

More

The Little DreamOKEX futures do not support such a mode of switching. You can create a websocket connection directly using the Dial function.