public float BuyStock(StockType stockType, int quantity, bool isRequiresCash = true) { var stockDatum = stockDataList.FirstOrDefault(x => x.StockType == stockType); // check that we can buy this amount if (isRequiresCash && stockDatum.SharePrice * quantity > GameManager.Instance.Cash) { Debug.LogError(string.Format("Attempting to buy {0} shares of: {1} at price: {2}. Not enough Current Cash: {3}", quantity, stockType.name, stockDatum.SharePrice, GameManager.Instance.Cash)); return(0); } float stockValue = 0; if (stockDatum == null) { Debug.LogError(string.Format("Could not find stocktype: '{0}' in current list", stockType.name)); } else { stockValue = stockDatum.BuyShares(quantity); } if (isRequiresCash) { GameManager.Instance.OnCashChanged(-stockValue); } stockListings.ForEach(x => x.RefreshText()); return(stockValue); }
public int Save(StockType _model) { StockType _stockType = _context.StockTypes.Where(s => s.StockTypeID == _model.StockTypeID).FirstOrDefault(); if (_stockType == null) { StockType _stockType1 = _context.StockTypes.Where(s => (s.Code == _model.Code || s.Name == _model.Name) && s.Parent == _model.Parent).FirstOrDefault(); if (_stockType1 != null) { _model.Enabled = true; } else { _context.StockTypes.Add(_model); } } else { _stockType.Name = _model.Name; _stockType.Code = _model.Code ?? _stockType.Code; _stockType.Parent = _model.Parent ?? _stockType.Parent; _stockType.PurchaseType = _model.PurchaseType ?? _stockType.PurchaseType; _stockType.Enabled = _model.Enabled; } _context.SaveChanges(); return(_model.StockTypeID); }
public StockManager(StockType sType) { stockInfos.Clear(); if (sType == StockType.SH) stockInfos.AddRange(StockInfo.GetSHStockCodes()); if (sType == StockType.SZ) stockInfos.AddRange(StockInfo.GetSZStockCodes()); LimitPrice = 20.0M; }
/// <summary> /// 입출고재고현황기록을 데이터베이스에 저장하고 재고현황수량에서 가감하여 재고현황을 반영한다. /// </summary> /// <param name="date"></param> /// <param name="spec"></param> /// <param name="count"></param> /// <param name="seller"></param> /// <param name="eep"></param> /// <param name="warehouse"></param> /// <param name="remark"></param> public InOutStock Save(StockType type, DateTime date, Specification spec, int count, Seller seller, Employee eep, Warehouse warehouse, string remark) { _InOutStock.StockType = type; _InOutStock.SpecificationUUID = spec.UUID; _InOutStock.Date = date; _InOutStock.ItemCount = count; _InOutStock.EnterpriseUUID = seller.UUID; _InOutStock.EmployeeUUID = eep.UUID; _InOutStock.WarehouseUUID = warehouse.UUID; _InOutStock.Remark = remark; IIndexQuery<Inventory, string> queryResult = null; using (var db = DatabaseDirector.GetDbInstance()) { queryResult = db.Table<Inventory>().IndexQueryByKey("SpecificationUUID", spec.UUID); } Inventory stockItem = queryResult.Count() == 0 ? new Inventory() { SpecificationUUID = spec.UUID, WarehouseUUID = warehouse.UUID } : queryResult.ToList().First(); switch (_InOutStock.StockType) { case StockType.IN: stockItem.ItemCount += count; break; case StockType.OUT: stockItem.ItemCount -= count; break; } stockItem.Save<Inventory>(); return _InOutStock.Save<InOutStock>(); }
public Stock(string name, Table limbAttributes) { Name = name; LimbAttritbutes = limbAttributes; Type = DoubleToStockType(GetLimbAttributeValue("stocktype")); InitBodyParts(); }
/// <summary> /// 一次性爬單支股票的資料,爬股價爬到現在這個月 /// </summary> /// <param name="stockNo">股票編號</param> /// <param name="stockType">股票類型</param> /// <param name="from">輸入從哪年哪月開始爬</param> /// <param name="skipByMonth">若當月資料庫內已有資料,是否跳過(如果月中爬過的話,下次要爬那個月必須為false,否則會跳過那個月)</param> public async Task OneTimeCrawler(string stockNo, StockType stockType, DateTime from, bool skipByMonth = false) { var utcNow = DateTime.UtcNow; var twNow = utcNow.AddHours(8); await OneTimeCrawler(stockNo, stockType, from, twNow, skipByMonth); }
void ICollectionModification <StockType> .Update(StockType entity) { var modified = this.StockTypes.First(st => st.Id == entity.Id); modified.Name = entity.Name; modified.Cost = entity.Cost; }
/// <summary> /// Initializes a new instance of the <see cref="StockEntry" /> class. /// </summary> /// <param name="owner"> /// The mod that has requested this stock entry. /// </param> /// <param name="stockType"> /// The stock type. /// </param> /// <param name="id"> /// The id. /// </param> /// <param name="checkDelegate"> /// The check delegate. /// </param> /// <param name="price"> /// The price. /// </param> /// <param name="stock"> /// The stock. /// </param> public StockEntry( Mod owner, StockType stockType, int id, ShopUtilities.CheckIfAddShopStock checkDelegate, int price = 0, int stock = ShopUtilities.Infinite) { this.Owner = owner; if (stockType == StockType.Item) { this.ItemId = id; } else if (stockType == StockType.BigCraftable) { this.BigCraftableId = id; } else { this.ItemId = id; } this.CheckDelegate = checkDelegate; this.Price = price; this.Stock = stock; }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] StockType stockType) { if (id != stockType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(stockType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StockTypeExists(stockType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(stockType)); }
private void AddToDb <T>(object sender, DataUpdatedArgs args, StockType st) where T : StockBase { logger.Info("Adding to DB with stocktype=" + st.ToString()); var stocksValues = args.Values; foreach (var stockAnsiToValues in stocksValues) { if (st == StockType.RT) { StockRT stock = new StockRT(stockAnsiToValues.Value); logger.Debug("Adding stock with type RT with stockname=" + stockAnsiToValues.Key); this.stocks[stockAnsiToValues.Key].Tables.RT.Add(stock); } else if (st == StockType.Daily) { StockDaily stock = new StockDaily(stockAnsiToValues.Value); logger.Debug("Adding stock with type Daily with stockname=" + stockAnsiToValues.Key); this.stocks[stockAnsiToValues.Key].Tables.Daily.Add(stock); } else { logger.Error("Unknown stock type while trying to enter data to DB"); throw new Exception("Unknown stock type"); } this.stocks[stockAnsiToValues.Key].Tables.SaveChanges(); } }
public static StockInfo Get(StockType stockType, int id) { switch (stockType) { case StockType.stTeam: return(TeamList.FirstOrDefault(t => t.id == id)); case StockType.stCountry: return(CountryList.FirstOrDefault(t => t.id == id)); case StockType.stDriver: return(DriverList.FirstOrDefault(t => t.id == id)); case StockType.stTrack: return(TrackList.FirstOrDefault(t => t.id == id)); case StockType.stSurface: return(SurfaceList.FirstOrDefault(t => t.id == id)); case StockType.stPenalty: return(PenaltyList.FirstOrDefault(t => t.id == id)); case StockType.stInfringment: return(InfringmentList.FirstOrDefault(t => t.id == id)); case StockType.stSessionType: return(SessionTypeList.FirstOrDefault(t => t.id == id)); default: return(null); } }
public ICollection<Package> PackageTypesList(StockType packageType) { var result = from p in Packages.Include(c => c.Medication).Include(p => p.DistributionCenter) where p.StockStatus == packageType select p; return result.ToList(); }
public Stock(string symbol, double lastDividend, double parValue, StockType stockType = StockType.Common, double?fixedDividend = null) { if (IsNullOrEmpty(symbol) || IsNullOrWhiteSpace(symbol)) { throw new ArgumentException("Symbol can't be empty", nameof(symbol)); } if (lastDividend < 0) { throw new ArgumentOutOfRangeException(nameof(lastDividend), "last dividend value can not be negative"); } if (fixedDividend.HasValue && fixedDividend.Value < 0) { throw new ArgumentOutOfRangeException(nameof(fixedDividend), "fixed dividend value can not be negative"); } if (parValue < 0) { throw new ArgumentOutOfRangeException(nameof(parValue), "par value can not be negative"); } Symbol = symbol; LastDividend = lastDividend; FixedDividend = fixedDividend; ParValue = parValue; Type = stockType; }
public void Update(StockType entity) { var modified = StockTypes.First(st => st.Id == entity.Id); modified.Name = entity.Name; modified.Cost = entity.Cost; }
public void ShouldThrowExceptionIfStockCantBeSelled() { StockType stockType = new StockType() { Name = "TestType", Cost = 100 }; Stock stock = new Stock() { Type = stockType }; Client buyer = new Client() { Name = "Dummy1", Balance = 100 }; Client seller = new Client() { Name = "Dummy2", Balance = 0 }; Deal deal = new Deal() { Seller = seller, Buyer = buyer, Stock = stock, Sum = stock.Type.Cost }; buisnessService.NewDeal(deal); }
public async Task <OfferListContainer> GetLVBOrFBBInventory(int page = 1, StockType stockType = StockType.None, StockAmount stockAmount = StockAmount.None, string quantityRange = null, string query = null) { var queryParameters = new Dictionary <string, string>() { { "page", page.ToString() } }; if (stockType != StockType.None) { queryParameters.Add("state", stockType.ToString().ToUpper()); } if (stockAmount != StockAmount.None) { queryParameters.Add("stock", stockAmount.ToString().ToUpper()); } if (quantityRange != null) { queryParameters.Add("quantity", quantityRange); } if (query != null) { queryParameters.Add("query", query); } var response = await Get("/inventory", queryParameters).ConfigureAwait(false); return(await BolApiHelper.GetContentFromResponse <OfferListContainer>(response).ConfigureAwait(false)); }
public void ShouldMoveClientToBlackZoneAfterDeal() { StockType stockType = new StockType() { Name = "TestType", Cost = 150 }; Stock stock = new Stock() { Type = stockType }; Client buyer = new Client() { Name = "Dummy1", Balance = 100 }; Client seller = new Client() { Name = "Dummy2", Balance = 0 }; seller.ClientStocks.Add(stock); Deal deal = new Deal() { Seller = seller, Buyer = buyer, Stock = stock, Sum = stock.Type.Cost }; buisnessService.NewDeal(deal); Assert.AreEqual(Zone.Black, buyer.ClientZone); }
public void ShouldAddAndSaveDeal() { StockType stockType = new StockType() { Name = "TestType", Cost = 100 }; Stock stock = new Stock() { Type = stockType }; Client buyer = new Client() { Name = "Dummy1", Balance = 100 }; Client seller = new Client() { Name = "Dummy2", Balance = 0 }; seller.ClientStocks.Add(stock); Deal deal = new Deal() { Seller = seller, Buyer = buyer, Stock = stock, Sum = stock.Type.Cost }; buisnessService.NewDeal(deal); Received.InOrder(() => { dataContextRepository.Received(1).Add(Arg.Any <Deal>()); dataContextRepository.Received(1).SaveChanges(); }); }
public void SetUpStockType(StockType stockType) { this.stockType = stockType; sr.color = stockType.Color; nameText.text = stockType.name; gameObject.SetActive(true); }
public async Task <StockType> AddStockTypeAsync(StockType stockType) { _context.Create(stockType); await _context.CommitAsync(); return(stockType); }
public StockTypeRepositoryFixture() { MockStockTypeService = new Mock <IStockTypeService>(); StockTypes = new List <StockType> { new StockType { Id = 1, Type = "Grocery", Description = "" }, new StockType { Id = 2, Type = "Beverage", Description = "" } }; CreateStockTypeDto = new CreateStockTypeDto { Type = "Office", Description = "" }; CreatedNewStockType = new StockType { Id = 3, Type = CreateStockTypeDto.Type, Description = CreateStockTypeDto.Description }; EditStockTypeDto = new EditStockTypeDto { Type = "Beverage", Description = "Drinks items" }; }
private int GetStockType(StockType objectName) { int _result = 0; try { if (objectName == StockType.Good) { _result = 1; } else if (objectName == StockType.Bad) { _result = 2; } else { _result = 0; } } catch (Exception ex) { Tracing.Tracer.LogError(" Module = InventoryTransferAction " + ex.ToString()); } return(_result); }
public ActionResult AuditPackage(Package pack, string actionType) { if (Request.Form["SearchBarcode"] != null) { return(View(packageServies.CheckIfBarcodeExist(pack.Barcode, null))); } else if (Request.Form["AuditFeature"] != null) { StockType stockType = StockType.InStock; if (actionType.CompareTo("InStock") == 0) { stockType = StockType.InStock; } if (actionType.CompareTo("Discard") == 0) { stockType = StockType.Discarded; } if (actionType.CompareTo("Lost") == 0) { stockType = StockType.Lost; } if (actionType.CompareTo("Remove") == 0) { packageServies.RemovePackage(pack.Barcode); } else { packageServies.UpdatePackageStatus(WebSecurity.CurrentUserId, pack.Barcode, stockType, null); } } return(View()); }
public void CreateNewStockSucess( StockType typeIn, decimal priceIn, int quantityIn, string nameIn, decimal totalMarketValueIn, StockType typeOut, string nameOut, decimal priceOut, int quantityOut, decimal marketValueOut, decimal transitionCostOut, decimal stockWeightOut, bool nameHighlightedOut) { var stock = new StockModel() { Type = typeIn, Price = priceIn, Quantity = quantityIn, Name = nameIn, TotalMarketValue = totalMarketValueIn }; var result = new StockItem(_eventAggregatorMock.Object, stock); Assert.That(result.Type, Is.EqualTo(typeOut)); Assert.That(result.Price, Is.EqualTo(priceOut)); Assert.That(result.Quantity, Is.EqualTo(quantityOut)); Assert.That(result.Name, Is.EqualTo(nameOut)); Assert.That(result.MarketValue, Is.EqualTo(marketValueOut)); Assert.That(result.TransitionCost, Is.EqualTo(transitionCostOut)); Assert.That(Math.Round(result.StockWeight, 2), Is.EqualTo(stockWeightOut)); Assert.That(result.NameHighlighted, Is.EqualTo(nameHighlightedOut)); }
public void ShouldChangeClientsBalanceAndStockListsAfterDeal() { StockType stockType = new StockType() { Name = "TestType", Cost = 100 }; Stock stock = new Stock() { Type = stockType }; Client buyer = new Client() { Name = "Dummy1", Balance = 100 }; Client seller = new Client() { Name = "Dummy2", Balance = 0 }; seller.ClientStocks.Add(stock); Deal deal = new Deal() { Seller = seller, Buyer = buyer, Stock = stock, Sum = stock.Type.Cost }; buisnessService.NewDeal(deal); Assert.AreEqual(0, buyer.Balance); Assert.AreEqual(100, seller.Balance); Assert.AreEqual(1, buyer.ClientStocks.Count); }
public StockDTO CreateNewStock(StockType type, decimal price, int quantity) { string namePrefix; if (type == StockType.Equity) { namePrefix = "Equity"; } else { namePrefix = "Bond"; } Stock stock = new Stock { Name = namePrefix + (repository.Count(x => x.Type == type) + 1), Type = type, Price = price, Quantity = quantity }; repository.Insert(stock); return(ConvertToDTOList(new List <Stock> { stock })[0]); }
private string GetStockType(StockType _locStockType) { string _result = null; try { if (_locStockType == StockType.Good) { _result = "Good"; } else if (_locStockType == StockType.Bad) { _result = "Bad"; } else { _result = "None"; } } catch (Exception ex) { Tracing.Tracer.LogError("Business Object = Location ", ex.ToString()); } return(_result); }
public ICollection<Package> PackageByCenter(int centerID, StockType packageType) { var result = from p in Packages.Include(c => c.Medication) where p.DistributionCenterID == centerID && p.StockStatus == packageType select p; return result.ToList(); }
/// <summary> /// This is the Stock class constructor /// </summary> /// <param name="sto">Stock Symbol (to identify stock)</param> /// <param name="typ">Stock Type (Common or Preferred)</param> /// <param name="las">Last Dividend</param> /// <param name="fix">Fixed Dividend</param> /// <param name="par">Par Value</param> public Stock(string sto, StockType typ, double las, double?fix, double par) { this.SetStockSymbol(sto); this.SetStockType(typ); this.SetLastDividend(las); this.SetFixedDividend(fix); this.SetParValue(par); }
private static void SelectStocks(StockType sType) { //2016 - 02 - 13 var mgr = new StockManager(sType); mgr.LimitPrice = 30.0M; mgr.OutputGoldFork(string.Format(@"D:\output gold fork for {0}.dat", sType.ToString())); mgr.OutputAbove181(string.Format(@"D:\output 181 for {0}.dat", sType.ToString())); }
public ICollection<Package> PackageByUser(int userID, StockType packageType) { var result = from p in Packages.Include(c => c.Medication) where p.UserId == userID && p.StockStatus == packageType select p; return result.ToList(); }
public ICollection <Package> PackageTypesList(StockType packageType) { var result = from p in Packages.Include(c => c.Medication).Include(p => p.DistributionCenter) where p.StockStatus == packageType select p; return(result.ToList()); }
public static float TruncateToAllowedVolume(this float volume, StockType stockType) { if (stockType == StockType.InvestmentFund) { return(volume); } return((float)Math.Floor(volume)); }
public ActionResult DeleteConfirmed(int id) { StockType stockType = db.StockTypes.Find(id); db.StockTypes.Remove(stockType); db.SaveChanges(); return(RedirectToAction("Index")); }
public float AddTicks(StockType stockType, DateTime ts, float value, int ticks) { if (stockType == StockType.Undefined) { return(value); } return(value + (float)(GetTickSize(stockType, ts, (decimal)value) * ticks)); }
private decimal ExecuteUpDown(Func <decimal, decimal> alignOp, StockType stockType, DateTime ts, decimal value) { if (stockType == StockType.Undefined) { return(value); } return(AlignValue(alignOp, value, GetTickSize(stockType, ts, value), MinValue(stockType))); }
public Stock(string symbol, StockType type, decimal lastDividend, decimal fixedDividend, decimal parValue) { Symbol = symbol; Type = type; LastDividend = lastDividend; FixedDividend = fixedDividend; ParValue = parValue; }
/// <summary> /// Update the package status /// If the value is 0, no update will take place /// </summary> /// <param name="barCode"></param> /// <param name="stockType"></param> /// <param name="receivingCenterID"></param> /// <param name="distributionCenterID"></param> public void UpdatePackageStatus(int userID,int barCode,StockType stockType, int? receivingCenterID, int? distributionCenterID) { var pack = Packages.SingleOrDefault(Package => Package.Barcode == barCode); if (receivingCenterID != 0) { pack.ReceivingCenterID = receivingCenterID; } pack.UserId = userID; //Always put the userID of current logged in user pack.DistributionCenterID = distributionCenterID; //Always put the distribution Center ID of current user pack.StockStatus = stockType; SaveChanges(); }
public Package CheckIfPackageExist(int barCode, StockType? stockType) { var pack = new Package(); if (stockType != null) { pack = Packages.SingleOrDefault(Package => Package.Barcode == barCode && Package.StockStatus == stockType); } else { pack = Packages.SingleOrDefault(Package => Package.Barcode == barCode); } return pack; }
public Stock() { m_Name = string.Empty; m_Number = string.Empty; m_Type = StockType.Observed; m_BuyPrice = 0; m_SellPrice = 0; m_ObservedPrice = 0; m_CurrentPrice = 0; m_ExpectBuyPrice = 0; m_ExpectSellPrice = 0; m_AlgType = AlgorithmType.DefinedPrice; }
public static List<StockInfo> GetStocksFor(string stockCodePosition, StockType stockType) { var stocks = new List<StockInfo>(); using (var sr = new StreamReader(stockCodePosition)) { while (!sr.EndOfStream) { var line = sr.ReadLine(); var items = line.Split(new char[] {' '}); var aStockInfo = new StockInfo(); aStockInfo.Name = items[0]; aStockInfo.Symbol = items[1]; aStockInfo.StockType = stockType; stocks.Add(aStockInfo); } } return stocks; }
public StockCollaborator() { Summary = new SummaryCollectionViewSource(); Summary.SourceChanged += Summary_SourceChanged; Transaction = new TransactionStockViewSource(); Transaction.SourceChanged += Transaction_SourceChanged; InitializeRange(); stockTypeSync = StockType.All; RefreshCommand = ReactiveCommand.CreateAsyncTask(async _ => { stockTypeSync = StockType.Summary; await OnRefresh(); }); SearchCommand = new DelegateCommand(new Action(OnSearch)); RefreshCommand.Execute(null); SelectedRange = Range.SingleOrDefault(x => x.Id == "3"); }
private void Transaction_SourceChanged(object sender, EventArgs e) { stockTypeSync = StockType.Transaction; Pull(); }
private void Summary_SourceChanged(object sender, EventArgs e) { stockTypeSync = StockType.Summary; Pull(); }
private static Stock GetSampleStock(double price, string symbol, StockType type, double lastDividend, double? fixedDividend, double parValue) { return new Stock { Price = price, Symbol = symbol, Type = type, LastDividend = lastDividend, FixedDividend = fixedDividend, ParValue = parValue }; }
/// <summary> /// Search package with given barcode and the given stock type /// </summary> /// <param name="barCode">Barcode of Package to be found</param> /// <param name="stockType">Package should have given status</param> /// <returns></returns> public Package CheckIfBarcodeExist(int barCode, StockType? stockType) { return packageDao.CheckIfPackageExist(barCode,stockType); }
public void UpdatePackageStatus(int userID, int barCode, StockType stockType, int? receivingCenterID) { int currentCenterID = employeeLoginDao.GetEmployeeLoginDetail(userID).DistributionCenterID; packageDao.UpdatePackageStatus(userID, barCode, stockType, receivingCenterID, currentCenterID); }
public ObservableCollection<IOStockWrapper> NewPipe(StockType type) { return new ObservableCollection<IOStockWrapper>(_ioDic[type]); }