/// <summary> /// Place a market order /// </summary> /// <param name="parms">Market Order Parameters</param> /// <returns>String of order id</returns> public static async Task <string> PlaceMarketOrder(this IKuCoinDotNet service, MarketOrderParams parms) { var body = new SortedDictionary <string, object>(); if (string.IsNullOrEmpty(parms.ClientOid)) { parms.ClientOid = Guid.NewGuid().ToString(); } if (parms.Funds > 0) { body.Add("funds", parms.Funds); } body.Add("clientOid", parms.ClientOid); body.Add("symbol", parms.Pair); if (!string.IsNullOrEmpty(parms.Remark)) { body.Add("remark", parms.Remark); } if (parms.SelfTradeProtect != null) { body.Add("stp", parms.SelfTradeProtect.ToString()); } body.Add("side", parms.Side.ToString().ToLower()); body.Add("size", parms.Size); body.Add("type", parms.Type.ToString().ToLower()); return(await service.PlaceOrder(body)); }
/// <summary> /// Place a market order /// </summary> /// <param name="pair">Trading pair</param> /// <param name="side">Side of trade</param> /// <param name="quantity">Quantity to trade</param> /// <returns>String of order id</returns> public static async Task <string> PlaceMarketOrder(this IKuCoinDotNet service, string pair, Side side, decimal quantity) { var clientOid = Guid.NewGuid().ToString().Replace("-", ""); var body = new SortedDictionary <string, object>(); body.Add("clientOid", clientOid); body.Add("symbol", pair); body.Add("side", side.ToString().ToLower()); body.Add("size", quantity); body.Add("type", OrderType.MARKET.ToString().ToLower()); return(await service.PlaceOrder(body)); }
/// <summary> /// Place a stop order /// </summary> /// <param name="parms">Stop Limit Order Parameters</param> /// <returns>String of order id</returns> public static async Task <string> PlaceStopOrder(this IKuCoinDotNet service, StopLimitOrderParams parms) { var body = new SortedDictionary <string, object>(); if (parms.CancelAfter > 0) { body.Add("cancelAfter", parms.CancelAfter); } if (string.IsNullOrEmpty(parms.ClientOid)) { parms.ClientOid = Guid.NewGuid().ToString(); } body.Add("clientOid", parms.ClientOid); body.Add("symbol", parms.Pair); if (parms.PostOnly) { body.Add("postOnly", parms.PostOnly); } body.Add("price", parms.Price); if (!string.IsNullOrEmpty(parms.Remark)) { body.Add("remark", parms.Remark); } if (parms.SelfTradeProtect != null) { body.Add("stp", parms.SelfTradeProtect.ToString()); } body.Add("side", parms.Side.ToString().ToLower()); body.Add("size", parms.Size); body.Add("stop", parms.Stop.ToString().ToLower()); body.Add("stopPrice", parms.StopPrice); if (parms.TimeInForce != null) { body.Add("timeInForce", parms.TimeInForce.ToString()); } body.Add("type", parms.Type.ToString().ToLower()); return(await service.PlaceOrder(body)); }