toCBJson method

Map<String, dynamic> toCBJson()

Converts an OrderConfiguration to a Coinbase JSON object.

Implementation

Map<String, dynamic> toCBJson() {
  Map<String, dynamic> config = {};

  if (marketIOC != null &&
      (marketIOC?.quoteSize != null || marketIOC?.baseSize != null)) {
    config.addAll({'market_market_ioc': marketIOC?.toCBJson()});
  }
  if (limitGTC != null && (limitGTC?.baseSize != null)) {
    config.addAll({'limit_limit_gtc': limitGTC?.toCBJson()});
  }
  if (limitGTD != null && (limitGTD?.baseSize != null)) {
    config.addAll({'limit_limit_gtd': limitGTD?.toCBJson()});
  }
  if (stopLimitGTC != null && (stopLimitGTC?.baseSize != null)) {
    config.addAll({'stop_limit_stop_limit_gtc': stopLimitGTC?.toCBJson()});
  }
  if (stopLimitGTD != null && (stopLimitGTD?.baseSize != null)) {
    config.addAll({'stop_limit_stop_limit_gtd': stopLimitGTD?.toCBJson()});
  }

  return {'order_configuration': config};
}