masyasmv / freedom-broker-api
PHP SDK & parser for Freedom24 (TraderNet) Broker API — reports, securities, quotes, orders and history
v1.3.0
2025-07-16 12:25 UTC
Requires
- php: ^8.0
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.0
- league/csv: ^9.0
- psr/http-client: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- larastan/larastan: ^1.0
- mockery/mockery: ^1.5
- orchestra/testbench: ^6.30
- orchestra/testbench-core: ^6.30
- php-coveralls/php-coveralls: ^2.8
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.6
This package is auto-updated.
Last update: 2025-09-16 13:10:26 UTC
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
+payments
collection in parser (dividends, tax compensation).- Safe numeric casting:
"-"
or""
⇒0.0
in money fields. ReportPeriodDTO
with 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