• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Stock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Stock的典型用法代码示例。如果您正苦于以下问题:C# Stock类的具体用法?C# Stock怎么用?C# Stock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Stock类属于命名空间,在下文中一共展示了Stock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: addTransaction

 public void addTransaction(ApplicationDbContext db, ApplicationUser user, Stock stock, StockTransaction model)
 {
     model.StockTicker = stock.Identifier;
     model.UserId = user.Id;
     db.StockTransactions.Add(model);
     db.SaveChanges();
 }
开发者ID:reaper10567,项目名称:344-Web-Engineering,代码行数:7,代码来源:StockHistoryService.cs


示例2: ReturnsDateOfMostRecentEntry

            public void ReturnsDateOfMostRecentEntry()
            {
                //// SETUP

                // Test Data
                var stock = new Stock { Ticker = "FLWS", CompanyName = "1-800 FLOWERS.COM" };
                var oldest = new HistoricPrice { Stock = stock, Date = DateTime.Parse("1/1/2000") };
                var middle = new HistoricPrice { Stock = stock, Date = DateTime.Parse("1/2/2000") };
                var newest = new HistoricPrice { Stock = stock, Date = DateTime.Parse("1/3/2000") };
                var testData = new List<HistoricPrice> { oldest, newest, middle };

                // Create a mock generic repository.
                var mockGenericRepository = new Mock<IReadOnlyRepository<HistoricPrice>>();
                mockGenericRepository.Setup(mock => mock.FilterBy(It.IsAny<Expression<Func<HistoricPrice, bool>>>())).Returns(testData.AsQueryable());

                // Setup target
                var target = new ReadOnlyPriceHistoryRepository(mockGenericRepository.Object);

                // EXECUTE
                var actual = target.GetMostRecentDateForTicker(stock.Ticker);

                // VERIFY
                Assert.AreEqual(newest.Date, actual);
                mockGenericRepository.Verify(mock => mock.FilterBy(It.IsAny<Expression<Func<HistoricPrice, bool>>>()), Times.Once());
            }
开发者ID:TheLogansFerrySoftwareCo,项目名称:LF-Trading-Suite,代码行数:25,代码来源:ReadOnlyPriceHistoryRepostioryTests.cs


示例3: GetStock

        public Stock GetStock(StockName stockName, DateTime startDate, DateTime endDate)
        {
            string dir = String.Format(@"..\..\StockData\Yahoo");
            string filename = String.Format("{0}.stock", stockName);
            var fullPath = Path.Combine(dir, filename);

            List<IStockEntry> rates;
            if (!File.Exists(fullPath))
            {
                rates = GetStockFromRemote(stockName, startDate, endDate);
                Directory.CreateDirectory(dir);
                using (Stream stream = File.Open(fullPath, FileMode.Create))
                {
                    var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    bformatter.Serialize(stream, rates);
                }

            }
            else
            {
                using (Stream stream = File.Open(fullPath, FileMode.Open))
                {
                    var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    rates = (List<IStockEntry>) bformatter.Deserialize(stream);
                }
            }
            var stock = new Stock(stockName, rates);
            return stock;
        }
开发者ID:ilan84,项目名称:ZulZula,代码行数:29,代码来源:YahooDataProvider.cs


示例4: RunExample

        public void RunExample()
        {
            decimal price = 23.50m;

            Stock stock = new Stock("MSFT", price);
            Console.WriteLine("Stock set to {0:C}.", stock.Price);

            Bidder bidderA = new Bidder("Bidder A", stock);
            Bidder bidderB = new Bidder("Bidder B", stock);
            Bidder bidderC = new Bidder("Bidder C", stock);

            stock.Attach(bidderA);
            stock.Attach(bidderB);
            stock.Attach(bidderC);

            price = 24.25m;
            Console.WriteLine("\nStock set to {0:C}.", price);
            stock.Price = price;

            stock.Detach(bidderB);
            Console.WriteLine("\n{0} detached.", bidderB.Name);

            price = 26.75m;
            Console.WriteLine("\nStock set to {0:C}.", price);
            stock.Price = price;
        }
开发者ID:fase,项目名称:.NET-Patterns,代码行数:26,代码来源:ObserverPattern.cs


示例5: Button2_Click

 protected void Button2_Click(object sender, EventArgs e)
 {
     int id = Convert.ToInt32(DropDownList.SelectedValue);
     int Quantity = Convert.ToInt32(QuantityBox.Text);
     Stock newStock = new Stock(id, Quantity);
     newStock.updateStock(id, Quantity);
 }
开发者ID:Willieodwyer,项目名称:SystemsAnalysis,代码行数:7,代码来源:Stock.aspx.cs


示例6: Init

 public void Init()
 {
     i1 = new StockItem ("BMAC56790", "Propelling Pencil", "Supply Master", "1.49", "10", "20");
     stock_list  = new Stock();
     stock_list.AddStockItem(i1.StockCode, i1);
     stock_control = new StockControl(stock_list);
 }
开发者ID:geekscruff,项目名称:m3app1,代码行数:7,代码来源:TestStockControl.cs


示例7: Main

        static void Main(string[] args)
        {
            Stock stock1 = new Stock("Technology", 160, 5, 15);
             Stock stock2 = new Stock("Retail", 30, 2, 6);
             Stock stock3 = new Stock("Banking", 90, 4, 10);
             Stock stock4 = new Stock("Commodity", 500, 20, 50);

             StockBroker b1 = new StockBroker("Broker 1");
             b1.AddStock(stock1);
             b1.AddStock(stock2);

             StockBroker b2 = new StockBroker("Broker 2");
             b2.AddStock(stock1);
             b2.AddStock(stock3);
             b2.AddStock(stock4);

             StockBroker b3 = new StockBroker("Broker 3");
             b3.AddStock(stock1);
             b3.AddStock(stock3);

             StockBroker b4 = new StockBroker("Broker 4");
             b4.AddStock(stock1);
             b4.AddStock(stock2);
             b4.AddStock(stock3);
             b4.AddStock(stock4);
        }
开发者ID:noel09,项目名称:CECS475-Lab03,代码行数:26,代码来源:StockApplication.cs


示例8: initPublisher

	    private void initPublisher(String pub, int strength)
	    {
		    mgr = new DDSEntityManager("Ownership");
		    String partitionName = "Ownership example";

		    // create Domain Participant
		    mgr.createParticipant(partitionName);
    		
		    // create Type
		    StockTypeSupport stkTS = new StockTypeSupport();
		    mgr.registerType(stkTS);
    		
		    // create Topic
		    mgr.createTopic("OwnershipStockTracker");
    		
		    // create Publisher
		    mgr.createPublisher();
    		
		    // create DataWriter
		    mgr.createWriterWithStrength(strength);
		    dwriter= mgr.getWriter();
            OwnershipDataWriter = dwriter as StockDataWriter;
    		
		    msft = new Stock();
		    msft.ticker = "MSFT";
            msft.publisher = pub;
            msft.strength = strength;
            msftHandle = OwnershipDataWriter.RegisterInstance(msft);
	    }
开发者ID:shizhexu,项目名称:opensplice,代码行数:29,代码来源:OwnershipPublisher.cs


示例9: GetStock

        public Stock GetStock(StockName stockName, DateTime startDate, DateTime endDate)
        {
            string dir = String.Format(@"..\..\StockData\Maya");
            string filename = String.Format("{0}.csv", stockName);
            var fullPath = Path.Combine(dir, filename);

            var rates = new List<IStockEntry>();

            var parser = new TextFieldParser(fullPath) {TextFieldType = FieldType.Delimited};
            parser.SetDelimiters(",");

            //skips the first 3 lines
            parser.ReadFields();
            parser.ReadFields();
            parser.ReadFields();

            while (!parser.EndOfData)
            {
                var fields = parser.ReadFields();
                if (fields != null)
                {
                    StockEntry stockEntry = null;
                    rates.Add(stockEntry);
                }
            }

            rates.Reverse();

            var stock = new Stock(stockName, rates);

            return stock;
        }
开发者ID:ilan84,项目名称:ZulZula,代码行数:32,代码来源:MayaDataProvider.cs


示例10: ReconcileStock

        public ReconcileStock(int _id)
        {
            InitializeComponent();
            id = _id;
            sl = new StockList(id);

            s = sl.ViewAStock(sl[0].StockID);
        }
开发者ID:DirkViljoen,项目名称:eSalon,代码行数:8,代码来源:ReconcileStock.cs


示例11: StockTest

 public StockTest()
 {
     _stock = new Stock("MSFT");
     _stock.CurrentPrice = 5.5m;
     _purchase1 = new StockTransaction(DateTime.Now, 4.0m, 7);
     _purchase2 = new StockTransaction(DateTime.Now.AddDays(-1), 7.5m, 2);
     _sale1 = new StockTransaction(DateTime.Now, 5.0m, -1);
 }
开发者ID:reaper10567,项目名称:344-Web-Engineering,代码行数:8,代码来源:StockTest.cs


示例12: Main

    static void Main()
    {
        Stock x = new Stock();
        x.SetPreviousPrice(5.3);
        Console.WriteLine(x.PreviousPrice); //=5.3

        Console.WriteLine(x.Words[1]); //=quick
    }
开发者ID:CrazySquid1,项目名称:CSharp,代码行数:8,代码来源:Money.cs


示例13: GetFristCol

        public Stock GetFristCol(string data)
        {
            List<Price> prices = new List<Price>();
            List<DataItem> items = new List<DataItem>();
            string firstCol = string.Empty;
            List<string> lines = data.Split('\n').ToList<string>();
            for (int i = 2; i < lines.Count; i++)
            {
                string line = lines[i];
                List<string> numStrs = line.Split(' ').ToList<string>();
                if (numStrs.Count < 5)
                    continue;
                DataItem item = new DataItem();
                Price price = new Price();
                price.content = new string[4];
                for (int numI = 0; numI < numStrs.Count; numI++)
                {
                    if (numI == 0)
                        item.content = numStrs[numI];
                    if (numI > 0 && numI < 5)
                    {
                        price.content[numI-1] = numStrs[numI];
                        if (numI == 3)
                        {
                            price.content[numI-1] = numStrs[numI+1];
                        }
                        if (numI == 4)
                        {
                            price.content[numI - 1] = numStrs[numI-1];
                        }
                    }
                   // if (numI > 0 && numI < 4)

                        //price.content += ",";

                }
                items.Add(item);
                prices.Add(price);
            }
            Stock stock = new Stock();
            stock.price = new Price[prices.Count];
            for (int itemI = 0; itemI < items.Count; itemI++)
            {
                stock.data += items[itemI].content;
                if (itemI != items.Count - 1)
                    stock.data += ",";
            }
            for (int priceI = 0; priceI < prices.Count; priceI++)
            {
                stock.price[priceI] = prices[priceI];   // += "[" + prices[priceI].content + "]";
                //if (priceI != prices.Count - 2)
                //    stock.price += ";";
            }
               // stock.data = "[" + stock.data + "]";
               // stock.price = "[" + stock.price  + "]";
            return stock;
        }
开发者ID:heavenlw,项目名称:Ebank,代码行数:57,代码来源:stockController.cs


示例14: ImportStock

 public void ImportStock(Stock stock)
 {
     using (var context = ContainerHelper.Instance.Resolve<IRepositoryContext>())
     {
         //添加新的股票基础数据
         context.UnitOfWork.RegisterNew<Stock>(stock);
         context.UnitOfWork.Commit();
     }
 }
开发者ID:philfanzhou,项目名称:PredictFuture,代码行数:9,代码来源:ImportStockService.cs


示例15: tstInheritance1

        static void tstInheritance1()
        {
            Stock stock = new Stock { Name = "MSFT", SharesOwned = 1500 };
            House house = new House { Name = "SAS", Mortgage = 2300 };

            stock.Display();
            house.Display();

            //Upcasting
            Stock stock2 = new Stock();
            Asset asset = stock2;

            Console.WriteLine((asset == stock2 ? "asset == stock2!" : "asset != stock2!"));
            //asset.SharesOwned;     - yet Stock fields aren't accessible!!!

            //To access Stock fields DOWNCASTING is needed!!
            Stock stock3 = (Stock) asset;

            Console.WriteLine(stock3.SharesOwned);      // <No error>
            Console.WriteLine(stock3 == asset);         // True
            Console.WriteLine(stock3 == stock2);        // True

            //AS operator
            Asset a = new Asset();
            Stock s = a as Stock; // s is null; no exception thrown

            try {
                long shares1 = ((Stock)a).SharesOwned; // Approach #1
            }
            catch (InvalidCastException ice) {
                Console.WriteLine(ice.ToString());
            }

            if (s != null) {
                Console.WriteLine(s.SharesOwned);
                long shares2 = (a as Stock).SharesOwned; // Approach #2
            }

            /*  
             *  Another way of looking at it is that with the cast operator (Approach #1), you’re
                saying to the compiler: “I’m certain of a value’s type; if I’m
                wrong, there’s a bug in my code, so throw an exception!”
                Whereas with the as operator (Approach #2), you’re uncertain of its type and
                want to branch according to the outcome at runtime.
             * */

            //IS operator
            if (a is Stock)
                Console.WriteLine(((Stock)a).SharesOwned);

            /*
             *  The is operator tests whether a reference conversion would succeed; in other words,
                whether an object derives from a specified class (or implements an interface). It is
                often used to test before downcasting. 
             * */
        }
开发者ID:JohnPaine,项目名称:learning,代码行数:56,代码来源:TestInheritance.cs


示例16: CalculateDividendTest

        public void CalculateDividendTest()
        {
            var stockCommon = new Stock("TEA", StockType.Common, 10, 0, 100);
            var dividendCommon = StockCalculator.CalculateDividend(stockCommon, 100m);
            AssertDiff(0.1m, dividendCommon);

            var stockPreferred = new Stock("TEA", StockType.Preferred, 10, 5, 100);
            var dividendPreffered = StockCalculator.CalculateDividend(stockPreferred, 100);
            AssertDiff(5m, dividendPreffered);
        }
开发者ID:mmihokovic,项目名称:superSimpleStocks-csharp,代码行数:10,代码来源:StockCalculatorTests.cs


示例17: Init

 public void Init()
 {
     i1 = new StockItem ("BMAC56790", "Propelling Pencil", "Supply Master", "1.49", "10", "20");
     i3 = new StockItem ("BMAC56780", "Propelling Pencil", "Supply Master", "1.49", "10", "20");
     i4 = new StockItem ("BMAC56770", "Propelling Pencil", "Supply Master", "1.49", "10", "20");
     stock_list  = new Stock();
     stock_list.AddStockItem(i1.StockCode, i1);
     stock_list.AddStockItem(i3.StockCode, i3);
     stock_list.AddStockItem(i4.StockCode, i4);
 }
开发者ID:geekscruff,项目名称:m3app1,代码行数:10,代码来源:TestStock.cs


示例18: Init

 public void Init()
 {
     i1 = new StockItem ("BMAC56790", "Propelling Pencil", "Supply Master", "1.49", "10", "20");
     stock_list  = new Stock();
     stock_list.AddStockItem(i1.StockCode, i1);
     order_history = new OrderHistory();
     DateTime timestamp = DateTime.Now;
     o1 = new Order (timestamp, i1.StockCode, i1.Supplier, 10, 10);
     order_history.AddOrder (o1);
 }
开发者ID:geekscruff,项目名称:m3app1,代码行数:10,代码来源:TestOrderHistory.cs


示例19: CalculatePeRatioTest

        public void CalculatePeRatioTest()
        {
            var stock = new Stock("TEA", StockType.Common, 10, 0, 100);
            var peRatio = StockCalculator.CalculatePeRatio(stock, 105);
            AssertDiff(10.5m, peRatio );

            var stockWithZeroDividend = new Stock("TEA", StockType.Common, 0, 0, 100);
            var peRatioWithZeroDividend = StockCalculator.CalculatePeRatio(stockWithZeroDividend, 105);
            AssertDiff(0m, peRatioWithZeroDividend);
        }
开发者ID:mmihokovic,项目名称:superSimpleStocks-csharp,代码行数:10,代码来源:StockCalculatorTests.cs


示例20: Buy

        public async Task<IActionResult> Buy(string symbol, int shares)
        {
            var stock = new Stock(symbol);
            stock = await stockInfo.GetQuoteAsync(stock);

            var model = new StockTransaction(DateTime.Now, stock.CurrentPrice.Value, shares);
            stockHistory.addTransaction(_applicationDbContext, await GetCurrentUserAsync(), stock, model);

            return Redirect("/Stocks/SearchStocks?symbol=" + symbol);
        }
开发者ID:reaper10567,项目名称:344-Web-Engineering,代码行数:10,代码来源:StocksController.cs



注:本文中的Stock类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# StockSerie类代码示例发布时间:2022-05-24
下一篇:
C# StkId类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap