/// <summary> /// Sell Event Invocator /// </summary> /// <param name="e">The sell event argument</param> protected SellEventArgs OnSellEvent(SellEventArgs e) { if (SellEvent != null && e != null) { SellEvent(this, e); } return(e); }
/// <summary> /// OnSellEvent /// </summary> /// <param name="eventArgs">eventArgs</param> public void OnSellEvent(object sender, SellEventArgs eventArgs) { if (eventArgs.Shares <= 0) { eventArgs.Cancel = true; return; } // adding to cash is predicated on safe removal; this really means you // can't sell more than you have. if (PositionData.Remove(eventArgs)) { Cash += eventArgs.Price * eventArgs.Shares; NumberOfTrades++; } else { eventArgs.Cancel = true; } }
/// <summary> /// The information of a completed sale of bitcoin. /// Software action: Update machine inventory by calling PostInventory() /// Hardware action: Dispense the given amount of cash. /// Hardware action: Print a proof of sale receipt that includes the transaction ID, the amount of fiat, and the amount of bitcoin. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void onSellSuccess(object sender, SellEventArgs e) { WriteToConsole("onSellSuccess: " + "Transaction: " + e.TransactionId + " Fiat: " + e.FiatAmount + " Bitcoin: " + e.BitcoinAmount); WriteToConsole("Hardware Action: Dispenser -> Dispense " + e.FiatAmount); WriteToConsole("Hardware Action: Printer -> Proof of Sale receipt"); }