ByBit constructor

ByBit(
  1. {String key = '',
  2. String password = '',
  3. String restUrl = 'https://api.bybit.com',
  4. String websocketUrl = 'wss://stream.bybit.com/realtime',
  5. int timeout = -1,
  6. int pingPeriod = 30,
  7. int receiveWindow = 1000,
  8. String logLevel = 'WARNING'}
)

The constructor use default parameters without api-key. If you want to use all endpoints, you must provite a valid key and password. Go to https://www.bybit.com/app/user/api-management To generate your key. If you're using the websockets, a ping will be sent every pingPeriod seconds to the server to maintain connection. If no message is received from the Server within timeout seconds, an exception will be thrown. The receiveWindow must be given in milliseconds and prevents replay attacks. See https://bybit-exchange.github.io/docs/inverse/?console#t-authentication

Implementation

ByBit(
    {this.key = '',
    this.password = '',
    this.restUrl = 'https://api.bybit.com',
    this.websocketUrl = 'wss://stream.bybit.com/realtime',
    int timeout = -1,
    this.pingPeriod = 30,
    this.receiveWindow = 1000,
    String logLevel = 'WARNING'}) {
  if (logLevel == 'ERROR') {
    Logger.level = Level.error;
  } else if (logLevel == 'WARNING') {
    Logger.level = Level.warning;
  } else if (logLevel == 'INFO') {
    Logger.level = Level.info;
  } else if (logLevel == 'DEBUG') {
    Logger.level = Level.debug;
  } else {
    Logger.level = Level.nothing;
  }
  if (timeout > 0) {
    this.timeout = Duration(seconds: timeout);
  } else {
    this.timeout = Duration(days: 999999);
  }
  log = LoggerSingleton();
  websocket = ByBitWebSocket(
      key: key,
      password: password,
      timeout: this.timeout,
      url: websocketUrl,
      pingPeriod: pingPeriod);
  rest = ByBitRest(
      key: key,
      password: password,
      url: restUrl,
      timeout: this.timeout,
      receiveWindow: receiveWindow);
}