/// <summary>
        /// OnBuyEvent
        /// </summary>
        /// <param name="eventArgs">eventArgs</param>
        public void OnBuyEvent(object sender, BuyEventArgs eventArgs)
        {
            var totalValue = eventArgs.Shares * eventArgs.MarketData.Close;

            if (totalValue >= Cash)
            {
                eventArgs.Cancel = true;

                return;
            }
            else if (eventArgs.Cancel)
            {
                return;
            }

            if (PositionData.Add(eventArgs))
            {
                NumberOfTrades++;
                Cash -= totalValue;
            }
            else
            {
                eventArgs.Cancel = true;
            }
        }
예제 #2
0
        /// <summary>
        /// Buy Event Invocator
        /// </summary>
        /// <param name="e">The buy event arguments</param>
        protected BuyEventArgs OnBuyEvent(BuyEventArgs e)
        {
            if (BuyEvent != null && e != null)
            {
                BuyEvent(this, e);
            }

            return(e);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eventArgs"></param>
        /// <returns></returns>
        private static BuyEventArgs BuyCondition(MarketTickEventArgs eventArgs)
        {
            BuyEventArgs buyEventArgs = null;



            if (eventArgs.RSI < 20)
            {
                buyEventArgs = new BuyEventArgs(eventArgs.MarketData, (int)eventArgs.RSI);
            }

            if (buyEventArgs != null && buyEventArgs.Shares == 0)
            {
                return(null);
            }

            return(buyEventArgs);
        }
 /// <summary>
 /// The information of a completed purchase of bitcoin.
 /// Software action: Update machine inventory by calling PostInventory()
 /// Hardware action: Print a proof of purchase receipt that includes the transaction ID, the amount of fiat, and the amount of bitcoin.
 /// Hardware action: Disable the bill validator.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void onBuySuccess(object sender, BuyEventArgs e)
 {
     _totalInserted = 0;
     WriteToConsole("onBuySuccess: " + "Transaction: " + e.TransactionId + " Bitcoin: " + e.BitcoinAmount + " Fiat: " + e.FiatAmount);
     WriteToConsole("Hardware Action: Validator -> Disable");
     WriteToConsole("Hardware Action: Printer -> Proof of Purchase receipt");
 }