public static async Task <List <MarketOrderBook> > GetMarketOrders() { var apiInstance = new OrdersApi(); var orders = await apiInstance.OrdersGetAsync(); var marketGroups = orders.GroupBy(order => order.Price); var orderbooks = new List <MarketOrderBook>(); foreach (var group in marketGroups) { var orderbook = new MarketOrderBook { Price = group.Key.GetValueOrDefault(), MyBidQty = group.Where(order => order.Side == SideEnum.Buy && order.UserId == UserId).Sum(order => order.Quantity).GetValueOrDefault(), MktBidQty = group.Where(order => order.Side == SideEnum.Buy && order.UserId != UserId).Sum(order => order.Quantity).GetValueOrDefault(), MktAskQty = group.Where(order => order.Side == SideEnum.Sell && order.UserId != UserId).Sum(order => order.Quantity).GetValueOrDefault(), MyAskQty = group.Where(order => order.Side == SideEnum.Sell && order.UserId == UserId).Sum(order => order.Quantity).GetValueOrDefault() }; orderbooks.Add(orderbook); } return(orderbooks); }
public Boolean Sell() { MarketOrderBook ob = _broker.returnMarketOrderBook(_TradedPair, 20); Double amount = TargetWallet.amount; while (amount > Convert.ToDouble(ConfigurationManager.AppSettings["Minimum_trade"])) { TradeDone order = _broker.Sell(_TradedPair, ob.GetTheNextBids().rate, amount); amount = amount - order.totalAmountDoneTargetCurrency; } return(false); }