masyasmv/freedom-broker-api
最新稳定版本:v1.3.0
Composer 安装命令:
composer require masyasmv/freedom-broker-api
包简介
PHP SDK & parser for Freedom24 (TraderNet) Broker API — reports, securities, quotes, orders and history
README 文档
README
Freedom Broker API SDK for PHP 8 / Laravel 8 +
Lean, fully‐typed SDK for Freedom24 (TraderNet) broker API:
| Domain | What you get |
|---|---|
| Reports | JSON fetch → strict DTO collections balances, operations, positions, payments (dividends / compensations) |
| Trading | send, cancel, list orders |
| Market data | securities catalog, quotes, historical bars |
| Auth | V1 & V2 HMAC request signing |
| Tooling | ReportPeriodDTO (start/end helpers) |
All DTOs are Psalm-/PHPStan-friendly; persistence/business logic stays in your app.(GitHub)
✨ What’s new (v 1.3.0)
PaymentDTO+paymentscollection in parser (dividends, tax compensation).- Safe numeric casting:
"-"or""⇒0.0in money fields. ReportPeriodDTOwith helperscontains()&lengthInDays().- 100 % unit-coverage on GitHub Actions & Coveralls.
- README overhaul 😎
Full list: see CHANGELOG.
️Requirements
- PHP ≥ 8.0 (8.1–8.3 preferred)
ext-json,ext-mbstring- Guzzle 7+
- Laravel 8/9/10 (auto-discover)
Installation
composer require masyasmv/freedom-broker-api
Laravel setup
php artisan vendor:publish \ --provider="MasyaSmv\FreedomBrokerApi\Laravel\Providers\FreedomBrokerServiceProvider" \ --tag="freedom-config"
FREEDOM_PUBLIC_KEY=your_public_key FREEDOM_PRIVATE_KEY=your_secret_key
That’s it – the package facade Freedom:: is ready.
Quick Start
use MasyaSmv\FreedomBrokerApi\Laravel\Facades\Freedom; $public = config('freedom.public_key'); $private = config('freedom.private_key'); // 1. Full broker report – now includes `payments` $report = Freedom::load($public, $private, '2025-06-01', '2025-06-30'); $dividends = $report['payments']; // Collection<PaymentDTO> // 2. Send order $order = Freedom::orders()->send('AAPL.US', 1, 182.50, 'ACC-123'); // 3. Quote info $quote = Freedom::quotes()->get('AAPL.US'); // 4. Historical bars $bars = Freedom::history() ->history('AAPL.US', new DateTime('2024-01-01'), new DateTime());
API Reference (brief)
| Service | Facade/helper | Returns / DTO |
|---|---|---|
load($from,$to) |
Freedom::load() |
array{…} – see above |
StockService::all() |
Freedom::stocks() |
Collection<StockDTO> |
QuoteInfoService::get($ticker) |
Freedom::quotes() |
`StockDTO |
StockHistoryService::history() |
Freedom::history() |
Collection<StockHistoryDTO> |
OrderService::send/cancel/history() |
Freedom::orders() |
`OrderDTO |
✅ Quality
composer test # PHPUnit (unit + stub integration) composer coverage # html/text coverage composer cs # style check composer cs-fix # auto-fix composer phpstan # static analysis (level 8)
Live API tests (FREEDOM_LIVE_TEST=1) are opt-in to keep CI
fast.(GitHub)
Contributing
- Fork → feature branch (
feat/xxx) - Add tests (aim ≥ 95 % cov.)
composer test && composer cs- PR against
develop
We follow PSR-12 + Laravel conventions.
License
Released under the MIT license. © Masya Smv, 2025
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-09