Skip to main content

Crate financial_api

Crate financial_api 

Source
Expand description

§financial-api-rs

License: MIT

面向同花顺官方金融数据服务的异步 Rust 客户端,提供已上线 REST API 的类型化访问。

§安装

cargo add financial-api

使用前设置 API Key:

export HITHINK_FINANCE_API_KEY='<your-api-key>'

§快速开始

use financial_api::{Client, Error};

#[tokio::main]
async fn main() -> Result<(), Error> {
    let client = Client::from_env()?;
    let response = client
        .index_constituents_ths_stock_list("000300.SH")
        .await?;

    println!("{:#?}", response.data());
    Ok(())
}

§支持范围

当前覆盖 59 个已上线端点,包括:

  • 标的检索与列表
  • A 股行情、财务、估值、竞价及特色数据
  • 同花顺指数目录、成分股与行情
  • 基金资料、持仓、业绩、经理、公司、资讯及行情
  • 全市场日 K 与复权因子导出

上游标记为“敬请期待”的能力不在当前支持范围内。完整用法可查看 API 文档和仓库中的 examples/。

§项目说明

  • 使用本项目需要同花顺金融数据服务的有效账号、API Key 和对应权限。
  • 数据内容、更新频率与服务可用性由上游提供方决定。
  • 本项目及其示例不构成投资建议。
  • 源码与问题跟踪位于 Choi-Jungwoo/financial-api-rs。

§许可证

本项目使用 MIT License。该许可证不授予同花顺服务、数据、商标或其他上游 资产的权利。

Structs§

AShareCode
限定在 A 股标的宇宙内的完整标的代码。
AdjustmentFactorItem
AdjustmentFactorsData
指定 A 股标的的复权事件。
AnomalyItem
ApiKey
以敏感 HTTP 请求头值保存的已校验 API Key。
AuctionBenchmarkData
AuctionBenchmarkItem
AuctionSnapshotData
AuctionSnapshotItem
BalanceSheetItem
BusinessError
从响应信封中解码出的非零业务结果。
CashFlowStatementItem
Client
可复用的异步 API 客户端。
ClientBuilder
用于配置客户端级可选传输参数的构建器。
CompactDate
在线路协议中编码为 YYYYMMDD 的已校验公历自然日。
CompanyId
从基金资料数据中发现的不透明基金公司标识。
ConceptItem
Cursor
游标分页端点返回的不透明分页游标。
DragonTigerData
DragonTigerStockItem
EndpointInfo
一个已支持 REST 能力的稳定名称和路径。
FinancialAbility
FinancialIndicator
FinancialIndicatorsData
FinancialRange
“最近报告期”和“时间戳区间”互斥的财务查询。
FinancialReport
YYYY-[1-4] 格式的财务报告期标识。
FinancialStatementMeta
上市公司三类财务报表共用的字段。
FundAssetAllocationItem
FundBalanceSheetItem
FundCategoryCode
在诊断数据中观察到的不透明基金分类代码。
FundCompanyItem
FundDiagnosticsItem
FundDividendItem
FundDividendsData
FundDrawdownsItem
FundFinancialIndicatorsItem
FundHolderItem
FundHoldingItem
FundHoldingsData
FundIncomeStatementItem
FundIndicatorHistoryItem
FundIndustryAllocationItem
FundManagerDetailItem
FundManagerExperienceItem
FundManagerPerformanceItem
FundManagerRadarComparison
按类别和区间对齐的一项基金经理同类比较雷达节点。
FundManagerRef
FundManagerStyleItem
FundMarketHistoricalData
FundMarketSnapshotData
FundMarketSnapshotItem
FundNavItem
FundNewsData
FundNewsItem
FundOfferingItem
FundPortfolioHistoryItem
FundProfileItem
FundRateInfo
FundReportDateItem
FundReturnsItem
FundTopHolderItem
FundTopHoldersData
FundTradeRule
HistoricalData
历史日 K 线载荷。
HotMoneyItem
HotStockHistoryData
HotStockHistoryItem
HotStockItem
HotStockTrendItem
IncomeStatementItem
IndexCatalogItem
IndexConstituentItem
IndexHistoricalData
指数历史行情包含固定为 null 的复权字段。
LadderBoardCaps
LadderBoards
LadderData
LadderDay
LadderStock
LadderWindow
LimitBreakItem
LimitDownItem
LimitUpItem
ManagerId
从基金资料数据中发现的不透明基金经理标识。
MarketDumpUrl
短期有效的市场数据包下载授权。
NaturalDate
序列化为 YYYY-MM-DD 的已校验公历自然日。
OptionalInput
可省略端点参数的转换目标。
Page
特色数据池使用的已校验分页参数。
Pagination
PoolData
PreciseDecimal
保留源数字且不转换为二进制浮点数的 JSON 十进制数。
PriceBarItem
一条日开高低收量 K 线。
PriceSnapshotData
A 股或指数的行情快照载荷。
PriceSnapshotItem
一条最新行情记录。
PriceSnapshotSelection
显式指定的标的,或完整 A 股标的宇宙中的一页。
ReportType
从报告期端点中发现的基金披露报告类型。
Response
通过通用业务信封校验后的成功响应。
SecretUrl
调试表示始终脱敏的短期预签名 URL。
ShanghaiDateMillis
以 Asia/Shanghai 时区午夜 Unix 毫秒值表示的自然日。
Thscode
包含市场后缀的完整标的代码。
TickerItem
一条规范化标的代码记录。
TickerListRequest
用于浏览标的代码表的参数。
TickerSearchRequest
用于标的搜索和跨市场消歧的参数。
TimestampedItems
将业务记录保存在 item 中的带时间戳端点载荷。
TradingDayItem
UnixMillis
非负 Unix 毫秒时间戳。
ValidationError
请求领域值或客户端配置值无效。
ValuationItem
ValuationsData

Enums§

Adjustment
历史行情复权口径。
AnomalyTag
A 股异动标签。
AssetType
规范化的最细粒度资产类型。
AuctionPhase
集合竞价快照响应中的阶段。
AuctionStage
集合竞价快照请求接受的阶段。
BusinessErrorKind
上游非零业务结果对应的稳定恢复类别。
DailyInterval
基金历史行情返回的固定日 K 线周期。
DragonTigerBoard
龙虎榜榜单筛选条件。
Error
配置或调用 API 时产生的失败。
Exchange
元数据 API 支持的交易所筛选条件。
FinancialAbilityKind
固定的财务分析能力分组。
FinancialIndicatorId
上游契约定义的财务指标标识。
FinancialPeriod
财务报表频率。
FiscalPeriod
上市公司财务报表返回的会计期间。
FundNavType
基金净值序列选择。
FundRange
基金历史净值区间。
FundType
基金标的宇宙。
HolderMergeScope
持有人记录合并策略。
HolderRecordScope
基金持有人记录返回的实际披露范围。
HotListPeriod
排名聚合周期。
IndexTag
同花顺指数目录标签。
JsonValue
Represents any valid JSON value.
LimitBreakSortField
炸板池排序字段。
LimitDownSortField
跌停池排序字段。
LimitUpSortField
涨停池排序字段。
ManagerPerformanceRange
基金经理业绩区间。
OfferingStatus
新发基金认购状态。
PortfolioAssetType
基金持仓披露使用的资产类别。
RankTrend
热榜排名变化方向。
SortDirection
特色数据分页池使用的排序方向。

Constants§

SUPPORTED_ENDPOINTS
上游契约中当前所有可用的 REST 端点。

Type Aliases§

AnomalyData
BalanceSheetsData
CashFlowStatementsData
FundAssetAllocationData
FundBalanceSheetsData
FundCompanyData
FundDiagnosticsData
FundDrawdownsData
FundFinancialIndicatorsData
FundHoldersData
FundIncomeStatementsData
FundIndicatorHistoryData
FundIndustryAllocationData
FundManagerDetailData
FundManagerExperienceData
FundManagerPerformanceData
FundManagerStyleData
FundNavData
FundOfferingsData
FundPortfolioHistoryData
FundProfileData
FundReportDatesData
FundReturnsData
HotStockData
HotStockTrendData
IncomeStatementsData
IndexCatalogData
IndexConstituentsData
LimitBreakData
LimitDownData
LimitUpData
TickerData
TradingDaysData