dirkolbrich / stockfighter
A wrapper for the stockfighter api
Requires
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- vlucas/phpdotenv: ~2.1
This package is not auto-updated.
Last update: 2024-11-09 18:43:36 UTC
README
My take on an API wrapper for stockfighter.io
It utilizes two base classes:
StockfighterApi.php
, which is the minimal wrapper around the REST API of stockfighter.io. It returns the raw json response. See the stockfighter API documentation. You can use this base class for you own implemantation.
Stockfighter.php
is the actual game wrapper around the API. It depends on StockfighterApi.php
. The system keeps track of your orders and your account with a list of the transactions, the inventory and your balance.
Installation
Install via composer:
"require": { "dirkolbrich/stockfighter": "*" }
Usage
API Class
To only use the base API class. Provide your API key during instantiation:
use DirkOlbrich\Stockfighter\StockfighterApi; $apiKey = "your API key provided by stockfighter.io"; $api = new StockfighterApi($apiKey);
The followings functions are available:
heartbeat()
- check if the REST API is upvenueHeartbeat($venue)
- check if the venue is upvenues()
- get all available venuesstocks($venue)
- get all available stocks on a specific venueorders($account, $venue)
- get all orders on a specific venuestockOrders($account, $venue, $stock)
- get all orders for a specific stock on a specific venueorderbook($venue, $stock)
- get the orderbook of a specific stock on a specific venuequote($venue, $stock)
- get the last quote of a specific stock on a specific venueorder($venue, $stock, $order)
- place an order, the$order
param must be a string specified by the REST APIcancel($venue, $stock, $orderId)
- cancel an orderorderStatus($venue, $stock, $orderId)
- get the status of an order
Requests to the Game Master are available as well (self-explanatory):
levels()
- not implemented by the REST API yetstart($level)
restart($instanceId)
stop($instanceId)
resume($instanceId)
levelStatus($instanceId)
- get the status of the level
Stockfighter System
Or use the Stockfighter
system:
use DirkOlbrich\Stockfighter\Stockfighter; $apiKey = "your API key provided by stockfighter.io"; $sf = new Stockfighter($apiKey);
Dependencies
So far, it uses these dependencies.
"require": { "guzzlehttp/guzzle": "~6.0", }
ToDo
- integrate web socket client
- tests, tests, tests