Download the PHP package ragingprodigy/alpaca-php without Composer

On this page you can find all versions of the php package ragingprodigy/alpaca-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package alpaca-php

Alpaca-PHP

Alpaca Trade API for PHP Build Status Build Status

Overview

This is a PHP Client for Alpaca (General Alpaca API Documentation). Alpaca API lets you build and trade with real-time market data for free.

Table of Contents

  1. Installation
  2. Basic Usage
  3. Full Scale Example
  4. Methods

Installation

The package can be installed via Composer.

composer require ragingprodigy/alpaca-php

Basic Usage

To use the Library, simply create an instance of the client as shown below:

Under the Hood, the library makes use of the Guzzle Http client library to send HTTP requests. You can also provide a custom ClientInterface as the second argument to the Client constructor in order to further customize the GuzzleHttp Client.

You can then access the available APIs by calling:

Full Scale Example

Here's how you can use the library to print out account information, submit a limit order, and print out bars.

The output for the code above would be similar to:

Account Information: 
        Created At: 2019-06-26T15:19:01.819453Z
        Buying Power: $ 398861.06
        Portfolio Value: $ 100003.99

Clock: 
        Current Time: 2019-07-01T03:14:37.582893836-04:00
        Market Next Open Time: 2019-07-01T09:30:00-04:00
        Market Next Close Time: 2019-07-01T16:00:00-04:00

Market Order Response: 
        Symbol: AAPL
        Client Order Id: 309626b7-5569-4ae5-bb16-d93930b8b82b
        Quantity: 5
        Type: market
        Created At: 2019-07-01T07:14:39.022538874Z

Order Update Event: {"event":"new","order":{"asset_class":"us_equity","asset_id":"b0b6dd9d-8b9b-48a9-ba46-b9d54906e415","canceled_at":null,"client_order_id":"abea2d0b-2340-4034-a50c-b4f09cde1e0b","created_at":"2019-07-01T07:12:16.177026Z","expired_at":null,"failed_at":null,"filled_at":null,"filled_avg_price":null,"filled_qty":"0","id":"b3332b17-b7dc-4a55-9a3c-dfd0c50ecc62","limit_price":null,"order_type":"market","qty":"5","side":"buy","status":"new","stop_price":null,"submitted_at":"2019-07-01T07:12:16.165806Z","symbol":"AAPL","time_in_force":"day","type":"market","updated_at":"2019-07-01T07:12:20.373783079Z"}}

Market Order by ID Response: 
        Symbol: AAPL
        Client Order Id: 309626b7-5569-4ae5-bb16-d93930b8b82b
        Quantity: 5
        Type: market
        Created At: 2019-07-01T07:14:39.022539Z

Market Order by ID Response: 
        Symbol: AAPL
        Client Order Id: 309626b7-5569-4ae5-bb16-d93930b8b82b
        Quantity: 5
        Type: market
        Created At: 2019-07-01T07:14:39.022539Z

Order Update Event: {"event":"canceled","order":{"asset_class":"us_equity","asset_id":"b0b6dd9d-8b9b-48a9-ba46-b9d54906e415","canceled_at":"2019-07-01T07:12:20.369944583Z","client_order_id":"abea2d0b-2340-4034-a50c-b4f09cde1e0b","created_at":"2019-07-01T07:12:16.177026Z","expired_at":null,"failed_at":null,"filled_at":null,"filled_avg_price":null,"filled_qty":"0","id":"b3332b17-b7dc-4a55-9a3c-dfd0c50ecc62","limit_price":null,"order_type":"market","qty":"5","side":"buy","status":"canceled","stop_price":null,"submitted_at":"2019-07-01T07:12:16.165806Z","symbol":"AAPL","time_in_force":"day","type":"market","updated_at":"2019-07-01T07:12:20.384272245Z"},"timestamp":"2019-07-01T07:12:20.369944583Z"}

Bars Response: 
        ========================
        Symbol: AAPL
        Open: 198.43
        High: 199.26
        Low: 195.29
        Close: 195.57
        Volume: 18361798
        ========================
        Symbol: AAPL
        Open: 197.83
        High: 200.99
        Low: 197.35
        Close: 199.8
        Volume: 22499633
        ========================
        Symbol: AAPL
        Open: 200.29
        High: 201.57
        Low: 199.57
        Close: 199.73
        Volume: 15460769
        ========================
        Symbol: AAPL
        Open: 199.24
        High: 199.4
        Low: 197.05
        Close: 197.92
        Volume: 18773228

Methods

All API methods are available on the Alpaca Client (RagingProdigy\Alpaca\Client).

Account API

Calls GET /account and returns the current account

Orders API
Request New Order

Calls POST /orders and creates a new order.

Get Orders

Calls GET /orders and returns an array of Order objects.

Get Order By ID

Calls GET /orders/{id} and returns an Order.

Get Order By Client Order Id

Calls GET /orders:by_client_order_id and returns an order by client_order_id. You can set client_order_id while creating your orders to easily keep track of your orders.

Cancel an Order

Calls DELETE /orders/{id} and deletes an Order.

Raises an AlpacaApiException when it fails.

Positions API
Get Position

Calls GET /positions/{symbol} and returns a Position.

Get All Position

Calls GET /positions and returns an array of Position objects.

Assets API
Get Assets

Calls GET /assets/ and returns an array of Assets matching your criteria.

Get Asset Information

Calls GET /assets/{symbol} and returns an Asset entity.

Calendar API

Calls GET/calendar and returns the market calendar for the selected dates

Data API
Get Bars

Tests

In order to run the tests, install the dev-dependencies (composer install --dev) and then run:


All versions of alpaca-php with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
ext-json Version *
guzzlehttp/guzzle Version ^6.3
ratchet/pawl Version ^0.3.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ragingprodigy/alpaca-php contains the following files

Loading the files please wait ....