Esempio n. 1
0
 public BitfinexApiResult <BitfinexPlacedOrder> PlaceOrder(string symbol,
                                                           double amount,
                                                           double price,
                                                           OrderSide side,
                                                           OrderType2 type,
                                                           bool?hidden          = null,
                                                           bool?postOnly        = null,
                                                           bool?useAllAvailable = null,
                                                           bool?ocoOrder        = null,
                                                           double?buyPriceOco   = null,
                                                           double?sellPriceOco  = null) => PlaceOrderAsync(symbol, amount, price, side, type, hidden, postOnly, useAllAvailable, ocoOrder, buyPriceOco, sellPriceOco).Result;
Esempio n. 2
0
        public async Task <BitfinexApiResult <BitfinexPlacedOrder> > PlaceOrderAsync(string symbol,
                                                                                     double amount,
                                                                                     double price,
                                                                                     OrderSide side,
                                                                                     OrderType2 type,
                                                                                     bool?hidden          = null,
                                                                                     bool?postOnly        = null,
                                                                                     bool?useAllAvailable = null,
                                                                                     bool?ocoOrder        = null,
                                                                                     double?buyPriceOco   = null,
                                                                                     double?sellPriceOco  = null)
        {
            if (string.IsNullOrEmpty(apiKey) || encryptor == null)
            {
                return(ThrowErrorMessage <BitfinexPlacedOrder>(BitfinexErrors.GetError(BitfinexErrorKey.NoApiCredentialsProvided)));
            }

            var parameters = new Dictionary <string, object>()
            {
                { "symbol", symbol },
                { "amount", amount.ToString(CultureInfo.InvariantCulture) },
                { "price", price.ToString(CultureInfo.InvariantCulture) },
                { "exchange", "bitfinex" },
                { "side", JsonConvert.SerializeObject(side, new OrderSideConverter(false)) },
                { "type", JsonConvert.SerializeObject(type, new OrderType2Converter(false)) },
            };

            AddOptionalParameter(parameters, "is_hidden", hidden?.ToString());
            AddOptionalParameter(parameters, "is_postonly", postOnly?.ToString());
            AddOptionalParameter(parameters, "use_all_available", useAllAvailable != null ? JsonConvert.SerializeObject(useAllAvailable, new BoolToIntConverter(false)) : null);
            AddOptionalParameter(parameters, "ocoorder", ocoOrder?.ToString());
            AddOptionalParameter(parameters, "buy_price_oco", buyPriceOco?.ToString(CultureInfo.InvariantCulture));
            AddOptionalParameter(parameters, "sell_price_oco", sellPriceOco?.ToString(CultureInfo.InvariantCulture));

            return(await ExecuteAuthenticatedRequestV1 <BitfinexPlacedOrder>(GetUrl(NewOrderEndpoint, OldApiVersion), PostMethod, parameters));
        }