private void btnSendMultiple_Click(object sender, EventArgs e)
      {
         var price = decimal.Parse(txtPrice.Text);
         var amount = decimal.Parse(txtSize.Text);
         var side = cbBuySell.Text;

         var orderList = new List<BitfinexNewOrderPost>();
         var order1 = new BitfinexNewOrderPost();
         order1.Amount = amount.ToString();
         order1.Exchange = "bitfinex";
         order1.Price = price.ToString();
         order1.Side = side;
         order1.Symbol = _frm.cbPair.SelectedItem.ToString().ToLower();
         order1.Type = "exchange limit";

         orderList.Add(order1);
         
         order1 = new BitfinexNewOrderPost();
         order1.Amount = amount.ToString();
         order1.Exchange = "bitfinex";
         if (side == "buy")
            order1.Price = decimal.Subtract(price, .50m).ToString();
         else
         {
            order1.Price = decimal.Add(price, .50m).ToString();
         }
         order1.Side = side;
         order1.Symbol = _frm.cbPair.SelectedItem.ToString().ToLower();
         order1.Type = "exchange limit";

         orderList.Add(order1);

         var x = Exchange.Api.SendMultipleOrders(orderList.ToArray());
      }
 public BitfinexCancelReplaceOrderResponse CancelReplaceOrder(int cancelOrderId, BitfinexNewOrderPost newOrder)
 {
     var replaceOrder = new BitfinexCancelReplacePost()
     {
         Amount = newOrder.Amount,
         CancelOrderId = cancelOrderId,
         Exchange = newOrder.Exchange,
         Price = newOrder.Price,
         Side = newOrder.Side,
         Symbol = newOrder.Symbol,
         Type = newOrder.Type
     };
     return CancelReplaceOrder(replaceOrder);
 }
 public BitfinexNewOrderResponse SendOrder(string symbol, string amount, string price, string exchange, string side, string type, bool isHidden)
 {
     var newOrder = new BitfinexNewOrderPost()
     {
         Symbol = symbol,
         Amount = amount,
         Price = price,
         Exchange = exchange,
         Side = side,
         Type = type//,
         //IsHidden = isHidden.ToString()
     };
     return SendOrder(newOrder);
 }
        public BitfinexNewOrderResponse SendOrder(BitfinexNewOrderPost newOrder)
        {
            IRestResponse response = null;
            try
            {
                newOrder.Request = NewOrderRequestUrl;
                newOrder.Nonce = Common.UnixTimeStampUtc().ToString();

                var client = GetRestClient(NewOrderRequestUrl);
                response = GetRestResponse(client, newOrder);
                Logger.Log.InfoFormat("New Order Response: {0}", response.Content);

                var newOrderResponseObj = JsonConvert.DeserializeObject<BitfinexNewOrderResponse>(response.Content);
                //(newOrderResponseObj);

                Logger.Log.InfoFormat("Sending New Order: {0}", newOrder.ToString());
                Logger.Log.InfoFormat("Response from Exchange: {0}", newOrderResponseObj);

                return newOrderResponseObj;
            }
            catch (Exception ex)
            {
                var outer = new Exception(response.Content, ex);
                Logger.LogException(outer);
                return null;
            }
        }
        public BitfinexMultipleNewOrderResponse SendMultipleOrders(BitfinexNewOrderPost[] orders)
        {
            try
            {
                var multipleOrdersPost = new BitfinexMultipleNewOrdersPost();
                multipleOrdersPost.Request = NewOrderRequestUrl + MultipleRequestUrl;
                multipleOrdersPost.Nonce = Common.UnixTimeStampUtc().ToString();
                multipleOrdersPost.Orders = orders;

                var client = GetRestClient(multipleOrdersPost.Request);
                var response = GetRestResponse(client, multipleOrdersPost);

                var multipleOrderResponseObj = JsonConvert.DeserializeObject<BitfinexMultipleNewOrderResponse>(response.Content);
                MultipleOrderFeedMsg(multipleOrderResponseObj);

                Logger.Log.Info("Sending Multiple Orders:");
                foreach (var order in orders)
                    Logger.Log.Info(order.ToString());

                return multipleOrderResponseObj;

            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return null;
            }
        }
      private void btnCancelReplace_Click(object sender, EventArgs e)
      {
         var price = decimal.Parse(txtPrice.Text);
         var amount = decimal.Parse(txtSize.Text);
         var side = cbBuySell.Text;

         var order = new BitfinexNewOrderPost();
         order.Side = side;
         if (side == "buy")
         {
            order.Price = decimal.Subtract(price, .05m).ToString();
            order.Amount = decimal.Subtract(amount, .20m).ToString();
         }
         else
         {
            order.Price = decimal.Add(price, .05m).ToString();
            order.Amount = decimal.Subtract(amount, .20m).ToString();
         }
         order.Exchange = "bitfinex";
         order.Symbol = "ltcusd";
         order.Type = "exchange limit";

         Exchange.Api.CancelReplaceOrder(Convert.ToInt32(txtCancelReplaceId.Text), order);
      }