Exemplo n.º 1
0
 public virtual ErrorType SendLimitOrder(OrderRequestData order_request) => ErrorType.UnknownError;
Exemplo n.º 2
0
        public override ErrorType SendOrder(OrderRequestData order_request)
        {
            OrderResponseData orderResponseData = new OrderResponseData();

            orderResponseData.account_id       = "bybit";
            orderResponseData.symbol           = order_request.symbol;
            orderResponseData.trans_type       = order_request.signal;
            orderResponseData.request_quantity = order_request.amount;
            orderResponseData.request_price    = order_request.request_price;
            orderResponseData.is_market        = order_request.is_market;
            string symbol = order_request.symbol;
            string str    = order_request.signal == ORDER_TYPE.Buy ? "Buy" : "Sell";
            Dictionary <string, object> order_query = new Dictionary <string, object>()
            {
                {
                    "api_key",
                    (object)this.api_key_
                },
                {
                    "order_type",
                    order_request.is_market ? (object)"Market" : (object)"Limit"
                },
                {
                    "price",
                    (object)order_request.request_price.ToString()
                },
                {
                    "qty",
                    (object)order_request.amount.ToString()
                },
                {
                    "reduce_only",
                    (object)false
                },
                {
                    "side",
                    (object)str
                },
                {
                    "symbol",
                    (object)symbol
                },
                {
                    "time_in_force",
                    (object)"GoodTillCancel"
                },
                {
                    "timestamp",
                    (object)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString()
                }
            };

            if (order_request.is_market)
            {
                order_query.Remove("price");
            }
            ByBitOrderResult byBitOrderResult = this.api_client_.PlaceNewOrder(order_query);

            if (byBitOrderResult == null)
            {
                this.atb_manager_.AppendLog(this.api_client_.LastMessage);
                return(this.api_client_.LastError);
            }
            orderResponseData.accept_quantity = (double)byBitOrderResult.CumExecQuantity;
            orderResponseData.accept_price    = order_request.request_price;
            return(ErrorType.Success);
        }