-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example/Test files for main functions
- Loading branch information
Showing
20 changed files
with
233 additions
and
11 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Aggregate Trades List | ||
$trades = $api->aggTrades("BNBBTC"); | ||
print_r($trades); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Get all of your positions, including estimated BTC value | ||
$balances = $api->balances(); | ||
print_r($balances); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Get all bid/ask prices | ||
$bookPrices = $api->bookPrices(); | ||
print_r($bookPrices); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Get Kline/candlestick data for a symbol | ||
// Periods: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M | ||
$ticks = $api->candlesticks("BNBBTC", "5m"); | ||
print_r($ticks); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Get Market Depth | ||
$depth = $api->depth("ETHBTC"); | ||
print_r($depth); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Get latest price of a symbol | ||
$ticker = $api->prices(); | ||
print_r($ticker); // List prices of all symbols | ||
echo "Price of BNB: {$ticker['BNBBTC']} BTC.\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Get Open Orders | ||
$openorders = $api->openOrders("BNBBTC"); | ||
print_r($openorders); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Place a LIMIT order | ||
$quantity = 1; | ||
$price = 0.0005; | ||
$order = $api->buy("BNBBTC", $quantity, $price); | ||
print_r($order); | ||
|
||
// Place a MARKET order | ||
$quantity = 1; | ||
$order = $api->buy("BNBBTC", $quantity, 0, "MARKET"); | ||
print_r($order); | ||
|
||
// Place a STOP LOSS order | ||
// When the stop is reached, a stop order becomes a market order | ||
$quantity = 1; | ||
$price = 0.5; // Try to sell it for 0.5 btc | ||
$stopPrice = 0.4; // Sell immediately if price goes below 0.4 btc | ||
$order = $api->sell("BNBBTC", $quantity, $price, "STOP_LOSS", ["stopPrice"=>$stopPrice]); | ||
print_r($order); | ||
|
||
// Place a take profit order | ||
// When the stop is reached, a stop order becomes a market order | ||
$quantity = 1; | ||
$price = 0.5; // Try to sell it for 0.5 btc | ||
$stopPrice = 0.4; // Sell immediately if price goes below 0.4 btc | ||
$order = $api->sell("TRXBTC", $quantity, $price, "TAKE_PROFIT", ["stopPrice"=>$stopPrice]); | ||
print_r($order); | ||
|
||
// Place an ICEBERG order | ||
// Iceberg orders are intended to conceal the true order quantity. | ||
$quantity = 20; | ||
$price = 0.5; | ||
$icebergQty = 10; | ||
$order = $api->sell("BNBBTC", $quantity, $price, "LIMIT", ["icebergQty"=>$icebergQty]); | ||
print_r($order); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Place a LIMIT order | ||
$quantity = 1000; | ||
$price = 0.0005; | ||
$order = $api->buyTest("BNBBTC", $quantity, $price); | ||
print_r($order); | ||
|
||
// Place a MARKET order | ||
$quantity = 1; | ||
$order = $api->buyTest("BNBBTC", $quantity, 0, "MARKET"); | ||
print_r($order); | ||
|
||
// Place a STOP LOSS order | ||
// When the stop is reached, a stop order becomes a market order | ||
$quantity = 1; | ||
$price = 0.5; // Try to sell it for 0.5 btc | ||
$stopPrice = 0.4; // Sell immediately if price goes below 0.4 btc | ||
$order = $api->sellTest("BNBBTC", $quantity, $price, "STOP_LOSS", ["stopPrice"=>$stopPrice]); | ||
print_r($order); | ||
|
||
// Place a take profit order | ||
// When the stop is reached, a stop order becomes a market order | ||
$quantity = 1; | ||
$price = 0.5; // Try to sell it for 0.5 btc | ||
$stopPrice = 0.4; // Sell immediately if price goes below 0.4 btc | ||
$order = $api->sellTest("TRXBTC", $quantity, $price, "TAKE_PROFIT", ["stopPrice"=>$stopPrice]); | ||
print_r($order); | ||
|
||
// Place an ICEBERG order | ||
// Iceberg orders are intended to conceal the true order quantity. | ||
$quantity = 20; | ||
$price = 0.5; | ||
$icebergQty = 10; | ||
$order = $api->sellTest("BNBBTC", $quantity, $price, "LIMIT", ["icebergQty"=>$icebergQty]); | ||
print_r($order); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Get Trade History | ||
$history = $api->history("TRXBTC"); | ||
print_r($history); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Get complete realtime chart data via WebSockets | ||
$api->chart(["BNBBTC"], "15m", function($api, $symbol, $chart) { | ||
echo "{$symbol} chart update\n"; | ||
print_r($chart); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
$api->depthCache(["BNBBTC"], function($api, $symbol, $depth) { | ||
echo "{$symbol} depth cache update\n"; | ||
$limit = 11; // Show only the closest asks/bids | ||
$sorted = $api->sortDepth($symbol, $limit); | ||
$bid = $api->first($sorted['bids']); | ||
$ask = $api->first($sorted['asks']); | ||
echo $api->displayDepth($sorted); | ||
echo "ask: {$ask}\n"; | ||
echo "bid: {$bid}\n"; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
require '../php-binance-api.php'; | ||
|
||
// @see home_directory_config.php | ||
// use config from ~/.confg/jaggedsoft/php-binance-api.json | ||
$api = new Binance\API(); | ||
|
||
// Trade Updates via WebSocket | ||
$api->trades(["BNBBTC"], function($api, $symbol, $trades) { | ||
echo "{$symbol} trades update".PHP_EOL; | ||
print_r($trades); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters