Exemplo n.º 1
0
        public void Get_Url_Without_Query_And_Add_Params_With_Utf8()
        {
            Uri newUri = uriUtf8.AddQueryParam("test3", "3");

            Assert.AreEqual("http://www.opten.ch/", newUri.GetUrl(withQuery: false, withDomain: true));
            Assert.AreEqual("/", newUri.GetUrl(withQuery: false, withDomain: false));
        }
Exemplo n.º 2
0
        public void Get_Url_Without_Query_And_Add_Params_With_Utf8()
        {
            Uri newUri         = uriAbsoluteUtf8.AddQueryParam("test3", "3");
            Uri newUriRelative = uriRelativeUtf8.AddQueryParam("test3", "3");

            Assert.AreEqual("http://www.opten.ch/", newUri.GetUrl(withQuery: false, withDomain: true, withFragment: false));
            Assert.AreEqual("/", newUri.GetUrl(withQuery: false, withDomain: false, withFragment: false));
            Assert.AreEqual("/", newUriRelative.GetUrl(withQuery: false, withDomain: true, withFragment: false));
            Assert.AreEqual("/", newUriRelative.GetUrl(withQuery: false, withDomain: false, withFragment: false));
            Assert.AreEqual("http://www.opten.ch/#fragment", newUri.GetUrl(withQuery: false, withDomain: true, withFragment: true));
            Assert.AreEqual("/#fragment", newUri.GetUrl(withQuery: false, withDomain: false, withFragment: true));
            Assert.AreEqual("/#fragment", newUriRelative.GetUrl(withQuery: false, withDomain: true, withFragment: true));
            Assert.AreEqual("/#fragment", newUriRelative.GetUrl(withQuery: false, withDomain: false, withFragment: true));
        }
Exemplo n.º 3
0
        public static Task Launch(string displayName, Uri uri, string filter = null)
        {
            if (Holder.Active)
            {
                return(Task.Delay(0));
            }

            Holder.Active = true;
            var dialog = new ModernDialog {
                Title              = displayName,
                SizeToContent      = SizeToContent.Manual,
                ResizeMode         = ResizeMode.CanResizeWithGrip,
                LocationAndSizeKey = uri.ToString().Split('?')[0],
                MinWidth           = 800,
                MinHeight          = 480,
                Width              = 800,
                Height             = 640,
                MaxWidth           = 99999,
                MaxHeight          = 99999,
                Content            = new ModernFrame {
                    Source = string.IsNullOrWhiteSpace(filter) ? uri : uri.AddQueryParam("Filter", filter)
                }
            };

            dialog.Closed += OnDialogClosed;
            return(dialog.ShowAndWaitAsync());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Send an order to the specific account.
        /// </summary>
        /// <param name="account">Account to send the order to.</param>
        /// <param name="order">Order to send.</param>
        /// <returns>Order identifier.</returns>
        public async Task <OrderId> SubmitOrder(string account, Order order)
        {
            var uri = new Uri(BaseUri, "/rest/order/newSingleOrder").ToString();

            uri = uri.AddQueryParam("marketId", "ROFX")
                  .AddQueryParam("symbol", order.Instrument.Symbol)
                  .AddQueryParam("price", order.Price)
                  .AddQueryParam("orderQty", order.Quantity)
                  .AddQueryParam("ordType", order.Type.ToApiString())
                  .AddQueryParam("side", order.Side.ToApiString())
                  .AddQueryParam("timeInForce", order.Expiration.ToApiString())
                  .AddQueryParam("account", account)
                  .AddQueryParam("cancelPrevious", order.CancelPrevious)
                  .AddQueryParam("iceberg", order.Iceberg)
                  .AddQueryParam("expireDate", order.ExpirationDate.ToString("yyyyMMdd"));

            if (order.Iceberg)
            {
                uri = uri.AddQueryParam("displayQty", order.DisplayQuantity);
            }

            var jsonResponse = await uri.GetJsonFromUrlAsync(
                request =>
            {
                request.Headers.Add("X-Auth-Token", AccessToken);
            }
                );

            var response = JsonConvert.DeserializeObject <OrderIdResponse>(jsonResponse);

            if (response.Status == Status.Error)
            {
                throw new Exception($"{response.Message} ({response.Description})");
            }

            return(new OrderId()
            {
                ClientOrderId = response.Order.ClientId,
                Proprietary = response.Order.Proprietary
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Cancel an order.
        /// </summary>
        /// <param name="orderId">Order identifier to cancel.</param>
        public async Task CancelOrder(OrderId orderId)
        {
            var uri = new Uri(BaseUri, "/rest/order/cancelById").ToString();

            uri = uri.AddQueryParam("clOrdId", orderId.ClientOrderId)
                  .AddQueryParam("proprietary", orderId.Proprietary);

            var jsonResponse = await uri.GetJsonFromUrlAsync(
                request =>
            {
                request.Headers.Add("X-Auth-Token", AccessToken);
            }
                );

            var response = JsonConvert.DeserializeObject <OrderIdResponse>(jsonResponse);
            //if (response.Status == Status.Error)
            //{
            //    throw new Exception($"{response.Message} ({response.Description})");
            //}
        }
Exemplo n.º 6
0
 internal LinkInputEmpty(Uri uri)
 {
     Source = uri.AddQueryParam("Special", "Input");
 }
Exemplo n.º 7
0
 public static Uri AddQueryParam(this Uri uri, Interval interval)
 {
     return(interval != Interval.Default ? uri.AddQueryParam("group_by", interval.AsString()) : uri);
 }
Exemplo n.º 8
0
 public static Uri AddQueryParam(this Uri uri, string name, int value)
 {
     return(uri.AddQueryParam(name, value.ToString()));
 }
Exemplo n.º 9
0
 public static Uri AddQueryParam(this Uri uri, string name, bool?value)
 {
     return(value == null ? uri : uri.AddQueryParam(name, value.Value ? "true" : "false"));
 }
Exemplo n.º 10
0
 public static Uri AddQueryParam(this Uri uri, string name, DateTimeOffset?value)
 {
     return(value == null ? uri : uri.AddQueryParam(name, value.Value.ToIso8601()));
 }