marketdataapp/sdk-php

PHP SDK for MarketData.app

v0.6.2-beta 2024-09-17 01:46 UTC

README

Latest Version on Packagist Tests Codecov Total Downloads

This is the official PHP SDK for Market Data. It provides developers with a powerful, easy-to-use interface to obtain real-time and historical financial data. Ideal for building financial applications, trading bots, and investment strategies.

Installation

You can install the package via composer:

composer require MarketDataApp/sdk-php

Usage

$client = new MarketDataApp\Client('your_api_token');

// Indices
$quote = $client->indices->quote('VIX');
$quotes = $client->indices->quotes(['VIX', 'DJI']);
$candles = $client->indices->candles(
    symbol: "VIX",
    from: '2022-09-01',
    to: '2022-09-05',
    resolution: 'D'
);

// Stocks
$candles = $client->stocks->candles('AAPL');
$bulk_candles = $client->stocks->bulkCandles(['AAPL, MSFT']);
$quote = $client->stocks->quote('AAPL');
$quotes = $client->stocks->quotes(['AAPL', 'MSFT']);
$bulk_quotes = $client->stocks->bulk_quotes(['AAPL', 'MSFT']);
$earnings = $client->stocks->earnings(symbol: 'AAPL', from: '2023-01-01');
$news = $client->stocks->news(symbol: 'AAPL', from: '2023-01-01');

// Markets
$status = $client->markets->status(date: '2023-01-01');

// Mutual Funds
$candles = $client->mutual_funds->candles(
    symbol: 'VFINX',
    from: '2022-09-01',
    to: '2022-09-05',
    resolution: 'D'
);

// Options
$expirations = $client->options->expirations('AAPL');
$lookup = $client->options->lookup('AAPL 7/28/23 $200 Call');
$strikes = $client->options->strikes(
    symbol: 'AAPL',
    expiration: '2023-01-20',
    date: '2023-01-03',
);
$option_chain = $client->options->option_chain(
    symbol: 'AAPL',
    expiration: '2025-01-17',
    side: Side::CALL,
);
$quotes = $client->options->quotes('AAPL250117C00150000');

// Utilities
$status = $client->utilities->api_status();
$headers = $client->utilities->headers();

Universal Parameters

All endpoints (other than utilities) supports universal parameters.

For instance, you can change the format to CSV

$option_chain = $client->options->option_chain(
    symbol: 'AAPL',
    expiration: '2025-01-17',
    side: Side::CALL,
    parameters: new Parameters(format: Format::CSV),
);

Testing

./vendor/bin/phpunit

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.