rocketfellows/tinkoff-invest-v1-market-data-rest-client

v1.0.0 2022-07-12 21:07 UTC

This package is not auto-updated.

Last update: 2024-09-19 06:30:42 UTC


README

Code Coverage Badge

tinkoff invest v1 市场数据服务的简单实现。提供以下方法:

方法接口

  • \rocketfellows\TinkoffInvestV1MarketDataRestClient\GetTradingStatusInterface
  • \rocketfellows\TinkoffInvestV1MarketDataRestClient\GetOrderBookInterface
  • \rocketfellows\TinkoffInvestV1MarketDataRestClient\GetLastTradesInterface
  • \rocketfellows\TinkoffInvestV1MarketDataRestClient\GetLastPricesInterface
  • \rocketfellows\TinkoffInvestV1MarketDataRestClient\GetCandlesInterface

方法接口实现汇总在 \rocketfellows\TinkoffInvestV1MarketDataRestClient\MarketDataService。

为了遵循接口隔离原则,您应注入特定的接口作为依赖项,并通过容器(DI)定义实现。

安装

composer require rocketfellows/tinkoff-invest-v1-market-data-rest-client

方法合同定义

组件方法接受数组作为参数,并且原始数组也用作输出值。

方法抛出以下类型的异常

  • rocketfellows\TinkoffInvestV1RestClient\exceptions\request\ClientException
  • rocketfellows\TinkoffInvestV1RestClient\exceptions\request\ServerException
  • rocketfellows\TinkoffInvestV1RestClient\exceptions\request\HttpClientException

组件依赖项

"rocketfellows/tinkoff-invest-v1-rest-client": "1.0.2" - 作为通用 HTTP 客户端。

使用示例

通用 HTTP 客户端配置

$client = new Client(
    (
        new ClientConfig(
            'https://invest-public-api.tinkoff.ru/rest',
            <your_access_token>
        )
    ),
    new \GuzzleHttp\Client()
);

市场数据服务配置(或通过 DI 的接口特定方法配置)

$marketDataService = new MarketDataService($client);

获取仪器最后价格方法调用示例

$marketDataService->getLastPrices([
    'figi' => ['BBG004730RP0', 'BBG00TW9WTR3'],
]);

结果方案您可以在以下位置找到: https://tinkoff.github.io/investAPI/swagger-ui/#/MarketDataService/MarketDataService_GetLastPrices

贡献

欢迎发送 pull request。如果有重大更改,请先打开一个 issue 进行讨论。

请确保适当更新测试。