Example #1
0
 public bool Equals(Order token)
 {
     return this == token;
 }
Example #2
0
        public List<OrderResult> PlaceOrder(Order order, int timeout = TimeoutDefault)
        {
            Uri uri = new Uri(root, "/v2/orders");
            string postData = JsonConvert.SerializeObject(order, new OrderConverter());

            string response = TryPost(uri, postData, timeout);
            JsonSerializerSettings settings = new JsonSerializerSettings {NullValueHandling = NullValueHandling.Ignore};
            return JsonConvert.DeserializeObject<List<OrderResult>>(response, settings);
        }
Example #3
0
        public OrderResult UpdateOrder(Order order, int timeout = TimeoutDefault)
        {
            if (order == null) throw new ArgumentNullException("order", "null Order passed to UpdateOrder.");

            Uri uri = new Uri(root, string.Format("/v2/orders/{0}", order.OrderId));
            string postData = JsonConvert.SerializeObject(order, new OrderConverter());
            WebHeaderCollection headers = new WebHeaderCollection {{"Authorization", Token.Token}};

            string response = HttpClient.HttpPut(uri, postData, timeout, headers);
            return JsonConvert.DeserializeObject<OrderResult>(response);
        }
Example #4
0
        public List<OrderConfirmation> ConfirmOrder(Order order, int timeout = TimeoutDefault)
        {
            if (order == null) throw new ArgumentException("NULL Order passed to OrderConfirm", "order");

            Uri uri = new Uri(root, "/v2/orders/confirm");
            List<OrderConfirmation> confirmationList = new List<OrderConfirmation>(1);

            string postData = JsonConvert.SerializeObject(order, new OrderConverter());
            string response = TryPost(uri, postData, timeout);

            switch (order.AssetType)
            {
                case AssetType.FU:
                    List<FuturesOrderConfirmation> futuresConfirmationList = JsonConvert.DeserializeObject<List<FuturesOrderConfirmation>>(response);
                    if (futuresConfirmationList != null) confirmationList.AddRange(futuresConfirmationList);
                    break;
                case AssetType.FX:
                    List<ForexOrderConfirmation> forexConfirmationList = JsonConvert.DeserializeObject<List<ForexOrderConfirmation>>(response);
                    if (forexConfirmationList != null) confirmationList.AddRange(forexConfirmationList);
                    break;
                default:
                    List<EquityOrderConfirmation> equityConfirmationList = JsonConvert.DeserializeObject<List<EquityOrderConfirmation>>(response);
                    if (equityConfirmationList != null) confirmationList.AddRange(equityConfirmationList);
                    break;
            }

            return confirmationList;
        }