public IStock CalculateNewReceive(IStock newStock,IStock currentStock,bool includeMargin) { stock = null; if (ValidationService.ValidateStockService(newStock, currentStock)) { currentStock = BindCostFromLedger(currentStock); decimal totalCost,totalQuantity; // Add the TotalCost totalCost = Math.Round(newStock.Quantity*newStock.UnitCost,2,MidpointRounding.AwayFromZero) + Math.Round(currentStock.Quantity*currentStock.UnitCost,2,MidpointRounding.AwayFromZero); // Add the Quantities totalQuantity = currentStock.Quantity + newStock.Quantity; //Set the Quantity and UnitCost to the Averagecost currentStock.Quantity = totalQuantity; currentStock.UnitCost = Math.Round(totalCost/totalQuantity, 2, MidpointRounding.AwayFromZero); //Set Margin From New Stock and calculate SellingPrice if necessary currentStock.Margin = newStock.Margin; currentStock.SellingPrice = includeMargin?Math.Round(currentStock.Margin* currentStock.UnitCost,2, MidpointRounding.AwayFromZero):currentStock.UnitCost; currentStock.Identifier = newStock.Identifier; stock = currentStock; return stock; } return stock; }
public void Update(IStock stock) { var stockObj = stock as Stock; if (null != stockObj) Console.WriteLine("Notified: {0}[Trading ID #{1}] Of {2} changed to {3:C}", Name, Id, stockObj.Symbol, stockObj.Price); }
public PlayDomino(int numberOfPlayers) { _myDomino=new DominoGame(); _stock=new Stock(); _stock.Shuffle(15); _myDomino.InitializePlayers(numberOfPlayers); _myDomino.InitializeTurns(); _currentPlayer = _myDomino.GetPlayerAtTurn(_myDomino.PlayerTurn); }
public PlayDomino(IDominoGame myDominoGame,IStock stock,int numberOfPlayers) { _myDomino = myDominoGame; _stock = stock; _stock.Shuffle(15); _myDomino.InitializePlayers(numberOfPlayers); _myDomino.InitializeTurns(); _currentPlayer= _myDomino.GetPlayerAtTurn(_myDomino.PlayerTurn); }
public virtual decimal CalculatePriceEarningsRatio(IStock stock, decimal marketPrice) { if (stock.LastDividend == 0) throw new Exception("Cannot calculate price-earnings ratio as last dividend is zero."); decimal ratio = marketPrice / stock.LastDividend; return ratio; }
public IStock BindCostFromLedgerLite(IStock stock) { LedgerService ledgerService = new LedgerService(repository); LedgerLite ledger = ledgerService.GetLedgerLite(stock.ItemId, stock.UnitId, stock.ManufacturerId, stock.MovingAverageId); stock.UnitCost = ledger.UnitCost; stock.Margin = ledger.Margin; stock.SellingPrice = ledger.SellingPrice; return stock; }
public StockForm(string stkCode, string stkName) { InitializeComponent(); InitMainMenu(); CandleGraph(); stock = new StockDependsOnMemory(this.Handle, stkCode, stkName); stock.LoadPK(); stock.LoadMins(); lineType = "日线"; }
public void Init() { prices = new decimal[] { 6, 50, 9, 1200 }; trades = GetTradesMock(); stocks = GetStocksMock(); common = stocks[1]; preferred = stocks[3]; gbce = new Exchange(); gbce.SetStocks(GetStocksMock()); }
public MyClass(IStock stock, IMarketDay marketDay) { Stock = stock; MarketDay = marketDay; CreatedOn = DateTime.Now; if (marketDay.Date.ToDateTimeUtc() == CreatedOn.Date) { DoThing1(); } else { DoThing2(); } }
public ParserD(String formula, IStock _stock) { stock = _stock; Regex split = new Regex("([+\\-*/<>=()])|([\\[\\],])|[;]|(AND)|(OR)"); formulaElement=split.Split(formula); //清除空字符串 int count = 0; //for (int i = 0; i < formulaElement.Length; i++) { // if (formulaElement[i] == "") { // for (int j = i + 1; j < formulaElement.Length; j++) { // formulaElement[j - 1] = formulaElement[j]; // } // count++; // formulaElement[formulaElement.Length - count] = null; // } //} foreach (String s in formulaElement) { if (s == "") { count++; } } String[] temp = new String[formulaElement.Length - count]; int countOfTemp=0; for (int i = 0; i < formulaElement.Length; i++) { if (formulaElement[i] != "") { temp[countOfTemp]=formulaElement[i]; countOfTemp++; } } //for (int i = 0; i < temp.Length; i++) { // temp[i] = formulaElement[i]; //} formulaElement = temp; //test //Decimal r=getResult(formulaElement); //Console.WriteLine(r); //test //String[] test = { "[", "pow", "[", "30", ",", "open", "]", "+", "4", ",", "end", "]" }; //Queue<String>q=new Queue<string>(); //foreach (String s in test) { // q.Enqueue(s); //} //breakFormula(q,","); //this.getResult(formulaElement); //foreach (String s in formulaElement) { // Console.WriteLine(s); // Comparer.typeOfElement(s); //} //simplifyForm(formulaElement); }
public virtual decimal CalculateDividendYield(IStock stock, decimal marketPrice) { if (marketPrice == 0) throw new Exception("Cannot calculate dividend yield when market price is zero."); if (stock.StockType == Constants.StockTypePreferred && !stock.FixedDividend.HasValue) throw new Exception("Preferred stock must have a fixed dividend value in order to calculate the yield."); decimal yield = stock.StockType == Constants.StockTypePreferred ? (stock.FixedDividend ?? 0m * stock.ParValue * 0.01m) / marketPrice : stock.LastDividend / marketPrice; return yield; }
public MyClassCurrentTimeInConstructor( IStock stock, IMarketDay marketDay) { Stock = stock; MarketDay = marketDay; CreatedOn = SystemTime.Now(); if (marketDay.Date.ToDateTimeUtc() == CreatedOn.Date) { DoThing1(); } else { DoThing2(); } }
public IntPtr ReadStockPtr(IStock drive) { if (drive != null) { drive.ReadHeader(); BufferSize = drive.BufferSize; binReceive = new byte[BufferSize]; GCHandle handler = GCHandle.Alloc(binReceive, GCHandleType.Pinned); binReceivePtr = GCHandle.ToIntPtr(handler); IntPtr rawpointer = handler.AddrOfPinnedObject(); drive.Read(rawpointer, BufferSize, 0); ReceiveBytes(rawpointer, BufferSize); } return(DeserialPacketPtr); }
public object ReadStock(IStock drive) { if (drive != null) { drive.ReadHeader(); BufferSize = drive.BufferSize; byte[] bufferread = new byte[BufferSize]; GCHandle handler = GCHandle.Alloc(bufferread, GCHandleType.Pinned); IntPtr rawpointer = handler.AddrOfPinnedObject(); drive.Read(rawpointer, BufferSize, 0L); ReceiveBytes(bufferread, BufferSize); handler.Free(); } return(DeserialPacket); }
public FormulaEdit(IStock _stock) { InitializeComponent(); stock = _stock; tipStr = "说明:\n" + "支持运算符:\n" + " 运算类:+ - * / () [] pow sin cos tan asin acos atan\n" + "\t exp ln log sqrt abs ceiling floor intpart\n" + "\t rand sign round fracpart max min mod\n" + "\t 多参数函数请用[arg0,arg1,…]予以标示\n" + " 布尔类:if nif and or\n" + "\t 布尔运算请用{}予以标示\n\n" + "支持数据类型:\n" + " 当日数据:open close high low vol"; }
static void Main(string[] args) { Console.Title = "Client"; Console.WriteLine("Press Enter when the service is ready"); Console.ReadLine(); InstanceContext context = new InstanceContext(new StockCallback()); DuplexChannelFactory <IStock> factory = new DuplexChannelFactory <IStock>(context, "StockEP"); IStock proxy = factory.CreateChannel(); proxy.RegisterForQuote("MSFT"); Console.WriteLine("Waiting for stock updates. Press Enter to stop"); Console.ReadLine(); }
public void RemoveStockFromWarehouse(IStock stock, IEmployee employee) { Validate.CheckNullObject(stock, employee); //only employees with right (Responsibility) to SELL can perform this work if (employee.Responsibilities.Contains(ResponsibilityType.Sell) || employee.Responsibilities.Contains(ResponsibilityType.Manage)) { availableStocks.Remove(stock); } else { throw new ArgumentException("No authorization to remove stock from warehouse!"); } }
/// <summary> /// Get historical scaling factor for leadstock and child stock /// </summary> /// <param name="leadStock">The lead stock.</param> /// <param name="childStock">The child stock.</param> /// <returns></returns> public decimal GetHistoricalScalFactor(IStock leadStock, IStock childStock) { decimal x = 0.0M; if (AreNoETOs(childStock)) { decimal childVol = DoHistVolCalc(childStock); decimal parentVol = DoHistVolCalc(leadStock); if (parentVol != 0 & childVol != 0) { x = childVol / parentVol; } } return(x); }
/* * when a Stock is added to the portefolio it attaches to the given stock * to be notified for any given changes for that stock */ public void AddStock(IStock stock, int amount) { var subject = (Subject)stock; subject.Attach(this); ; var mystock = new Ownstock { Amount = amount, Name = stock.Navn, Value = stock.Value }; _myOwnStock.Add(mystock); }
public double CalcDividendYield(IStock stock) { if (stock == null) { return(-1); } if (stock.LastPrice == 0) { return(-1); } if (stock.Type == StockType.Common) { return(Math.Round(stock.LastDividend / stock.LastPrice, 4)); } return(Math.Round((stock.FixedDividend * stock.ParValue / stock.LastPrice), 4)); }
/// <summary> /// Updates changes that are made in stock report /// </summary> /// <param name="stock"></param> public void EditBookStatus(IStock stock) { string storedProcedure = StoredProcedures.EditBookStatus.ToString(); var obj = new { ItemsID = stock.ItemsID, StockID = stock.StockID, Available = stock.Available, Reason = stock.Reason }; using (var conn = Create_Connection()) { conn.Execute(storedProcedure, obj, commandType: CommandType.StoredProcedure); } }
public void Init() { _portfolio = Substitute.For <IPortfolio>(); _stock = Substitute.For <IStock>(); _uut = new PortfolioDisplay(); _portfolio.Name.Returns("Folder1"); _portfolio.Total.Returns(1); var tempDic = new Dictionary <IStock, int>(); tempDic.Add(_stock, 40); _portfolio.Stocks.Returns(tempDic); }
public void AddStockToWarehouse(IStock stock, IEmployee employee) { Validate.CheckNullObject(stock, employee); //only employees with right (Responsibility) to BUY can perform this work if (employee.Responsibilities.Contains(ResponsibilityType.BuyPartForWarehouse) || employee.Responsibilities.Contains(ResponsibilityType.Manage) || employee.Responsibilities.Contains(ResponsibilityType.BuyPartForClient) || employee.Responsibilities.Contains(ResponsibilityType.WorkInWarehouse)) { availableStocks.Add(stock); } else { throw new ArgumentException("No authorization to put stock in warehouse parts."); } }
public void TestHistoricalExtrapolate() { IStock stockASXParent = LoadStock("AGK"); IVolatilitySurface stockASXChild = CreateNullVolSurface(); IVolatilitySurface targetChild = CreateNullVolSurface(); IStock stockSDParent = LoadStock("AGK"); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 8, 28), 1208)); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 8, 29), 1221)); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 8, 30), 1218)); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 8, 31), 1207)); stockASXParent.Valuations.Add(new Valuation(new DateTime(2008, 9, 1), 1250)); RateCurve rateCurve = CreateRateCurve(); List <Dividend> divCurve = CreateDividends(); IStock nullASXChild = new Stock(new DateTime(2009, 9, 9), 200.0M, "ZZZ", "ZZZ", rateCurve, divCurve); nullASXChild.VolatilitySurface = stockASXChild; nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 12), 208)); nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 13), 221)); nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 14), 218)); nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 15), 207)); nullASXChild.Valuations.Add(new Valuation(new DateTime(2008, 12, 16), 201)); ExtrapolationHelper extrap = new ExtrapolationHelper(); decimal histvol1 = extrap.DoHistVolCalc(stockASXParent); decimal histvol2 = extrap.DoHistVolCalc(nullASXChild); Assert.AreEqual(0.375846, Convert.ToDouble(histvol1), 0.0001); Assert.AreEqual(0.770018, Convert.ToDouble(histvol2), 0.0001); extrap.PopulateHistoricalVols(stockASXParent, nullASXChild, targetChild); double scalFactor = Convert.ToDouble(extrap.GetHistoricalScalFactor(stockASXParent, nullASXChild)); Assert.AreEqual(scalFactor, 2.0487573, 0.0001); //Spreadsheet fit SD parent to (5d, 1.000 * F) point, flatline endpoints. decimal SDParentVol0 = 0.296175M; // Spreadsheet fit SD parent to (7d,0.867 * F) point decimal SDParentVol1 = 0.320240M; // Spreadsheet fit SD parent to (21d,1.00 * F) point decimal SDParentVol2 = 0.287656M; double childExtrapVol0 = scalFactor * Convert.ToDouble(SDParentVol0); double childExtrapVol1 = scalFactor * Convert.ToDouble(SDParentVol1); double childExtrapVol2 = scalFactor * Convert.ToDouble(SDParentVol2); Assert.AreEqual(Convert.ToDouble(SDParentVol0 * histvol2 / histvol1), childExtrapVol0, 0.001); Assert.AreEqual(Convert.ToDouble(SDParentVol1 * histvol2 / histvol1), childExtrapVol1, 0.001); Assert.AreEqual(Convert.ToDouble(SDParentVol2 * histvol2 / histvol1), childExtrapVol2, 0.001); }
/// <summary> /// Gets the vol at. /// </summary> /// <param name="stock"></param> /// <param name="expiry">The expiry.</param> /// <param name="moneyness">The moneyness.</param> /// <returns></returns> public double GetVolAt(IStock stock, DateTime expiry, double moneyness) { DateTime date0 = ((Stock)stock).Date; double fwd = ((Stock)stock).GetForward(date0, expiry); double y = fwd * moneyness; double x = expiry.Subtract(date0).Days / 365.0; IPoint point = new Point2D(x, y); stock.VolatilitySurface.SetInterpolatedCurve(); ExtendedInterpolatedSurface interpCurve = stock.VolatilitySurface.GetInterpolatedCurve(); interpCurve.Forward = fwd; interpCurve.Spot = Convert.ToDouble(((Stock)stock).Spot); var vol = interpCurve.Value(point); return(vol); }
public void ChangeStockPrice(IStock stock, double newPrice) { var stockKvp = _stockIndex.Where(s => s.Key.Name == stock.Name) .Select(s => s) .FirstOrDefault(); var eventMessage = new StockPriceChangedEventMessage() { NewPrice = newPrice, OldPrice = stockKvp.Value, Stock = stock, }; _stockIndex[stockKvp.Key] = newPrice; StockPriceChangedEvent?.Invoke(this, eventMessage); }
public void TestExtrapolate1() { IStock stockASXParent = LoadStock("AGK"); IStock stockASXChild = LoadStock("ANZ"); IStock stockSDParent = LoadStock("AGK"); IVolatilitySurface child = CreateTestVolSurface(); ExtrapolationHelper extrapHelper = new ExtrapolationHelper(); if (stockASXParent.VolatilitySurface.Expiries[0].Strikes[0].InterpModel.GetType() == typeof(WingInterp)) { extrapHelper.DoExtrap(stockASXParent, stockASXChild, stockSDParent, child); Assert.AreEqual(Convert.ToDouble(child.NodalExpiries[0].Strikes[0].Volatility.Value), 0.295126142, 0.0001); } }
/// <summary> /// 检查高库存预警状态 /// </summary> /// <param name="wareHouse"></param> /// <returns></returns> public bool CheckStockHighWarning(string wareHouse) { bool result = false; string condition = string.Format("WareHouse='{0}' ", wareHouse); IStock dal = baseDal as IStock; List <StockInfo> stockList = dal.Find(condition); foreach (StockInfo info in stockList) { if (info.HighWarning > 0 && info.StockQuantity >= info.HighWarning) { result = true; } } return(result); }
/// <summary> /// Adds the subsidiary. /// </summary> /// <param name="stock">The stock.</param> /// <example> /// <code> /// // Adds the AMP subsidiary stock to the BHP lead stock instance /// IStock stock = new Stock("123", "BHP"); /// LeadStock lead = new LeadStock("456", "AMP"); /// lead.AddSubsidiary(stock); /// </code> /// </example> public void AddSubsidiary(IStock stock) { // 1. Ensure that parent/child expiries are not duplicated // 2. Ensure that furthest child expiry does not extend beyond furthest observable parent //StockHelper.CheckChildExpiriesWellDefined(this, stock); IStock matchedStock = FindSubsidiary(stock); if (matchedStock == null) { _subsidiaries.Add(stock); } else { throw new DuplicateNotAllowedException($"Stock with Asset Id {stock.AssetId} already exists"); } //StockHelper.CheckChildStrikesWellDefined(this, stock); }
static void Main(string[] args) { string market = Properties.Settings.Default.Market; string className = $"AbstractFactory.{market}Factory"; IFactory factory = (IFactory)Assembly.Load("AbstractFactory").CreateInstance(className); IStock stock = factory.CreateStock(); stock.Buy(); stock.Sell(); IFund fund = factory.CreateFund(); fund.Buy(); fund.Sell(); Console.Read(); }
public OrderFunctions(string Constring, IOrderFunctions testOrderFunctions, IAdminProductFunctions testProductFunctions, IStockFunctions testStockFunctions, IStock testStock) { if (testOrderFunctions != null || testProductFunctions != null) { IOrderFunctions = testOrderFunctions; ProductFunctions = testProductFunctions; StockFunctions = testStockFunctions; Stock = testStock; } else { ConnectionString = Constring; IOrderFunctions = Factory.Factory.CreateIOrderFunctions(Constring); Stock = Factory.Factory.CreateIStock(Constring); ProductFunctions = null; StockFunctions = null; } }
public void UpdateMarketPrice(String symbol, Decimal price) { try { if (price <= Decimal.Zero) { throw new ArgumentOutOfRangeException("price", "Price cannot be zero or lower"); } IStock stock = GetStock(symbol); stock.MarketPrice = price; } catch (Exception ex) { Logger.LogError(Logging.Events.UPDATE_MARKET_PRICE, ex, "Failure updating market price"); throw new Exception("Failure updating market price", ex); } }
public MyClassNodaTime( IStock stock, IMarketDay marketDay, IClock clock) { Stock = stock; MarketDay = marketDay; CreatedOn = clock.Now; if (marketDay.Date.InUtc().Date == CreatedOn.InUtc().Date) { DoThing1(); } else { DoThing2(); } }
/// <summary> /// Does the extrap. /// </summary> /// <param name="asxParent">The ASX parent.</param> /// <param name="asxChild">The ASX child.</param> /// <param name="sdParent">The SD parent.</param> /// <param name="child">The child.</param> public void DoExtrap(IStock asxParent, IStock asxChild, IStock sdParent, IVolatilitySurface child) { //foreach expiry in child, interpolate ratio at ASX parent, child and interpolate SD Parent and apply to SD Parent. foreach (ForwardExpiry exp in child.NodalExpiries) { foreach (Strike str in exp.Strikes) { if (!str.VolatilityHasBeenSet) { double moneyness = str.StrikePrice / Convert.ToDouble(exp.FwdPrice); double parentVol = GetVolAt(sdParent, exp.ExpiryDate, moneyness); double scalingFactor = CalcExtrapFactor(asxParent, asxChild, exp.ExpiryDate); IVolatilityPoint vp = new VolatilityPoint(); vp.SetVolatility(Convert.ToDecimal(parentVol * scalingFactor), VolatilityState.Default()); str.SetVolatility(vp); } } } }
public void buyStock(int amount, IStock stock) { if (amount < 0) { return; } int bought = stock.Buy(amount); //see if stock exsists: foreach (var VARIABLE in StockList) { if (VARIABLE.Name == stock.Name) { VARIABLE.AvailibleAmount += bought; return; } } StockList.Add(new Stock(stock.Name, stock.Price, bought)); }
/// <summary> /// Checks the child expiries well defined. Obsolete. /// </summary> /// <param name="leadStock">The lead stock.</param> /// <param name="childStock">The child stock.</param> public static void CheckChildExpiriesWellDefined(IStock leadStock, IStock childStock) { foreach (ForwardExpiry childExpiry in childStock.VolatilitySurface.Expiries) { var parentExpiries = new List <ForwardExpiry>(leadStock.VolatilitySurface.Expiries); List <ForwardExpiry> matchedExpiries = parentExpiries.FindAll(delegate(ForwardExpiry expiryItem) { // Time between parent and child TimeSpan span = childExpiry.ExpiryDate - expiryItem.ExpiryDate; //For each child we should find a mapping expiry i.e matchesPerExpiry = 1 return(Math.Abs(span.Days) <= CExpiryProximityDays); } ); if (matchedExpiries.Count != 1) { throw new IncompleteLeadSurfaceException("Not all child expiries map 1:1 to a parent"); } } }
public Decimal GetPERatio(String symbol) { try { IStock stock = GetStock(symbol); if (stock.LastDividendPrice == 0) { throw new Exception("Cannot calculate a P/E ratio when the last dividend price was zero"); } return(Math.Round(stock.MarketPrice / stock.LastDividendPrice, 1)); } catch (Exception ex) { Logger.LogError(Logging.Events.GET_PERATIO_YIELD, ex, "Failure calculating the P/E ratio"); throw new Exception("Failure calculating the P/E ratio", ex); } }
/// <summary> /// Populates the historical vols. /// </summary> /// <param name="leadStock">The lead stock.</param> /// <param name="childStock">The child stock.</param> /// <param name="child">The child.</param> public void PopulateHistoricalVols(IStock leadStock, IStock childStock, IVolatilitySurface child) { decimal scalingFactor = GetHistoricalScalFactor(leadStock, childStock); foreach (ForwardExpiry exp in child.NodalExpiries) { foreach (Strike str in exp.Strikes) { if (!str.VolatilityHasBeenSet) { double moneyness = str.StrikePrice / Convert.ToDouble(exp.FwdPrice); double parentVol = GetVolAt(leadStock, exp.ExpiryDate, moneyness); IVolatilityPoint vp = new VolatilityPoint(); vp.SetVolatility(Convert.ToDecimal(parentVol) * scalingFactor, VolatilityState.Default()); str.SetVolatility(vp); } } } }
public void GetResult_ShouldReturnStock_WithSameBasicProperties_AsStockEntity() { /* ARRANGE */ StockEntity basicProps = new StockEntity { Id = 111, ProductId = 222, Amount = 300, Date = DateTime.Now }; SetBasicPropertiesInMockStockEntity(basicProps); SetupMockDomainFactoryToReturnStock(); /* ACT */ StockConverter builder = CreateStockBuilderWithMocks(); IStock stock = builder.Convert(basicProps, (a, b) => { }); /* ASSERT */ Assert.AreEqual(stock.Id, basicProps.Id); Assert.AreEqual(stock.ProductId, basicProps.ProductId); Assert.AreEqual(stock.Amount, basicProps.Amount); Assert.AreEqual(stock.Date, basicProps.Date); }
public void TestGetVol() { IStock stockASXParent = LoadStock("AGK"); ExtrapolationHelper extrapHelper = new ExtrapolationHelper(); double vol0 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 0.05); double vol1 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 0.60); double vol2 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 0.80); double vol3 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 1.00); double vol4 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 2.00); double vol5 = extrapHelper.GetVolAt(stockASXParent, new DateTime(2009, 9, 16), 3.00); //Extrap below Assert.AreEqual(0.6413, vol0, 0.001); Assert.AreEqual(0.5950, vol1, 0.001); Assert.AreEqual(0.3545, vol2, 0.001); Assert.AreEqual(0.2962, vol3, 0.001); Assert.AreEqual(0.3765, vol4, 0.001); //Extrap above Assert.AreEqual(0.3765, vol5, 0.001); }
private void OrderStockFromSupplier(IStock stock) { if (stock.ResponsibleEmployee.Responsibilities.Contains(ResponsibilityType.BuyPartForWarehouse) || stock.ResponsibleEmployee.Responsibilities.Contains(ResponsibilityType.WorkInWarehouse) || stock.ResponsibleEmployee.Responsibilities.Contains(ResponsibilityType.Manage)) { IOrderStock orderStock = factory.CreateOrderStock(stock.ResponsibleEmployee, stock.Supplier, stock); this.warehouse.AddStockToWarehouse(stock, stock.ResponsibleEmployee); } else { throw new ArgumentException( $"Employee {stock.ResponsibleEmployee.FirstName} {stock.ResponsibleEmployee.LastName} does not have the required repsonsibilities to register asset {stock.Name}"); } Console.WriteLine( $"{stock.Name} ordered from {stock.Supplier.Name} for the amount of {stock.PurchasePrice} are stored in the Warehouse." + Environment.NewLine + $"Employee responsible for the transaction: {stock.ResponsibleEmployee.FirstName} {stock.ResponsibleEmployee.LastName}"); }
public ParserB(String formula, IStock _stock) { stock = _stock; Regex r = new Regex("([<>=])"); m_formula = r.Split(formula); int count = 0; foreach (String s in m_formula) { if (s == "") { count++; } } String[] temp = new String[m_formula.Length - count]; int countOfTemp = 0; for (int i = 0; i < m_formula.Length; i++) { if (m_formula[i] != "") { temp[countOfTemp] = m_formula[i]; countOfTemp++; } } m_formula = temp; //test //foreach(string i in m_formula) //Console.WriteLine(i); }
public StockViewModel(IStock stock) { _stock = stock; _stockDataManager = Composition.Compose<IStockDataManager>(); _settingsModel = Composition.Compose<ISettingsModel>(); }
public SyncDataProgressEventArgs(IStock stock, int index, int count) { Progress = new SyncDataProgress(stock, index, count); }
public void CreateStock(IStock stock) { _factory.StockRepository.Create(stock); }
public SyncDataProgress(IStock stock, int index, int count) : base(index, count) { Stock = stock; }
/// <summary> /// Dispatch event /// </summary> /// <param name="stock"></param> /// <param name="index"></param> /// <param name="count"></param> private void OnSyncDataProgressEvent(IStock stock, int index, int count) { if (SyncDataProgressEvent != null) { SyncDataProgressEvent(new SyncDataProgressEventArgs(stock, index, count)); } }
public void UpdateStock(IStock stock) { _factory.StockRepository.Update(stock); _factory.StockHistoryRepository.Add(new Model.StockHistory() { StockId = stock.ID, IsEod = false, ObservationTime = DateTime.Now, Price = stock.LastPrice }); }
public void Create(IStock entity) { dbContext.Stocks.Add(Mapper.Map<IStock, Data.Stock>(entity)); dbContext.SaveChanges(); }
public void Update(IStock entity) { Stock dbStock = dbContext.Stocks.Where(s => s.ID == entity.ID).FirstOrDefault(); dbStock.LastPrice = entity.LastPrice; dbStock.Symbol = entity.Symbol; dbStock.CompanyName = entity.CompanyName; dbContext.SaveChanges(); }
public void AddStock(IStock s) { if (s == null && s.StockSymbol == null || s.StockSymbol.Equals("")) throw new ArgumentException(); stocks.Add(s.StockSymbol, s); }