Exemplo n.º 1
0
 public TradeOrder(string remoteOrderId, Network network, AssetPair pair, TradeOrderType orderType, decimal price)
 {
     Network       = network;
     RemoteOrderId = remoteOrderId.Trim();
     Pair          = pair;
     OrderType     = orderType;
     Price         = new Money(price, pair.Asset2);
 }
Exemplo n.º 2
0
        public override OrderResponse PlaceOrder(double price, double amount, CurrencyName inst, OrderSide side, TradeOrderType type = TradeOrderType.Limit)
        {
            OkExOrderResponse response = null;
            var symbol = inst.ToString().ToLower() + "_usd";

            if (type == TradeOrderType.Limit)
            {
                response = _client.PlaceLimitOrder(side == OrderSide.BID ? "buy" : "sell", symbol, amount, price);
            }
            else
            {
                throw new ArgumentException("Invalid order type");
            }

            return(response.Result
                ? new OrderResponse(DateTime.UtcNow, response.OrderId)
                : new OrderResponse()
            {
                ErrorReason = String.Format("[OkEx] {0}", response.ErrorCode)
            });
        }
Exemplo n.º 3
0
        public override OrderResponse PlaceOrder(double price, double amount, CurrencyName currency, OrderSide side, TradeOrderType type = TradeOrderType.Limit)
        {
            BittrexOrderResponse response = null;
            string path   = side == OrderSide.BID ? "buylimit" : "selllimit";
            string market = "USDT-" + currency;

            if (type == TradeOrderType.Limit)
            {
                response = _client.PlaceLimitOrder(path, amount, price, market);
            }
            else
            {
                throw new ArgumentException("Invalid order type");
            }

            return(response.Success
                ? new OrderResponse(response.Result.OrderId)
                : new OrderResponse()
            {
                ErrorReason = response.Message
            });
        }
Exemplo n.º 4
0
        public override OrderResponse PlaceOrder(double price, double amount, CurrencyName currency, OrderSide side, TradeOrderType type = TradeOrderType.Limit)
        {
            QuadrigaOrderResponse response = null;
            string path = side == OrderSide.BID ? "buy" : "sell";
            string book = currency.ToString().ToLower() + "_cad";

            if (type == TradeOrderType.Limit)
            {
                response = _client.PlaceLimitOrder(path, amount, book, price);
            }
            else if (type == TradeOrderType.Market)
            {
                response = _client.PlaceMarketOrder(path, amount, book, price);
            }
            else
            {
                throw new ArgumentException("Invalid order type");
            }

            return(response.Error == null
                ? new OrderResponse(response.Datetime, response.OrderId)
                : new OrderResponse()
            {
                ErrorReason = response.Error.Message
            });
        }
Exemplo n.º 5
0
        public override OrderResponse PlaceOrder(double price, double amount, CurrencyName currency, OrderSide side, TradeOrderType type = TradeOrderType.Limit)
        {
            string market = currency.ToString().ToLower() + "uah";
            var    order  = _client.PlaceOrder(market, side == OrderSide.BID ? "buy" : "sell", amount, price);

            return(order.Error == null
                ? new OrderResponse(order.CreatedAt, order.Id)
                : new OrderResponse {
                ErrorReason = order.Error.Message
            });
        }
Exemplo n.º 6
0
 public override OrderResponse PlaceOrder(double price, double amount, CurrencyName currency, OrderSide side, TradeOrderType type = TradeOrderType.Limit)
 {
     return(_restExchange.PlaceOrder(price, amount, currency, side, type));
 }
Exemplo n.º 7
0
        public override OrderResponse PlaceOrder(double price, double amount, CurrencyName inst, OrderSide side, TradeOrderType type = TradeOrderType.Limit)
        {
            BitstampOrderResponse response = null;
            var symbol = inst.ToString().ToLower() + "usd";

            if (type == TradeOrderType.Limit)
            {
                response = Client.PlaceLimitOrder(side == OrderSide.BID ? "buy" : "sell", symbol, amount, price);
            }
            else
            {
                throw new ArgumentException("[Bitstamp] Invalid order type");
            }

            if (String.Compare(response.Status, "error", true) != 0)
            {
                return(new OrderResponse(response.Datetime, response.OrderId));
            }

            var str = new StringBuilder("[Bitstamp] PlaceOrder");

            foreach (var error in response.Reason.All)
            {
                str.AppendFormat(" {0}", error);
            }
            return(new OrderResponse()
            {
                ErrorReason = str.ToString()
            });
        }
Exemplo n.º 8
0
        public override OrderResponse PlaceOrder(double price, double amount, CurrencyName instrument, OrderSide side, TradeOrderType type = TradeOrderType.Limit)
        {
            var result = _client.PlaceOrder(side == OrderSide.BID ? "buy" : "sell", instrument, amount, CurrencyName.PLN, price);

            return(result.Success ? new OrderResponse(result.OrderId) : new OrderResponse()
            {
                ErrorReason = "Error"
            });
        }
Exemplo n.º 9
0
 public virtual OrderResponse PlaceOrder(double price, double amount, CurrencyName currency, OrderSide side, TradeOrderType type = TradeOrderType.Limit)
 {
     return(null);
 }
Exemplo n.º 10
0
        public override OrderResponse PlaceOrder(double price, double amount, CurrencyName currency, DataType.OrderSide orderSide, TradeOrderType type = TradeOrderType.Limit)
        {
            if (!(currency == CurrencyName.BTC || currency == CurrencyName.BCH ||
                  currency == CurrencyName.ETH || currency == CurrencyName.LTC))
            {
                return(new OrderResponse {
                    ErrorReason = "Invalid instrument"
                });
            }
            var currencyName = currency.ToString();

            if (currency == CurrencyName.BCH)
            {
                currencyName = "BCC";
            }

            var symbol = currencyName + "USDT";
            var side   = orderSide == DataType.OrderSide.BID ? Binance.Net.Objects.OrderSide.Buy : Binance.Net.Objects.OrderSide.Sell;

            //"LIMIT", "LIMIT_MAKER", "MARKET", "STOP_LOSS_LIMIT", "TAKE_PROFIT_LIMIT"

            var result = _client.PlaceOrder(symbol, side, OrderType.Limit, TimeInForce.GoodTillCancel, amount, price);

            return(result.Success
                ? new OrderResponse(result.Data.TransactTime, result.Data.OrderId.ToString())
                : new OrderResponse {
                ErrorReason = result.Error.Message, ErrorCode = result.Error.Code
            });
        }