/// <summary> /// Gets the ticker for a given currency pair /// </summary> /// <param name="pair">The currency pair</param> /// <returns>The ticker</returns> public CallResult <Ticker> GetTicker(CurrencyPair pair) { return(CallProxy(() => _proxy.GetTicker(pair.ToCryptsyPair()), t => new Ticker { Ask = t.Ask, Bid = t.Bid, High = t.High, Low = t.Low, Last = t.Last })); }
/// <summary> /// Gets all open orders /// </summary> /// <param name="pair">The currency pair</param> /// <returns>A list of open orders</returns> public CallResult <OpenOrders> GetOpenOrders(CurrencyPair pair) { return(CallProxy(() => _proxy.GetOpenOrders(pair.ToCryptsyPair()), openOrders => new OpenOrders { List = openOrders.Select(o => new OrderDetails { Amount = o.Amount, DateTime = o.DateTime, Id = o.Id, Price = o.Price, Type = o.Type == CryptsyAPI.OrderTypes.Buy ? OrderType.Buy : OrderType.Sell }).ToList() })); }
/// <summary> /// Gets recent transactions /// </summary> /// <param name="lastMin"></param> /// <param name="pair">The currency pair</param> /// <returns>The most recent transactions</returns> public CallResult <TransactionList> GetTransactions(bool lastMin, CurrencyPair pair) { return(CallProxy(() => _proxy.GetRecentTrades(pair.ToCryptsyPair()), tlist => new TransactionList { Transactions = tlist.Select((t => new DO.Exchanges.Transaction { Amount = t.Amount, Price = t.Price, ID = t.ID, Timestamp = BitstampAPI.UnixTimeHelper.GetFromDateTime(t.Date), Date = t.Date })).ToList() })); }
/// <summary> /// Gets the order book for a currency pair /// </summary> /// <param name="pair">The currency pair</param> /// <returns>The order book (bids/asks)</returns> public CallResult <OrderBook> GetOrderBook(CurrencyPair pair) { return(CallProxy(() => _proxy.GetOrderBook(pair.ToCryptsyPair()), o => new OrderBook { Asks = o.Asks.Select(a => new SimpleOrderInfo { Amount = a.Amount, Price = a.Price }).ToList(), Bids = o.Bids.Select(b => new SimpleOrderInfo { Amount = b.Amount, Price = b.Price }).ToList(), } )); }
/// <summary> /// Places a buy order /// </summary> /// <param name="amount">The amount of units to buy</param> /// <param name="price">The price per unit</param> /// <param name="pair">The currency pair</param> /// <returns>Detaisl about the new order</returns> public CallResult <OrderDetails> PlaceBuyOrder(decimal amount, decimal price, CurrencyPair pair) { return(CallProxy(() => _proxy.PlaceOrder(price, amount, CryptsyAPI.OrderTypes.Buy, pair.ToCryptsyPair()), o => new OrderDetails { Amount = amount, DateTime = DateTime.UtcNow, Id = o, Price = price, Type = OrderType.Sell })); }