Exemple #1
0
        IEnumerable <RequestValidationException> Validation.IRequest.GetExceptions()
        {
            if (ClientOrderId?.Length > 48)
            {
                ClientOrderId = ClientOrderId.Substring(0, 48);
            }

            // TODO: olegra - add more validations here

            yield break;
        }
Exemple #2
0
        IEnumerable <RequestValidationException> Validation.IRequest.GetExceptions()
        {
            ClientOrderId = ClientOrderId?.ValidateClientOrderId();

            if (String.IsNullOrEmpty(Symbol))
            {
                yield return(new RequestValidationException(
                                 "Symbols shouldn't be empty.", nameof(Symbol)));
            }

            if (Quantity <= 0)
            {
                yield return(new RequestValidationException(
                                 "Order quantity should be positive value.", nameof(Quantity)));
            }
        }
        public static Task <JObject> SendOrder(
            this RestClient client,
            ClientOrderId clientOrderId,
            Instrument instrument,
            Side side,
            ExchangeOrderType orderType,
            decimal?price,
            decimal size,
            bool postOnly = true
            )
        {
            // TODO: Add Time-in-Force

            var     jobj = new JObject();
            dynamic o    = jobj;

            o.client_oid = clientOrderId.Id;
            o.product_id = instrument.Symbol;
            o.type       = orderType.ToString().ToLowerInvariant();
            o.side       = side.ToString().ToLowerInvariant();


            o.size = size;

            switch (orderType)
            {
            case ExchangeOrderType.Limit:
                o.stp       = "cn"; // Self trading prevention -> cancel newest
                o.post_only = postOnly;
                goto case ExchangeOrderType.Stop;

            case ExchangeOrderType.Stop:
                o.price = price;
                break;

            case ExchangeOrderType.Market:
                break;
            }

            return(DoPost(client, jobj));
        }
Exemple #4
0
        void StateNotInMarket()
        {
            ReceiveAsync <ChangeRequest>(async change =>
            {
                _clientOrderId = new ClientOrderId();
                _originalSize  = change.Size;

                var nos = new NewOrderSingle
                {
                    ClientOrderId   = _clientOrderId,
                    Instrument      = Instrument,
                    Side            = Side,
                    OrderType       = OrderType,
                    Price           = change.Price,
                    Size            = change.Size,
                    IsMakerOrCancel = false
                };

                await _orderManager.NewExchangeOrder(nos);
                Become(StatePendingNew);
            });
        }
        // TODO: Time in force
        // TODO: Implement ManagementMode (Cancel/Leave on disconnect)

        public NewOrderSingle()
        {
            ClientOrderId   = new ClientOrderId();
            OrderType       = ExchangeOrderType.Limit;
            IsMakerOrCancel = true;
        }