internal static TimeInForce GetTiff(TimeInForceEnum oandaTiff)
        {
            switch (oandaTiff)
            {
            case TimeInForceEnum.FOK:
                return(TimeInForce.FOC);

            case TimeInForceEnum.GTD:
                return(TimeInForce.GTD);

            case TimeInForceEnum.GFD:
                return(TimeInForce.Day);

            case TimeInForceEnum.IOC:
                return(TimeInForce.IOC);

            case TimeInForceEnum.GTC:
            default:
                return(TimeInForce.GTC);
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Order" /> class.
 /// </summary>
 /// <param name="id">id (required).</param>
 /// <param name="clientOrderId">clientOrderId (required).</param>
 /// <param name="symbol">symbol (required).</param>
 /// <param name="side">side (required).</param>
 /// <param name="status">status (required).</param>
 /// <param name="type">type (required).</param>
 /// <param name="timeInForce">timeInForce (required).</param>
 /// <param name="quantity">quantity.</param>
 /// <param name="price">price.</param>
 /// <param name="cumQuantity">cumQuantity.</param>
 /// <param name="createdAt">createdAt.</param>
 /// <param name="updatedAt">updatedAt.</param>
 /// <param name="stopPrice">stopPrice.</param>
 /// <param name="expireTime">expireTime.</param>
 /// <param name="tradesReport">tradesReport.</param>
 public Order(long?id = default(long?), string clientOrderId = default(string), string symbol = default(string), SideEnum side = default(SideEnum), StatusEnum status = default(StatusEnum), TypeEnum type = default(TypeEnum), TimeInForceEnum timeInForce = default(TimeInForceEnum), string quantity = default(string), string price = default(string), string cumQuantity = default(string), DateTime?createdAt = default(DateTime?), DateTime?updatedAt = default(DateTime?), string stopPrice = default(string), DateTime?expireTime = default(DateTime?), List <OrderTradesReport> tradesReport = default(List <OrderTradesReport>))
 {
     // to ensure "id" is required (not null)
     if (id == null)
     {
         throw new InvalidDataException("id is a required property for Order and cannot be null");
     }
     else
     {
         this.Id = id;
     }
     // to ensure "clientOrderId" is required (not null)
     if (clientOrderId == null)
     {
         throw new InvalidDataException("clientOrderId is a required property for Order and cannot be null");
     }
     else
     {
         this.ClientOrderId = clientOrderId;
     }
     // to ensure "symbol" is required (not null)
     if (symbol == null)
     {
         throw new InvalidDataException("symbol is a required property for Order and cannot be null");
     }
     else
     {
         this.Symbol = symbol;
     }
     // to ensure "side" is required (not null)
     if (side == null)
     {
         throw new InvalidDataException("side is a required property for Order and cannot be null");
     }
     else
     {
         this.Side = side;
     }
     // to ensure "status" is required (not null)
     if (status == null)
     {
         throw new InvalidDataException("status is a required property for Order and cannot be null");
     }
     else
     {
         this.Status = status;
     }
     // to ensure "type" is required (not null)
     if (type == null)
     {
         throw new InvalidDataException("type is a required property for Order and cannot be null");
     }
     else
     {
         this.Type = type;
     }
     // to ensure "timeInForce" is required (not null)
     if (timeInForce == null)
     {
         throw new InvalidDataException("timeInForce is a required property for Order and cannot be null");
     }
     else
     {
         this.TimeInForce = timeInForce;
     }
     this.Quantity     = quantity;
     this.Price        = price;
     this.CumQuantity  = cumQuantity;
     this.CreatedAt    = createdAt;
     this.UpdatedAt    = updatedAt;
     this.StopPrice    = stopPrice;
     this.ExpireTime   = expireTime;
     this.TradesReport = tradesReport;
 }
Пример #3
0
        /// <summary>Makes the HTTP request (Sync).</summary>
        /// <param name="side">Order side</param>
        /// <param name="symbol">Currency symbol for order</param>
        /// <param name="orderType">Order type</param>
        /// <param name="timeInForce">Time in force for order</param>
        /// <param name="qty">Order quantity of perpetual contracts to buy or sell</param>
        /// <param name="price">Order price of perpetual contracts to buy or sell.</param>
        /// <param name="takeProfit">Order take profit (TP) price</param>
        /// <param name="stopLoss">Order stop loss (SL) price </param>
        /// <param name="reduceOnly">Reduce only</param>
        /// <param name="closeOnTrigger">Closing trigger.  When creating a closing order, it is highly recommended to set as true to avoid failing by insufficient available margin.</param>
        /// <param name="orderLinkId">Custom order identifier.</param>
        /// <param name="trailingStop">Order trailing stop (TS) units.</param>
        /// <remarks>As of 20190117 ByBit only support order quantity in an integer.</remarks>
        /// <returns><see cref="OrderResBase"/> object.</returns>
        public OrderResBase CallApi(SideEnum side, SymbolEnum symbol, OrderTypeEnum orderType, TimeInForceEnum timeInForce, decimal qty, double price, double?takeProfit = null, double?stopLoss = null, bool?reduceOnly = null, bool?closeOnTrigger = null, string orderLinkId = null, string trailingStop = null)
        {
            formParams.Add("side", Configuration.ApiClient.ParameterToString(side));                    // form parameter
            formParams.Add("symbol", Configuration.ApiClient.ParameterToString(symbol));                // form parameter
            formParams.Add("order_type", Configuration.ApiClient.ParameterToString(orderType));         // form parameter
            formParams.Add("time_in_force", Configuration.ApiClient.ParameterToString(timeInForce));    // form parameter
            formParams.Add("qty", Configuration.ApiClient.ParameterToString(qty));                      // form parameter
            queryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "price", price)); // query parameter
            if (takeProfit != null)
            {
                queryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "take_profit", takeProfit)); // query parameter
            }

            if (stopLoss != null)
            {
                formParams.Add("stop_loss", Configuration.ApiClient.ParameterToString(stopLoss)); // form parameter
            }

            if (reduceOnly != null)
            {
                formParams.Add("reduce_only", Configuration.ApiClient.ParameterToString(reduceOnly)); // form parameter
            }

            if (closeOnTrigger != null)
            {
                formParams.Add("close_on_trigger", Configuration.ApiClient.ParameterToString(closeOnTrigger)); // form parameter
            }

            if (orderLinkId != null)
            {
                formParams.Add("order_link_id", Configuration.ApiClient.ParameterToString(orderLinkId)); // form parameter
            }

            if (trailingStop != null)
            {
                formParams.Add("trailing_stop", Configuration.ApiClient.ParameterToString(trailingStop)); // form parameter
            }

            IRestResponse localVarResponse = CallApi(path, Method.POST, queryParams, formParams, headerParams);

            return(ProcessRestResponce(localVarResponse).Data);
        }