コード例 #1
0
        public static async Task <bool> DoneOrderAsync(int orderNo, TypeOrder typeOrder)
        {
            using var client = new HttpClient();
            var result = await client.GetAsync(URL + typeOrder.ToString() + "?orderNo=" + orderNo);

            return(result.ToString() == "ok");
        }
コード例 #2
0
        /// <summary>
        /// Method for managing orders coming in from the other terminals
        /// over web API throws an exception if the ordernumber is incorrect for the call
        /// that the client can use to know that it was an incorrect call
        /// </summary>
        /// <param name="orderNo">The order's Number</param>
        /// <param name="typeOrder">Type of order command: PlaceOrder, DoneOrder, RemoveOrder</param>
        private void ManageOrders(int orderNo, TypeOrder typeOrder)
        {
            Trace.WriteLine(typeOrder.ToString() + " ");
            switch (typeOrder)
            {
            // handle a new order. throws an exception if there is already an order with same number
            case TypeOrder.placeorder:
                if (Orders.Any(x => x.ID == orderNo) != true)
                {
                    Orders.Add(new Order {
                        ID = orderNo, CustomerID = 99, Orderstatus = 0, Price = 99, TimeCreated = GetRandomTime()
                    });
                }
                else
                {
                    throw new Exception();
                }
                break;

            // handle an order that is ready to get picked up. throws an exception if there isnt any order with that ordernumber
            case TypeOrder.doneorder:
                var tempOrder = Orders.Single(x => x.ID == orderNo);
                if (Orders.Contains(tempOrder) == true)
                {
                    Orders.Remove(tempOrder);
                    tempOrder.Orderstatus = 1;
                    OrdersDone.Add(tempOrder);
                }
                break;

            // handle removing an order. throws an exception if there isnt any order with that ordernumber
            case TypeOrder.removeorder:
                tempOrder = OrdersDone.Single(x => x.ID == orderNo);
                if (OrdersDone.Contains(tempOrder) == true)
                {
                    OrdersDone.Remove(tempOrder);
                }
                break;

            default:
                throw new Exception();
                break;
            }
        }
コード例 #3
0
        public override string Trade(TypeOrder type, string pair, double rate, double amount, int nonce)
        {
            string parameters = $"method=Trade&pair=" + pair +
                                "&type=" + type.ToString() + "&rate=" + rate.ToString("F8", CultureInfo.InvariantCulture) + "&amount=" +
                                amount.ToString("F8", CultureInfo.InvariantCulture) +
                                "&nonce=" + nonce;

            string resp = Response(parameters);

            if (resp.Contains("error"))
            {
                return(DateTime.Now.ToString("dd/MM/yy HH:mm:ss.ffff") + " " + resp + "\n");
            }
            resp = resp.Replace("return", "returnInfo");
            YobitTradeInfo info = JsonConvert.DeserializeObject <YobitTradeInfo>(resp);

            curBalance = info.returnInfo.funds_incl_orders;

            return(DateTime.Now.ToString("dd/MM/yy HH:mm:ss.ffff") + " Order Type: " + type.ToString() + " Order ID: " + info.returnInfo.order_id
                   + " Price: " + rate.ToString("F8", CultureInfo.InvariantCulture) + " Received: " + info.returnInfo.received + " Remains: " + info.returnInfo.remains + "\n");
        }  //private
コード例 #4
0
        public override string Trade(TypeOrder type, string pair, double rate, double amount, int nonce)
        {
            string resp = Response("SubmitTrade", new postObj()
            {
                Market = pair,
                Type   = type.ToString(),
                Rate   = rate.ToString("F8", CultureInfo.InvariantCulture),
                Amount = amount.ToString("F8", CultureInfo.InvariantCulture)
            }, nonce);

            if (resp.Contains("false"))
            {
                return(DateTime.Now.ToString("dd/MM/yy HH:mm:ss.ffff") + " " + resp + "\n");
            }
            CryptopiaTradeInfo info = JsonConvert.DeserializeObject <CryptopiaTradeInfo>(resp);

            //curBalance = info.returnInfo.funds_incl_orders;

            return(DateTime.Now.ToString("dd/MM/yy HH:mm:ss.ffff") + " Order Type: " + type.ToString() + " Order ID: " + info.Data.OrderId
                   + " Price: " + rate.ToString("F8", CultureInfo.InvariantCulture) + "\n");
        } //private
コード例 #5
0
ファイル: SortOrderHelper.cs プロジェクト: LeoFelipe/Agenda
 public SortOrderHelper(string fieldName, TypeOrder typeOrderBy)
 {
     FieldTypeOrderBy = typeOrderBy.ToString();
     FieldName        = fieldName;
 }