private BotInstanceData GetCashAndTokenBalance(IBotInstanceData instance)
        {
            BotInstanceData data = (BotInstanceData)instance;

            data.CashTokenValue = _exchange.GetBalance(data.CashTokenSymbol);
            data.TokenSize      = _exchange.GetBalance(data.TokenSymbol);
            Console.WriteLine($"Total cash available {data.CashTokenValue} , number of {data.TokenSymbol} tokens {data.TokenSize}");
            return(data);
        }
Exemple #2
0
        /// <summary>
        /// Gets The result of the strategy
        /// </summary>
        /// <returns></returns>
        public StrategyResult GetResult()
        {
            var balRes = _proxy.GetBalance(_pair);

            return(new StrategyResult
            {
                BalanceItem1 = balRes.Result.Balances[_pair.Item1],
                BalanceItem2 = balRes.Result.Balances[_pair.Item2]
            });
        }
        /// <summary>
        /// Updates the user's balance
        /// </summary>
        /// <param name="displayErrorMessages">Whether to display error messages in a popup</param>
        private void UpdateBalance(bool displayErrorMessages = true)
        {
            var tickerRes = _proxy.GetTicker(_selectedPair);

            if (!tickerRes.Success)
            {
                if (displayErrorMessages)
                {
                    ErrorHelper.DisplayErrorMessage(tickerRes);
                }
                return;
            }
            var    ticker   = tickerRes.Result;
            string currency = _selectedPair.Item2;

            OnTickerUpdate(ticker);

            var balRes = _proxy.GetBalance(_selectedPair);

            if (balRes.Success)
            {
                var bal = balRes.Result;
                _fee = _proxy.GetFee(_selectedPair).Result;
                lblItem1Balance.Text = string.Format("{0} {1}", bal.Balances[_selectedPair.Item1].ToStandardFormat(), _selectedPair.Item1);
                lblItem2Balance.Text = string.Format("{0} {1}", bal.Balances[_selectedPair.Item2].ToStandardFormat(), currency);
            }
            else if (displayErrorMessages)
            {
                ErrorHelper.DisplayErrorMessage(balRes);
            }
        }