Exemple #1
0
        public async Task <StockChartModel> GetRealTimeTradeChartAsync(StockInfoItem stockItem)
        {
            TwseStockClient client = new TwseStockClient();
            var             resutl = await client.QueryRealTimeTradeChartAsync(stockItem.Convert());

            return(resutl);
        }
Exemple #2
0
        public async Task <List <RealTimeStockItem> > GetMultipleRealTimeStockAsync(List <StockInfoItem> stockList)
        {
            // hard code to display taiwan tse stock
            stockList.Insert(0, new StockInfoItem {
                Id = "t00", MarketType = "上市"
            });


            SessionData session = await GetSession();

            List <StockInfoModel> queryStockList = stockList.Convert();

            List <RealTimeStockModel> results = new List <RealTimeStockModel>();

            try
            {
                TwseStockClient client = new TwseStockClient();
                results = await client.QueryStockAsync(queryStockList, session);
            }
            catch (Exception e)
            {
                Debug.WriteLine(DateTime.Now + " : " + "Cookie time out");
                ReleaseSession();
            }

            return(results.Convert());
        }
Exemple #3
0
 public void QueryExcehangeChartStockAsyncTest()
 {
     TwseStockClient client    = new TwseStockClient();
     var             stockInfo = new StockInfoModel {
         Id = "2345", MarketType = "上市", Name = "智邦"
     };
     var result = client.QueryRealTimeTradeChartAsync(stockInfo).GetAwaiter().GetResult();
 }
Exemple #4
0
        private async Task <SessionData> GetSession()
        {
            //SessionData clientSession;
            if (_clientSession == null)
            {
                await _syncLock.WaitAsync();

                if (_clientSession == null)
                {
                    _clientSession = await TwseStockClient.CreateSessionAsync();
                }
                _syncLock.Release();
            }
            return(_clientSession);
        }
Exemple #5
0
        /// <summary>
        /// Get all of the stock information from TWSE web site
        /// </summary>
        /// <returns></returns>
        public async Task <List <StockInfoItem> > GetAllStockInfoAsync()
        {
            TwseStockClient client    = new TwseStockClient();
            var             stockList = await client.GetAllStockInfoAsync();

            List <StockInfoItem> resultList = new List <StockInfoItem>();

            foreach (var item in stockList)
            {
                resultList.Add(new StockInfoItem
                {
                    Id         = item.Id,
                    Category   = item.Category,
                    MarketType = item.MarketType,
                    Name       = item.Name
                });
            }
            return(resultList);
        }