public string Sell(string assetName, decimal amount) { decimal price = MarketProp.AssetPrice(assetName); IAsset asset = Factory.CreateAsset(assetName, price, amount); UserSession.User.Wallet.RemoveAsset(asset); UserSession.User.Wallet.Cash += price * amount; PrinterManager.PrintMarket(UserSession.User, MarketProp); return($"Succesfully selled {amount} {assetName} " + (amount > 1 ? "assets" : "asset")); }
public string Buy(string assetName, decimal amount) { decimal price = MarketProp.AssetPrice(assetName); if (UserSession.User.Wallet.Cash >= price * amount) { IAsset asset = Factory.CreateAsset(assetName, price, amount); UserSession.User.Wallet.AddAsset(asset); UserSession.User.Wallet.Cash -= price * amount; } else { throw new ArgumentException("You don't have enough funds for this purchase."); } PrinterManager.PrintMarket(UserSession.User, MarketProp); return($"Succesfully purchased {amount} {assetName} " + (amount > 1 ? "assets" : "asset")); }
public string EndDayTraiding() { MarketProp.UpdatePrices(); PrinterManager.PrintMarket(UserSession.User, MarketProp); return("Trading day has ended!"); }
public string EndDayTraiding() { MarketProp.UpdatePrices(); return("Trading day has ended!"); }