createNewOrder method

Future<Order> createNewOrder({
  1. String? profileId,
  2. String? type,
  3. required String? side,
  4. required String? productId,
  5. String? stp,
  6. String? stop,
  7. double? stopPrice,
  8. double? price,
  9. double? size,
  10. double? funds,
  11. String? timeInForce,
  12. String? cancelAfter,
  13. bool? postOnly,
  14. String? clientOid,
})

Create a new order

Create an order. You can place two types of orders: limit and market. Orders can only be placed if your account has sufficient funds. Once an order is placed, your account funds will be put on hold for the duration of the order. How much and which funds are put on hold depends on the order type and parameters specified.

https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postorders

Implementation

Future<Order> createNewOrder({
  String? profileId,
  //TODO make enum
  String? type,
  //TODO make enum
  required String? side,
  required String? productId,
  //TODO make enum
  String? stp,
  //TODO make enum
  String? stop,
  double? stopPrice,
  double? price,
  double? size,
  double? funds,
  //TODO make enum
  String? timeInForce,
  //TODO make enum
  String? cancelAfter,
  bool? postOnly,
  String? clientOid,
}) async {
  var response = await _ordersRestClient.createNewOrder(
    profileId: profileId,
    type: type,
    side: side,
    productId: productId,
    stp: stp,
    stop: stop,
    stopPrice: stopPrice,
    price: price,
    size: size,
    funds: funds,
    timeInForce: timeInForce,
    cancelAfter: cancelAfter,
    postOnly: postOnly,
    clientOid: clientOid,
  );

  if (response.statusCode != 200) throw response;

  return Order.fromJson(json.decode(response.body));
}