public void CoreClassRequestWithoutToken() { TushareProApi pro = new TushareProApi(); Assert.ThrowsExceptionAsync <Exception>(async() => { APIRequest request = new APIRequest() { InterfaceName = "daily", Parameters = new Dictionary <string, string>() { { "ts_code", "603986.SH" }, { "trade_date", "20210305" }, }, Fields = new List <string>() { "open", "high", "low", "close" } }; APIResponse response = await pro.Request(request); }); }
public async Task ShSzStockClassGetShSzHkBasicInfo() { TushareProApi pro = new TushareProApi(TestToken); ShanghaiShenzhenStockApi shSzApi = new ShanghaiShenzhenStockApi(pro); List <Stock> stocks = await shSzApi.BasicInformation(ShSzHkConnect.Shenzhen); Assert.IsTrue(stocks.Count > 0); Console.WriteLine($"Shenzhen-Hongkong connect has {stocks.Count} stocks"); }
public async Task ShSzStockClassGetExchangeBasicInfo() { TushareProApi pro = new TushareProApi(TestToken); ShanghaiShenzhenStockApi shSzApi = new ShanghaiShenzhenStockApi(pro); List <Stock> stocks = await shSzApi.BasicInformation(Exchange.SZSE); Assert.IsTrue(stocks.Count > 0); Console.WriteLine($"SZSE has {stocks.Count} stocks"); }
public async Task ShSzStockClassGetMultiBasicInfo() { TushareProApi pro = new TushareProApi(TestToken); ShanghaiShenzhenStockApi shSzApi = new ShanghaiShenzhenStockApi(pro); List <Stock> stocks = await shSzApi.BasicInformation(ListStatus.Delisting); Assert.IsTrue(stocks.Count > 0); Console.WriteLine($"There are {stocks.Count} delisted stocks"); }
public async Task ShSzStockClassInstanseAndGetBasicInfo() { TushareProApi pro = new TushareProApi(TestToken); ShanghaiShenzhenStockApi shSzApi = new ShanghaiShenzhenStockApi(pro); Stock stockInfo = await shSzApi.BasicInformation("603986.SH"); Assert.AreEqual(stockInfo.Code, "603986"); Assert.AreEqual(stockInfo.Market, Market.Main); }
public async Task ShSzStockClassGetTradeDaysInRangeAndSpecificStatus() { TushareProApi pro = new TushareProApi(TestToken); ShanghaiShenzhenStockApi shSzApi = new ShanghaiShenzhenStockApi(pro); List <TradeDay> tradeDays = await shSzApi.TradeCalendar(Exchange.SZSE, new DateTime(2021, 1, 1), DateTime.Now, TradeStatus.Closing); Assert.IsTrue(tradeDays.Count > 0); foreach (TradeDay day in tradeDays) { Console.WriteLine(day); } }
public async Task ShSzStockClassGetStockCompanyManagerRewards() { TushareProApi pro = new TushareProApi(TestToken); ShanghaiShenzhenStockApi shSzApi = new ShanghaiShenzhenStockApi(pro); List <StockCompanyManagerRewards> managers = await shSzApi.StockCompanyManagerRewards(new string[] { "603986.SH", "000725.SZ" }); Assert.IsTrue(managers.Count > 0); foreach (var man in managers) { Console.WriteLine(man); } }
public async Task ShSzStockClassGetStockCompanyInfo() { TushareProApi pro = new TushareProApi(TestToken); ShanghaiShenzhenStockApi shSzApi = new ShanghaiShenzhenStockApi(pro); List <StockCompany> infos = await shSzApi.StockCompanyInformations(new string[] { "603986.SH", "000725.SZ" }); Assert.IsTrue(infos.Count > 0); foreach (var info in infos) { Console.WriteLine(info); } }
public async Task ShSzStockClassGetShSzHkConnectConstituent() { TushareProApi pro = new TushareProApi(TestToken); ShanghaiShenzhenStockApi shSzApi = new ShanghaiShenzhenStockApi(pro); List <ShSzHkConnectConstituent> constituents = await shSzApi.ShSzHkConnectConstituents(ShSzHkConnect.Shanghai); Assert.IsTrue(constituents.Count > 0); foreach (ShSzHkConnectConstituent constituent in constituents) { Console.WriteLine(constituent); } }
public async Task ShSzStockClassGetNameChangeHistory() { TushareProApi pro = new TushareProApi(TestToken); ShanghaiShenzhenStockApi shSzApi = new ShanghaiShenzhenStockApi(pro); List <NameHistory> histories = await shSzApi.NameChange("600848.SH"); Assert.IsTrue(histories.Count > 0); foreach (NameHistory history in histories) { Console.WriteLine(history); } }
public async Task CoreClassRequest() { TushareProApi pro = new TushareProApi(TestToken); APIRequest request = new APIRequest() { InterfaceName = "daily", Parameters = new Dictionary <string, string>() { { "ts_code", "603986.SH" }, { "trade_date", "20210305" }, }, Fields = new List <string>() { "open", "high", "low", "close" } }; APIResponse response = await pro.Request(request); Assert.AreEqual(response.ResponseCode, ResponseCode.OK); Console.WriteLine($"Get {response.DataSet.DataSet.Count} data, have {response.DataSet.DataColumn.Count} columns."); foreach (string col in response.DataSet.DataColumn) { Console.WriteLine($"Column: {col}"); } foreach (List <string> row in response.DataSet.DataSet) { Console.Write("["); foreach (string field in row) { Console.Write($"{field},"); } Console.WriteLine("]"); } }
public async Task CoreClassRequestInvalidInterface() { TushareProApi pro = new TushareProApi(TestToken); APIRequest request = new APIRequest() { InterfaceName = "validInterface", Parameters = new Dictionary <string, string>() { { "ts_code", "603986.SH" }, { "trade_date", "20210305" }, }, Fields = new List <string>() { "invalid", "open" } }; APIResponse response = await pro.Request(request); Assert.AreNotEqual(response.ResponseCode, ResponseCode.OK); Console.WriteLine($"Error message got: {response.ErrorMessage}"); }
public void CoreClassInstanseAndSetToken() { TushareProApi pro = new TushareProApi(TestToken); Assert.IsTrue(pro.UserTokenValid); }
/// <summary> /// 由TusharePro API接口创建访问沪深股票信息的API子接口 /// </summary> /// <param name="api">TusharePro API接口</param> public ShanghaiShenzhenStockApi(TushareProApi api) => this.api = api;