private void Button_Click(object sender, RoutedEventArgs e) { try { client.SetApiCredentials(keytb.Text, secrettb.Text); var x = client.GetAccount(); if (x.Error != null && x.Error.Message == "Server error: APIKEY_INVALID") { errormsg.Content = "Invalid API Key"; return; } } catch (Exception ex) { errormsg.Content = ex.Message; return; } //good key and secret. continue Key = keytb.Text; Secret = secrettb.Text; this.Close(); }
private void LoadChart(string symbol, CandleInterval interval) { CurrentLoadedSymbol = symbol; CurrentInterval = interval; //client.SetApiCredentials("118180a6a91e29425c90c2e2afe349aa71", "e36a6307025c4b4fb1b20a4a00c4c9ef"); client.SetApiCredentials(Key, Secret); //get min trade size var markets = client.GetSymbols(); if (markets.Data != null) { var market = markets.Data.FirstOrDefault(l => l.Symbol == symbol); CurrentMinTradeSize = market.MinTradeSize; } //get high low data var summary = client.GetSymbolSummary(symbol); if (summary.Data != null) { CurrentPriceHigh = summary.Data.High; CurrentPriceLow = summary.Data.Low; } //get balance for currency var balance = client.GetBalance(symbol.Substring(0, 3)); if (balance.Data != null) { AccountBalance = balance.Data.Available.ToString() + " " + balance.Data.Currency; } //get order history var orderhistory = client.GetOrderBook(symbol); if (orderhistory.Data != null) { OrderBook = orderhistory.Data; } //get closed orders var d = client.GetClosedOrders(symbol); if (d.Data != null) { ClosedOrders = new ObservableCollection <BittrexOrderV3>(d.Data); } //get open orders var o = client.GetOpenOrders(symbol); if (o.Data != null) { OpenOrders = new ObservableCollection <BittrexOrderV3>(o.Data); } //var balance = client.GetBalance(CurrentLoadedSymbol); //if (balance.Data != null) //{ // AccountBalance = balance.Data.Total.ToString(); //} //else //{ // AccountBalance = "0.00"; //} string intervalstring = ""; if (interval == CandleInterval.Day1) { intervalstring = "DAY_1"; } else if (interval == CandleInterval.Hour1) { intervalstring = "HOUR_1"; } else if (interval == CandleInterval.Minute1) { intervalstring = "MINUTE_1"; } else if (interval == CandleInterval.Minutes5) { intervalstring = "MINUTE_5"; } var coincandledatajson = CallRestMethod("https://api.bittrex.com/v3/markets/" + symbol + "/candles/" + intervalstring + "/recent"); var coincandledata = JsonConvert.DeserializeObject <CandleData[]>(coincandledatajson); coinsCb.SelectedItem = symbol; //defualt foreach (CandleData candle in coincandledata) { candle.Time = candle.StartsAt.DateTime; } if (plotmodel != null) { plotmodel.Series.Clear(); } OxyPlot.PlotModel model = new OxyPlot.PlotModel(); //x model.Axes.Add(new DateTimeAxis { //StringFormat = "hh:mm", Title = "Time", AxislineColor = OxyColors.White, TitleColor = OxyColors.White, TicklineColor = OxyColors.White, TextColor = OxyColors.White, MinorIntervalType = DateTimeIntervalType.Auto, Position = AxisPosition.Bottom, }); XAxis = model.Axes[0]; //y model.Axes.Add(new LinearAxis() { Title = "Market Price", Position = AxisPosition.Left, AxislineColor = OxyColors.White, TitleColor = OxyColors.White, TicklineColor = OxyColors.White, TextColor = OxyColors.White, }); YAxis = model.Axes[1]; //create plot model and add the line series CandleStickSeries data = new CandleStickSeries() { Title = symbol }; data.DataFieldClose = "Close"; data.DataFieldHigh = "High"; data.DataFieldLow = "Low"; data.DataFieldOpen = "Open"; data.DataFieldX = "Time"; data.Color = OxyColors.DarkGray; data.IncreasingColor = OxyColors.Green; data.DecreasingColor = OxyColors.Red; data.ItemsSource = coincandledata; data.TrackerFormatString = "Date: {2}\nOpen: {5:0.00000}\nHigh: {3:0.00000}\nLow: {4:0.00000}\nClose: {6:0.00000}"; plotmodel = model; model.PlotAreaBorderColor = OxyColors.White; model.LegendTextColor = OxyColors.YellowGreen; model.Series.Add(data); model.Background = OxyColors.Black; model.MouseUp += Model_MouseUp;; model.MouseDown += Model_MouseDown;; plotview.Model = model; if (LimitLineSeries != null) { DrawLimitLine(OrderSide.Buy, LimitLineSeries); } }