public void UpdateMyOrdersHistory_UIResultHandler(RequestItemGroup resultResponse) { if (Helper.IsResultHasErrors(resultResponse)) { return; } List <OrderDone> ordersHistory = (List <OrderDone>)resultResponse.items[0].result.resultData; var dataView = ordersHistory.Select(item => new { date = item.doneDate, orderType = item.orderType, price = Helper.PriceToStringBtc(item.price), amount = Helper.TradeAmountToString(item.quantity), remain = item.quantityRemaining }).ToList(); List <DGVColumn> columns = new List <DGVColumn>() { new DGVColumn("date", "Date", "string"), new DGVColumn("orderType", "Type", "string"), new DGVColumn("price", "Price", "string"), new DGVColumn("amount", "Amount", "string"), new DGVColumn("remain", "Remain", "string") }; DataGridViewWrapper gv = new DataGridViewWrapper(dgridMyOrdersHistory, true); gv.Create(dataView, columns); gv.AutoSizeDisplayedExcept("remain"); }
public void UpdateMyOpenOrders_UIResultHandler(RequestItemGroup resultResponse) { if (Helper.IsResultHasErrors(resultResponse)) { return; } List <OpenOrder> myOpenOrders = (List <OpenOrder>)resultResponse.items[0].result.resultData; var dataView = myOpenOrders.Select(item => new { date = item.openedDate, orderType = item.orderType, price = Helper.PriceToStringBtc(item.price), amount = Helper.PriceToStringBtc(item.quantity), remain = Helper.PriceToStringBtc(item.quantityRemaining) }).ToList(); List <DGVColumn> columns = new List <DGVColumn>() { new DGVColumn("date", "Date", "string"), new DGVColumn("orderType", "Type", "string"), new DGVColumn("price", "Price", "string"), new DGVColumn("amount", "Amount", "string"), new DGVColumn("remain", "Remain", "string") }; DataGridViewWrapper gv = new DataGridViewWrapper(dgridOpenOrders, true); gv.Create(dataView, columns); gv.AutoSizeDisplayedExcept("price"); gv.RowColorByCondition("orderType", "SELL LIMIT", Color.LightPink); }
public void UpdateTradeHistory_UIResultHandler(RequestItemGroup resultResponse) { if (Helper.IsResultHasErrors(resultResponse)) { return; } List <Trade> tradeHistory = (List <Trade>)resultResponse.items[0].result.resultData; var dataView = tradeHistory.Select(item => new { date = item.tradeDate, orderType = item.orderType, price = Helper.PriceToStringBtc(item.price), amount = Helper.TradeAmountToString(item.quantity), fillType = item.fillType }).Take(40).ToList(); List <DGVColumn> columns = new List <DGVColumn>() { new DGVColumn("date", "Date", "string"), new DGVColumn("orderType", "Type", "string"), new DGVColumn("price", "Price", "string"), new DGVColumn("amount", "Amount", "string"), new DGVColumn("fillType", "Fill", "string") }; DataGridViewWrapper gv = new DataGridViewWrapper(dgridTradeHistory, true); gv.Create(dataView, columns); gv.AutoSizeFillExcept("date"); gv.RowColorByCondition("orderType", "SELL", Color.LightPink); }
public void UpdateOrderBook_UIResultHandler(RequestItemGroup resultResponse) { if (Helper.IsResultHasErrors(resultResponse)) { return; } AllOrders orders = (AllOrders)resultResponse.items[0].result.resultData; var dataViewSell = orders.sellOrders.Select(item => new { amount = Helper.PriceToStringBtc(item.quantity), price = Helper.PriceToStringBtc(item.rate) }).Take(150).ToList(); List <DGVColumn> columnsSell = new List <DGVColumn>() { new DGVColumn("amount", "Amount", "string"), new DGVColumn("price", "Price", "string") }; DataGridViewWrapper gvSell = new DataGridViewWrapper(dgridSellOrders, true); gvSell.Create(dataViewSell, columnsSell); gvSell.AutoSizeFillExcept("amount"); var dataViewBuy = orders.buyOrders.Select(item => new { price = Helper.PriceToStringBtc(item.rate), amount = Helper.PriceToStringBtc(item.quantity) }).Take(150).ToList(); DataGridViewWrapper gvBuy = new DataGridViewWrapper(dgridBuyOrders, true); gvBuy.Create(dataViewBuy, columnsSell); gvBuy.AutoSizeFillExcept("amount"); }
public void CreateBalancesGridView(List <ExchangeBalance> balances) { var dataView = balances.Select(item => new { exchangeName = item.exchangeName, currency = item.currency, balance = Helper.PriceToStringBtc(item.balance), }).OrderBy(p => p.exchangeName).ThenBy(p => p.currency).ToList(); List <DGVColumn> columns = new List <DGVColumn>() { new DGVColumn("exchangeName", "Exchange", "string"), new DGVColumn("currency", "Currency", "string"), new DGVColumn("balance", "Balance", "string") }; DataGridViewWrapper gv = new DataGridViewWrapper(dgridBalance, true); gv.Create(dataView, columns); gv.AutoSizeDisplayedExcept("balance"); }
public void GetMarketCurrent_UIResultHandler(RequestItemGroup resultResponse) { if (Helper.IsResultHasErrors(resultResponse)) { return; } Dictionary <string, MarketCurrent> currenciesDict = (Dictionary <string, MarketCurrent>)resultResponse.items[0].result.resultData; List <MarketCurrentView> currencies = currenciesDict.Values.Select(item => new MarketCurrentView { ticker = item.ticker, lastPrice = item.lastPrice, lastPriceUSD = 0, percentChange = item.percentChange, volumeBtc = item.volumeBtc, volumeUSDT = item.volumeUSDT }).ToList(); if (currenciesDict.ContainsKey("USDT_BTC")) { double btcPrice = currenciesDict["USDT_BTC"].lastPrice; foreach (var item in currencies) { if (item.ticker.StartsWith("BTC")) { item.volumeUSDT = item.volumeBtc * btcPrice; } if (item.ticker.StartsWith("BTC")) { item.lastPriceUSD = item.lastPrice * btcPrice; } else if (item.ticker.StartsWith("USDT")) { double usdprice = item.lastPrice; item.lastPriceUSD = usdprice; item.lastPrice = item.lastPrice / btcPrice; } } } currencies = currencies.OrderByDescending(x => x.volumeUSDT).ToList(); var dataView = currencies.Select(item => new { ticker = item.ticker, lastPrice = Helper.PriceToStringBtc(item.lastPrice), lastPriceUSDT = item.lastPriceUSD.ToString("N3") + " $", percentChange = item.percentChange.ToString("0") + " %", volumeBtc = item.volumeBtc.ToString("N2"), volumeUSDT = item.volumeUSDT.ToString("N0") + " $" }).ToList(); List <DGVColumn> columns = new List <DGVColumn>() { new DGVColumn("ticker", "Currency", "string"), new DGVColumn("lastPrice", "Price BTC", "string"), new DGVColumn("lastPriceUSDT", "Price $", "string"), new DGVColumn("percentChange", "Change %", "string"), new DGVColumn("volumeBtc", "Volume BTC", "string"), new DGVColumn("volumeUSDT", "Volume $", "string") }; gvMarkets = new DataGridViewWrapper(dgridMarkets, true); gvMarkets.Create(dataView, columns); DataGridViewCellStyle styleTicker = new DataGridViewCellStyle { Font = new Font("Tahoma", 9.0F, FontStyle.Bold), ForeColor = Color.Black }; DataGridViewCellStyle stylePrice = new DataGridViewCellStyle { Font = new Font("Tahoma", 9.0F, FontStyle.Regular), ForeColor = Color.Black }; gvMarkets.SetColumnStyle("ticker", styleTicker); gvMarkets.SetColumnStyle("lastPrice", stylePrice); gvMarkets.SetColumnStyle("lastPriceUSDT", stylePrice); gvMarkets.AutoSizeFillExcept("volumeUSDT"); // gv.RowColorByCondition("orderType", (string s) => { return s == "1"; }, Color.LightPink); timerMarkets.Start(); }
public void UpdateOrderBook_UIResultHandler(RequestItemGroup resultResponse) { if (RequestManager.IsResultHasErrors(resultResponse)) { return; } try { AllOrders orders = (AllOrders)resultResponse.items[0].result.resultData; var dataViewSell = orders.sellOrders.Select(item => new { amount = Helper.PriceToStringBtc(item.quantity), price = Helper.PriceToStringBtc(item.rate) }).Take(150).ToList(); List <DGVColumn> columnsSell = new List <DGVColumn>() { new DGVColumn("amount", "Amount", "string"), new DGVColumn("price", "Price", "string") }; DataGridViewWrapper gvSell = new DataGridViewWrapper(dgridSellOrders, true); gvSell.Create(dataViewSell, columnsSell); gvSell.AutoSizeFillExcept("amount"); var dataViewBuy = orders.buyOrders.Select(item => new { price = Helper.PriceToStringBtc(item.rate), amount = Helper.PriceToStringBtc(item.quantity) }).Take(150).ToList(); DataGridViewWrapper gvBuy = new DataGridViewWrapper(dgridBuyOrders, true); gvBuy.Create(dataViewBuy, columnsSell); // gvBuy.AutoSizeFillExcept("amount"); // contr orderbook data grid var dataViewContrSell = orders.sellOrders.Select(item => new { price = Helper.PriceToStringBtc(item.rate), amount = Helper.PriceToStringBtc(item.quantity) }).Take(5).OrderByDescending(o => o.price).ToList(); DataGridViewWrapper gvContrSell = new DataGridViewWrapper(dGridContrSell, true); gvContrSell.Create(dataViewContrSell, columnsSell); // if (dGridContrSell.RowCount>0) // dGridContrSell.FirstDisplayedScrollingRowIndex = dGridContrSell.RowCount - 1; var dataViewContrBuy = orders.buyOrders.Select(item => new { price = Helper.PriceToStringBtc(item.rate), amount = Helper.PriceToStringBtc(item.quantity) }).Take(5).ToList(); DataGridViewWrapper gvContrBuy = new DataGridViewWrapper(dGridContrBuy, true); gvContrBuy.Create(dataViewContrBuy, columnsSell); gvContrBuy.ShowColumnHeaders(false); } catch (Exception ex) { Logman.Log(ex); } }