@@ -55,10 +55,25 @@ php composer.phar require "jaggedsoft/php-binance-api @dev"
55
55
56
56
</details >
57
57
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
59
73
` composer require jaggedsoft/php-binance-api `
60
74
``` php
61
75
require 'vendor/autoload.php';
76
+ require 'php-binance-api.php';
62
77
// 1. config in home directory
63
78
$api = new Binance\API();
64
79
// 2. config in specified file
@@ -1208,34 +1223,43 @@ bid: 0.00022258
1208
1223
1209
1224
#### User Data: Account Balance Updates, Trade Updates, New Orders, Filled Orders, Cancelled Orders via WebSocket
1210
1225
``` 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";
1214
1232
};
1215
1233
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;
1237
1237
};
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);
1239
1263
```
1240
1264
1241
1265
<details >
0 commit comments