static void Main(string[] args) { Constants.ApiKey = ""; Constants.SecretKey = ""; #region PublicAPI //Get Markets test List <Market> listOfMarkets = APIMethods.GetMarkets(); //Get all supported currencies List <MarketCurrency> listOfCurrencies = APIMethods.GetCurrencies(); //Get the current tick value for the specified market Ticker tick = APIMethods.GetTicker("BTC-LTC"); //Gets the summary of all markets List <MarketSummary> listOfMarketSummaries = APIMethods.GetMarketSummaries(); //Gets the summary of a specificed market MarketSummary marketSummary = APIMethods.GetMarketSummary("BTC-LTC"); //Gets the Order book for the specified market OrderBook book = APIMethods.GetOrderBook("BTC-LTC", Order.Type.both); List <MarketHistory> marketHistory = APIMethods.GetMarketHistory("BTC-LTC"); #endregion #region MarketAPI //APIMethods.PlaceBuyLimitOrder("BTC-LTC", 5, 0.17); // APIMethods.PlaceSellLimitOrder("BTC-LTC", 5, 0.17); APIMethods.CancelOrder("328bd88e-537e-4979-9d8b-d2e827d1a49e"); // List<OpenOrder> orders = APIMethods.GetOpenOrders("BTC-GRS"); #endregion #region AccountAPI // List<Balance> balanceList = APIMethods.GetBalances(); Balance balance = APIMethods.GetBalance("GRS"); //APIMethods.Withdraw("GRS", 20.23222, "Address to withdraw GRS to"); AccountOrder accountOrder = APIMethods.GetOrder("uuid here"); List <HistoryOrder> listOfOrderHistory = APIMethods.GetOrderHistory(); List <HistoryOrder> listOfSpecificOrderHistory = APIMethods.GetOrderHistory("BTC-LTC"); #endregion }
private async Task RefreshAvailableBalances() { while (MainActivity.isOnCurrencyFragment == true) { //Update the selected currency balance string selectedCurrencyBalanceAmount = "0.000000000"; try { Balance b = APIMethods.GetBalance(Currency.Substring(4, Currency.Length - 4)); selectedCurrencyBalanceAmount = b.Available.ToString("0.#########"); } catch { Toast.MakeText(Activity, "Unable to get " + currencyString + " Balance, ensure API keys are correct", ToastLength.Short).Show(); } activity.RunOnUiThread(() => { //Change the text on the UI thread selectedCurrencyBalance.Text = selectedCurrencyBalanceAmount; }); //Update the BTC currency balance string btcCurrencyBalanceAmount = "0.000000000"; try { Balance b = APIMethods.GetBalance("BTC"); btcCurrencyBalanceAmount = b.Available.ToString("0.#########"); } catch { Toast.MakeText(Activity, "Unable to get BTC Balance, ensure API keys are correct", ToastLength.Short).Show(); } activity.RunOnUiThread(() => { //Change the text on the UI thread btcBalance.Text = btcCurrencyBalanceAmount; }); await Task.Delay(1000); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment var view = inflater.Inflate(Resource.Layout.CurrencyLayout, container, false); var viewMain = inflater.Inflate(Resource.Layout.Main, null, false); var topToolbar = viewMain.FindViewById <Toolbar>(Resource.Id.toolbar); //Hooks into the refresh button listerner ToolbarOnClickListener listener = new ToolbarOnClickListener(Activity, buyTextView, sellTextView, lastTextView, currencyString); topToolbar.SetOnMenuItemClickListener(listener); //Gets the bottom toolbar var bottomToolbar = (Toolbar)view.FindViewById(Resource.Id.currencyToolbar); bottomToolbar.InflateMenu(Resource.Menu.bot_currency_menu); bottomToolbar.MenuItemClick += BottomToolbar_MenuItemClick; //Get the orders for the market orderBook = APIMethods.GetOrderBook(currencyString, Order.Type.both); //Finds the listview for buy orders buyOrderListView = (ListView)view.FindViewById(Resource.Id.buyOrders_listView); //Create the new adapter buyAdapter = new CurrencyOrderBookAdapter(Activity, orderBook.Buys.ToList(), true); buyOrderListView.Adapter = buyAdapter; //Set the buy orders to the last item buyOrderListView.SetSelection(buyOrderListView.Adapter.Count - 1); //Finds the listview for sell orders sellOrderListView = (ListView)view.FindViewById(Resource.Id.sellOrders_listView); //Create the new adapter sellAdapter = new CurrencyOrderBookAdapter(Activity, orderBook.Sells.ToList(), false); sellOrderListView.Adapter = sellAdapter; //Used to handle OnClick events on users Orders cancel button activity = Activity; //Get the current open orders for the specified currency try { usersOrders = APIMethods.GetOpenOrders(currencyString); } catch (Exception exc) { usersOrders = new List <OpenOrder>(); Toast.MakeText(Activity, exc.Message.ToString(), ToastLength.Short).Show(); } //Find the listview for users orders usersOrderListView = (ListView)view.FindViewById(Resource.Id.yourOrder_listView); //Create a new adapter for users order listview usersOrderAdapter = new YourOrdersListViewAdapter(this.Context, usersOrders); usersOrderListView.Adapter = usersOrderAdapter; //Set the on item click event for the listviews sellOrderListView.ItemClick += OrderListView_ItemClick; buyOrderListView.ItemClick += OrderListView_ItemClick; //Set the trading pair text var tradingPairText = (TextView)view.FindViewById(Resource.Id.tradingPairText); tradingPairText.Text = currencyString; currencySelectedText = (TextView)view.FindViewById(Resource.Id.selectedCurrencyBalanceAvailableText); currencySelectedText.Text = Currency.Substring(4, Currency.Length - 4); //Set the amount of available BTC to the user btcBalance = (TextView)view.FindViewById(Resource.Id.btcBalance); string btcBalanceAmount = "0.000000000"; try { Balance b = APIMethods.GetBalance("BTC"); btcBalanceAmount = b.balance.ToString("0.#########"); } catch { Toast.MakeText(Activity, "Unable to get BTC Balance, ensure API keys are correct", ToastLength.Short).Show(); } btcBalance.Text = btcBalanceAmount; //Set the amount of available currency for the currency selected selectedCurrencyBalance = (TextView)view.FindViewById(Resource.Id.selectedCurrencyBalance); string selectedCurrencyBalanceAmount = "0.000000000"; try { Balance b = APIMethods.GetBalance(Currency.Substring(4, Currency.Length - 4)); selectedCurrencyBalanceAmount = b.Available.ToString("0.#########"); } catch { Toast.MakeText(Activity, "Unable to get " + currencyString + " Balance, ensure API keys are correct", ToastLength.Short).Show(); } selectedCurrencyBalance.Text = selectedCurrencyBalanceAmount; //Subscribe to text changed events for order section totalPriceBtc = (TextView)view.FindViewById(Resource.Id.totalBtcPrice); orderAmount = (EditText)view.FindViewById(Resource.Id.amountToPurchase); orderPrice = (EditText)view.FindViewById(Resource.Id.priceToPurchase); orderAmount.TextChanged += OrderData_TextChanged; orderPrice.TextChanged += OrderData_TextChanged; //Subscribe the order buttons to on click event var buyButton = (Button)view.FindViewById(Resource.Id.buyOrderbutton); var sellButton = (Button)view.FindViewById(Resource.Id.sellOrderbutton); buyButton.Click += BuyButton_Click; sellButton.Click += SellButton_Click; //Testing awaiting method var rereshOrderBook = Task.Run(async() => { await RefreshOrderBook(); }); //Testing awaiting method var refreshUsersOrders = Task.Run(async() => { await RefreshUserOrders(); }); //Testing awaiting method var refreshAvailableBalances = Task.Run(async() => { await RefreshAvailableBalances(); }); //invoke loop method but DO NOT await it //RefreshOrderBook(); return(view); }