Example #1
0
        private List <Stock> GetData(List <string> symbols,
                                     int yearsOfHistory = 1)
        {
            //Thread.Sleep(2000);
            //return null;

            var stocks = new List <Stock>();
            var tasks  = new List <Task>();

            foreach (var symbol in symbols)
            {
                Task task = Task.Factory.StartNew((t_symbol) =>
                {
                    var stock = StockFactory.GetStockData(t_symbol.ToString(),
                                                          yearsOfHistory);
                    stocks.Add(stock);
                }, symbol);

                tasks.Add(task);
            }

            // Wait for all tasks to complete
            Task.WaitAll(tasks.ToArray());
            return(stocks);
        }
 public UsersController(DataBaseContext db)
 {
     _db           = db;
     _stockFactory = new StockFactory();
     _userFactory  = new UserFactory();
     _userRepo     = new UserRepo(db);
     _stockRepo    = new StockRepo(db);
 }
Example #3
0
 public EnclosureObjectUseCase(IEnclosureObjectDataEntity enclosureObjectDataEntity, StockFactory stockFactory,
                               AttackEffectFactory attackEffectFactory, EnclosureSpriteTable enclosureSpriteTable)
 {
     _enclosureObjectDataEntity = enclosureObjectDataEntity;
     _stockFactory         = stockFactory;
     _attackEffectFactory  = attackEffectFactory;
     _enclosureSpriteTable = enclosureSpriteTable;
 }
Example #4
0
        public void InitStock()
        {
            IStockFactory stockFactory = new StockFactory();

            bondStock = stockFactory.CreateStock(AssetType.Bond, price, quantity, 0);
            bondStock.TotalMarketValue = totalFundValue;
            equityStock = stockFactory.CreateStock(AssetType.Equity, price, quantity, 0);
            equityStock.TotalMarketValue = totalFundValue;
        }
Example #5
0
    private void lsEquities_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        int      i  = lsEquities.SelectedIndex;
        Equities eq = (Equities)lsEquities.Items[i];

        mchoice = StockFactory.getBuilder(eq);
        this.Controls.Remove(pnl);
        pnl = mchoice.getWindow();
        setPanel();
    }
Example #6
0
        public void CreateEquityTest()
        {
            var factory = new StockFactory();

            var stock = factory.CreateStock(StockType.Bond, "Equity1", 1500, 500);

            Assert.AreEqual(stock.Price, 1500);
            Assert.AreEqual(stock.Quantity, 500);
            Assert.AreEqual(stock.MarketValue, 1500 * 500);
            Assert.AreEqual(stock.MarketValue, 1500 * 500);
        }
Example #7
0
        public void ShouldCorrectlyCreateEquityObject()
        {
            int    quantity = 1;
            double price    = 2.5;
            string name     = "Equity1";

            var stock = StockFactory.GetStock(quantity, price, name, StockType.Equity);

            Assert.AreEqual(typeof(Equity), stock.GetType());
            Assert.AreEqual(quantity, stock.Quantity);
            Assert.AreEqual(price, stock.Price);
            Assert.AreEqual(name, stock.StockName);
        }
        public void CreateBondTest()
        {
            StockFactory stockFactory = new StockFactory();
            AssetType    type         = AssetType.Bond;
            decimal      price        = 20;
            int          quantity     = 1;
            int          occurence    = 0;
            Stock        s            = stockFactory.CreateStock(type, price, quantity, occurence);

            Assert.AreEqual(s.AssetType, type);
            Assert.AreEqual(s.Price, price);
            Assert.AreEqual(s.Quantity, quantity);
            Assert.AreEqual(s.StockName, type.ToString() + (occurence + 1).ToString());
            Assert.IsTrue(s.GetType() == typeof(Bond));
        }
Example #9
0
        public override ListStocksResponse OnListStocksExecute(ListStocksRequest request)
        {
            var stockFactory = new StockFactory();
            var response     = new ListStocksResponse();

            try
            {
                response.ListStocks = stockFactory.ListStocks(request.ItemCode);
            }
            catch (Exception ex)
            {
                response.Exception = ex;
                response.Message   = ex.Message;
            }

            return(response);
        }
Example #10
0
        private void Start()
        {
            var factory = new StockFactory(new Dictionary <string, Texture2D>()
            {
                { StockTypes.Tech, _placeholderIcon }
            });

            for (int i = 0; i < _numOfStockOptions; i++)
            {
                var stock = Instantiate(_stockPrefab) as GameObject;
                var agent = stock.GetComponent <StockAgent>();
                var model = new SerializableStock <TechStock>()
                {
                    startingValue = 7.5m,
                    marketId      = string.Format("PLA:{0}", i + 1),
                    type          = StockTypes.Tech
                };
                stock.name = model.marketId;
                agent.Initialize(factory.CreateStockModel(model));
                stock.transform.SetParent(_stockListDisplay, false);
            }
        }
Example #11
0
 public IEXContorller()
 {
     _stockFactory = new StockFactory();
 }
        public void AddStock(int quantity, double price, StockType stockType)
        {
            StockList.Add(StockFactory.GetStock(quantity, price, GetNextStockName(stockType), stockType));

            UpdateStockWeight();
        }