Exemple #1
0
        public static TradingData GetTradingData(MarketTickData marketData, bool splitProfitMargin, decimal buyVolume, TradingFeeData feeData = null)
        {
            TradingData tradingData = new TradingData();

            decimal profitMargin = splitProfitMargin ? BTCMarketsHelper.ProfitMargin / 2 : BTCMarketsHelper.ProfitMargin;

            decimal profitMultiplier = profitMargin / 100 + 1;

            tradingData.BuyVolume = buyVolume;

            decimal buyPrice = marketData.bestAsk;

            int roundPos = marketData.currency == "AUD" ? 2 : 8;

            buyPrice = Math.Round(splitProfitMargin ? buyPrice * (1 - profitMargin / 100) : buyPrice, roundPos);

            tradingData.BuyPrice = buyPrice;

            if (feeData == null)
            {
                feeData = JsonConvert.DeserializeObject <TradingFeeData>(BTCMarketsHelper.SendRequest(MethodConstants.TRADING_FEE_PATH(marketData.instrument, marketData.currency), null));
            }

            decimal tradingFeeMultiplier = 1 + TradingFeeData.GetTradingFee(feeData); // Bot.Settings.TradingFee / 100.0 + 1;

            tradingData.SpendTotal = Math.Round(tradingData.BuyVolume * buyPrice * tradingFeeMultiplier, roundPos);

            tradingData.SellPrice = Math.Round(marketData.bestbid * profitMultiplier, roundPos);

            tradingData.SellVolume = Math.Round(tradingData.SpendTotal / tradingData.SellPrice, 8);

            return(tradingData);
        }
Exemple #2
0
        private void MarketTickTimer_Tick(object sender, EventArgs e)
        {
            Random rnd = new Random();

            marketTickTimer.Interval = new TimeSpan(0, 0, rnd.Next(10, 30));
            TaskEx.Run(() => BTCMarketsHelper.GetMarketTick());

            UpdateTitle();
        }
Exemple #3
0
        /// <summary>
        /// Trading data with buy volume calculated as maximum
        /// </summary>
        /// <param name="marketData"></param>
        /// <returns></returns>
        public static TradingData GetTradingData(MarketTickData marketData, bool splitProfitMargin = false)
        {
            decimal balance = BTCMarketsHelper.RetrieveAccountBalance(marketData.currency) / 2; // buying currency

            TradingFeeData feeData = JsonConvert.DeserializeObject <TradingFeeData>(BTCMarketsHelper.SendRequest(MethodConstants.TRADING_FEE_PATH(marketData.instrument, marketData.currency), null));
            decimal        tradingFeeMultiplier = 1 + TradingFeeData.GetTradingFee(feeData);

            decimal buyVolume = Math.Round((balance / 100000000) / (marketData.bestAsk * tradingFeeMultiplier), 8); // maximum buy volume

            return(GetTradingData(marketData, splitProfitMargin, buyVolume, feeData));
        }
Exemple #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Read API_KEY and PRIVATE_KEY
            Bot.ReadAPIKeys();

            TaskEx.Run(() =>
            {
                BTCMarketsHelper.GetMarketTick();
                IsGuiReady = true;
            });

            UpdateGuiControls();
        }
Exemple #5
0
        private void cboBuySell_DropDownClosed(object sender, EventArgs e)
        {
            BTCMarketsHelper.GetMarketTick();

            UpdateGuiControls();
        }