Beispiel #1
0
        /// <summary>
        /// Place un ordre
        /// </summary>
        /// <returns>L'objet de l'ordre</returns>
        /// <param name="symbol">Symbole de la monnaie tradé, eg BCCETH</param>
        /// <param name="side">Sens de l'ordre , acheter ou vendre</param>
        /// <param name="type">Type de commande, voir Set.OrderTypes </param>
        /// <param name="timeInForce">La durée de la commande sera active pour</param>
        /// <param name="quantity">Montant à trader</param>
        /// <param name="price">Prix auquel acheter</param>

        public static Order PlaceOrder(string symbol, OrderSides side, OrderTypes type, TimesInForce timeInForce, double quantity, double price)
        {
            string apiRequestUrl = "";

            if (General.testCase == true)
            {
                apiRequestUrl = $"{Url}v3/order/test";
            }
            else
            {
                apiRequestUrl = $"{Url}v3/order";
            }


            string query = $"symbol={symbol}&side={side}&type={type}&timeInForce={timeInForce}&quantity={quantity}&price={price}";

            query = $"{query}&timestamp={Server.getTimeStamp()}";

            var signature = Server.getSignature(General.SecretKey, query);

            query += "&signature=" + signature;

            apiRequestUrl += "?" + query;
            var response = Server.webRequest(apiRequestUrl, "POST", General.ApiKey);

            var parsedResponse = JsonConvert.DeserializeObject <Order>(response);

            return(parsedResponse);
        }
Beispiel #2
0
        /// <summary>
        /// Places a market order. (Order at the current market price, needs no price or timeInForce params).
        /// </summary>
        /// <returns>The order object</returns>
        /// <param name="symbol">Symbol of currencies to be traded, eg BCCETH.</param>
        /// <param name="side">Order Side, BUY or SELL.</param>
        /// <param name="quantity">Amount to be traded.</param>

        public static Order PlaceMarketOrder(string symbol, OrderSides side, double quantity)
        {
            string apiRequestUrl = "";

            if (Globals.testCase == true)
            {
                apiRequestUrl = $"{baseUrl}v3/order/test";
            }
            else
            {
                apiRequestUrl = $"{baseUrl}v3/order";
            }

            string query = $"symbol={symbol}&side={side}&type={OrderTypes.MARKET}&quantity={quantity}";

            query = $"{query}&timestamp={Helper.getTimeStamp()}";

            var signature = Helper.getSignature(Globals.SecretKey, query);

            query += "&signature=" + signature;

            apiRequestUrl += "?" + query;
            var response = Helper.webRequest(apiRequestUrl, "POST", Globals.ApiKey);

            var parsedResponse = JsonConvert.DeserializeObject <Order>(response);

            return(parsedResponse);
        }
        public async Task <bool> Add(OrderSides OrderSides)
        {
            _context.OrderSides.Add(OrderSides);
            await _context.SaveChangesAsync();

            return(true);
        }
Beispiel #4
0
 public void Insert(IEnumerable <InsertDataItem> items, OrderSides side)
 {
     foreach (var item in items)
     {
         if (side == OrderSides.Buy)
         {
             _bids.TryAdd(item.Id, new OrderBookEntry(item.Id, item.Size, item.Price));
         }
         else if (side == OrderSides.Sell)
         {
             _asks.TryAdd(item.Id, new OrderBookEntry(item.Id, item.Size, item.Price));
         }
     }
 }
Beispiel #5
0
        public void Delete(IEnumerable <DeleteDataItem> items, OrderSides side)
        {
            foreach (var entry in items)
            {
                OrderBookEntry entryToRemove;

                if (side == OrderSides.Buy)
                {
                    _bids.TryRemove(entry.Id, out entryToRemove);
                }
                else if (side == OrderSides.Sell)
                {
                    _asks.TryRemove(entry.Id, out entryToRemove);
                }
            }
        }
Beispiel #6
0
        public void Update(IEnumerable <UpdateDataItem> items, OrderSides side)
        {
            foreach (var entry in items)
            {
                if (side == OrderSides.Buy)
                {
                    var updatedEntry = new OrderBookEntry(entry.Id, entry.Size, _bids[entry.Id].Price);

                    _bids.TryUpdate(entry.Id, updatedEntry, _bids[entry.Id]);
                }
                else if (side == OrderSides.Sell)
                {
                    var updatedEntry = new OrderBookEntry(entry.Id, entry.Size, _asks[entry.Id].Price);

                    _asks.TryUpdate(entry.Id, updatedEntry, _asks[entry.Id]);
                }
            }
        }
Beispiel #7
0
        public BitfinexExchange(ExchangeManager exchangeManager)
            : base(exchangeManager)
        {
            Name        = "Bitfinex";
            ExchangeAPI = new ExchangeAPI
            {
                Name = Name
            };

            PublicFunctions.Add(APIFunction.RequestOrderBook);
            PublicFunctions.Add(APIFunction.RequestTicker);
            PublicFunctions.Add(APIFunction.RequestTrades);

            AvailableFunctions.Add(APIFunction.RequestTicker);
            AvailableFunctions.Add(APIFunction.RequestBalances);
            AvailableFunctions.Add(APIFunction.RequestTrades);
            AvailableFunctions.Add(APIFunction.RequestOrderBook);
            AvailableFunctions.Add(APIFunction.RequestOpenOrders);
            AvailableFunctions.Add(APIFunction.RequestNewOrder);
            AvailableFunctions.Add(APIFunction.CancelOrder);

            OrderSides.Add(OrderSide.Buy);
            OrderSides.Add(OrderSide.Sell);

            DefaultOrderType = new OrderType("exchange limit", "exchange limit");

            OrderTypes.Add(new OrderType("exchange market", "exchange market"));
            OrderTypes.Add(DefaultOrderType);
            OrderTypes.Add(new OrderType("exchange stop", "exchange stop"));
            OrderTypes.Add(new OrderType("exchange trailing-stop", "exchange trailing-stop"));
            OrderTypes.Add(new OrderType("exchange fill-or-kill", "exchange fill-or-kill"));

            OrderTypes.Add(new OrderType("market", "market"));
            OrderTypes.Add(new OrderType("limit", "limit"));
            OrderTypes.Add(new OrderType("stop", "stop"));
            OrderTypes.Add(new OrderType("trailing-stop", "trailing-stop"));
            OrderTypes.Add(new OrderType("fill-or-kill", "fill-or-kill"));

            PairManager.AddSupportedPair(PairBase.BTCUSD, "btcusd");
            PairManager.AddSupportedPair(PairBase.LTCUSD, "ltcusd");
            PairManager.AddSupportedPair(PairBase.LTCBTC, "ltcbtc");
            PairManager.AddSupportedPair(PairBase.DRKUSD, "drkusd");
            PairManager.AddSupportedPair(PairBase.DRKBTC, "drkbtc");
        }
Beispiel #8
0
        /// <summary>
        /// Places an order
        /// </summary>
        /// <param name="symbol">currency</param>
        /// <param name="side">>Order Side, BUY or SELL</param>
        /// <param name="type">Order Type, see Enum.OrderTypes</param>
        /// <param name="timeInForce">Time order will be active for</param>
        /// <param name="quantity">Amount to be traded</param>
        /// <param name="price">Price to be bought/sold at</param>
        /// <returns>The order object</returns>
        public Order PlaceOrder(string symbol, OrderSides side, OrderTypes type, TimesInForce timeInForce, decimal quantity, decimal price)
        {
            string apiRequestUrl = $"{baseUrl}v3/order";

            string query = $"symbol={symbol}&side={side}&type={type}&timeInForce={timeInForce}&quantity={quantity}&price={price}";

            query = $"{query}&timestamp={TimeExtension.getTimeStamp()}";

            var signature = request.getSignature(SettingsAPI.SecretKey, query);

            query += "&signature=" + signature;

            apiRequestUrl += "?" + query;
            var response = request.webRequest(apiRequestUrl, "POST", SettingsAPI.ApiKey);

            var parsedResponse = JsonConvert.DeserializeObject <Order>(response);

            return(parsedResponse);
        }
Beispiel #9
0
        public KrakenExchange(ExchangeManager exchangeManager)
            : base(exchangeManager)
        {
            Name        = "Kraken";
            ExchangeAPI = new ExchangeAPI
            {
                Name = Name
            };

            PublicFunctions.Add(APIFunction.RequestOrderBook);
            PublicFunctions.Add(APIFunction.RequestTicker);
            PublicFunctions.Add(APIFunction.RequestTrades);

            AvailableFunctions.Add(APIFunction.RequestTicker);
            AvailableFunctions.Add(APIFunction.RequestOrderBook);
            AvailableFunctions.Add(APIFunction.RequestBalances);
            AvailableFunctions.Add(APIFunction.RequestOpenOrders);
            AvailableFunctions.Add(APIFunction.RequestNewOrder);

            OrderSides.Add(OrderSide.Buy);
            OrderSides.Add(OrderSide.Sell);

            DefaultOrderType = new OrderType("limit", "limit");
            OrderTypes.Add(new OrderType("market", "market"));
            OrderTypes.Add(DefaultOrderType); // limit
            OrderTypes.Add(new OrderType("stop-loss", "stop Loss"));
            OrderTypes.Add(new OrderType("take-profit", "take profit"));
            OrderTypes.Add(new OrderType("stop-loss-profit", "stop-loss-profit"));
            OrderTypes.Add(new OrderType("stop-loss-profit-limit", "stop-loss-profit-limit"));
            OrderTypes.Add(new OrderType("stop-loss-limit", "stop-loss-limit"));
            OrderTypes.Add(new OrderType("trailing-stop", "trailing-stop"));
            OrderTypes.Add(new OrderType("trailing-stop-limit", "trailing-stop-limit"));
            OrderTypes.Add(new OrderType("stop-loss-and-limit", "stop-loss-and-limit"));

            PairManager.AddSupportedPair(PairBase.BTCEUR, "XBTEUR");
            PairManager.AddSupportedPair(PairBase.LTCEUR, "LTCEUR");
            PairManager.AddSupportedPair(PairBase.BTCUSD, "XBTUSD");
            PairManager.AddSupportedPair(PairBase.LTCUSD, "LTCUSD");
            PairManager.AddSupportedPair(PairBase.BTCLTC, "XBTLTC");
            PairManager.AddSupportedPair(PairBase.BTCXRP, "XBTXRP");
        }
Beispiel #10
0
        public OrderOCO OrderOCO(string symbol, OrderSides side, decimal quantity, decimal price, decimal stopPrice)
        {
            string newQuantity  = quantity.ToString().Replace(',', '.');
            string newPrice     = price.ToString().Replace(',', '.');
            string newstopPrice = stopPrice.ToString().Replace(',', '.');

            string apiRequestUrl = $"{baseUrl}v3/order/oco";

            string query = $"symbol={symbol}&side={side}&quantity={newQuantity}&price={newPrice}&stopPrice={newstopPrice}";

            query = $"{query}&timestamp={TimeExtension.getTimeStamp()}";

            var signature = request.getSignature(SettingsAPI.SecretKey, query);

            query += "&signature=" + signature;

            apiRequestUrl += "?" + query;
            var response = request.webRequest(apiRequestUrl, "POST", SettingsAPI.ApiKey);

            var parsedResponse = JsonConvert.DeserializeObject <OrderOCO>(response);

            return(parsedResponse);
        }
        public async Task <ActionResult <NOrders> > PostOrders(Orders order)
        {
            if (order.Pizzas.IsNullOrEmpty() && order.PreMadePizzaIds.IsNullOrEmpty() && order.SidesIds.IsNullOrEmpty())
            {
                return(UnprocessableEntity());
            }
            else
            {
                NOrders nOrder = new NOrders
                {
                    CustomerId = order.CustomerId,
                    OrderTime  = DateTime.Now //order.OrderTime,
                };
                await _orderRepo.Add(nOrder);

                if (order.Pizzas != null)
                {
                    foreach (var pizza in order.Pizzas)
                    {
                        NPizzas nPizza = new NPizzas
                        {
                            CheeseTypeId = pizza.CheeseTypesId,
                            CrustTypeId  = pizza.CrustTypesId,
                            SauceTypeId  = pizza.SauceTypesId,
                            Size         = pizza.Size,
                            Name         = pizza.Name
                        };
                        await _pizzaRepo.Add(nPizza);

                        await _orderRepo.Add(new OrderPizzas
                        {
                            NOrderId = nOrder.Id,
                            NPizzaId = nPizza.Id
                        });

                        if (pizza.ToppingsId != null)
                        {
                            foreach (var topping in pizza.ToppingsId)
                            {
                                await _pizzaRepo.Add(new PizzaToppings
                                {
                                    NPizzaId  = nPizza.Id,
                                    ToppingId = topping
                                });
                            }
                        }
                    }
                }
                if (order.SidesIds != null)
                {
                    foreach (var sideId in order.SidesIds)
                    {
                        OrderSides os = new OrderSides
                        {
                            NOrderId = nOrder.Id,
                            SideId   = sideId
                        };
                        await _orderRepo.Add(os);
                    }
                }
                if (order.PreMadePizzaIds != null)
                {
                    foreach (var PreMadePizzaId in order.PreMadePizzaIds)
                    {
                        OrderPreMadePizzas opmp = new OrderPreMadePizzas
                        {
                            NOrderId       = nOrder.Id,
                            PreMadePizzaId = PreMadePizzaId
                        };
                        await _orderRepo.Add(opmp);
                    }
                }
                return(CreatedAtAction("GetOrders", new { id = nOrder.Id }, nOrder.Id));
            }
        }
Beispiel #12
0
 public async Task <OrderOCO> OrderOCOAsync(string symbol, OrderSides side, decimal quantity, decimal price, decimal stopPrice)
 {
     return(await Task.Run(() => OrderOCO(symbol, side, quantity, price, stopPrice)));
 }
Beispiel #13
0
 public async Task <Order> PlaceMarketOrderAsync(string symbol, OrderSides side, decimal quantity)
 {
     return(await Task.Run(() => PlaceMarketOrder(symbol, side, quantity)));
 }
Beispiel #14
0
 public async Task <Order> PlaceOrderAsync(string symbol, OrderSides side, OrderTypes type, TimesInForce timeInForce, decimal quantity, decimal price)
 {
     return(await Task.Run(() => PlaceOrder(symbol, side, type, timeInForce, quantity, price)));
 }
 public Task <bool> Add(OrderSides OrderSides)
 {
     throw new NotImplementedException();
 }