@@ -55,10 +55,25 @@ php composer.phar require "jaggedsoft/php-binance-api @dev"
5555
5656</details >
5757
58- #### Getting started
58+ #### Getting started FAPI
59+ ``` php
60+ require 'vendor/autoload.php';
61+ require 'php-binance-fapi.php';
62+ // 1. config in home directory
63+ $fapi = new Binance\FAPI();
64+ // 2. config in specified file
65+ $fapi = new Binance\FAPI( "somefile.json" );
66+ // 3. config by specifying api key and secret
67+ $fapi = new Binance\FAPI("<api key >","<secret >");
68+ // 4. config by specifying api key, api secret and testnet flag. By default the testnet is disabled
69+ $fapi = new Binance\FAPI("<testnet api key >","<testnet secret >", true);
70+ ```
71+
72+ #### Getting started API
5973` composer require jaggedsoft/php-binance-api `
6074``` php
6175require 'vendor/autoload.php';
76+ require 'php-binance-api.php';
6277// 1. config in home directory
6378$api = new Binance\API();
6479// 2. config in specified file
@@ -1208,34 +1223,43 @@ bid: 0.00022258
12081223
12091224#### User Data: Account Balance Updates, Trade Updates, New Orders, Filled Orders, Cancelled Orders via WebSocket
12101225``` php
1211- $balance_update = function($api, $balances) {
1212- print_r($balances);
1213- echo "Balance update".PHP_EOL;
1226+ $run = function () {
1227+ global $api;
1228+ $quantity = 1.00;
1229+ $price = 59000.58;
1230+ $api->sell("BTCUSDT", $quantity, $price, "LIMIT", [], true);
1231+ echo "Startup Function Completed";
12141232};
12151233
1216- $order_update = function($api, $report) {
1217- echo "Order update".PHP_EOL;
1218- print_r($report);
1219- $price = $report['price'];
1220- $quantity = $report['quantity'];
1221- $symbol = $report['symbol'];
1222- $side = $report['side'];
1223- $orderType = $report['orderType'];
1224- $orderId = $report['orderId'];
1225- $orderStatus = $report['orderStatus'];
1226- $executionType = $report['orderStatus'];
1227- if ( $executionType == "NEW" ) {
1228- if ( $executionType == "REJECTED" ) {
1229- echo "Order Failed! Reason: {$report['rejectReason']}".PHP_EOL;
1230- }
1231- echo "{$symbol} {$side} {$orderType} ORDER #{$orderId} ({$orderStatus})".PHP_EOL;
1232- echo "..price: {$price}, quantity: {$quantity}".PHP_EOL;
1233- return;
1234- }
1235- //NEW, CANCELED, REPLACED, REJECTED, TRADE, EXPIRED
1236- echo "{$symbol} {$side} {$executionType} {$orderType} ORDER #{$orderId}".PHP_EOL;
1234+ $balance_update = function ($api, $balances) {
1235+ print_r($balances);
1236+ echo "Balance update" . PHP_EOL;
12371237};
1238- $api->userData($balance_update, $order_update);
1238+
1239+ $order_update = function ($api, $report) {
1240+ echo "Order update" . PHP_EOL;
1241+ print_r($report);
1242+ $price = $report['price'];
1243+ $quantity = $report['quantity'];
1244+ $symbol = $report['symbol'];
1245+ $side = $report['side'];
1246+ $orderType = $report['orderType'];
1247+ $orderId = $report['orderId'];
1248+ $orderStatus = $report['orderStatus'];
1249+ $executionType = $report['orderStatus'];
1250+ if ($executionType == "NEW") {
1251+ if ($executionType == "REJECTED") {
1252+ echo "Order Failed! Reason: {$report['rejectReason']}" . PHP_EOL;
1253+ }
1254+ echo "{$symbol} {$side} {$orderType} ORDER #{$orderId} ({$orderStatus})" . PHP_EOL;
1255+ echo "price: {$price}, quantity: {$quantity}" . PHP_EOL;
1256+ return;
1257+ }
1258+ //NEW, CANCELED, REPLACED, REJECTED, TRADE, EXPIRED
1259+ echo "{$symbol} {$side} {$executionType} {$orderType} ORDER #{$orderId}" . PHP_EOL;
1260+ };
1261+
1262+ $api->userData($balance_update, $order_update, $run);
12391263```
12401264
12411265<details >
0 commit comments