-
Notifications
You must be signed in to change notification settings - Fork 6
/
limit_order.php
48 lines (40 loc) · 1.47 KB
/
limit_order.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* @author Ebo Eppenga
* @copyright 2021
*
* GoldStar Buy and Sell bot based on signals from for example TradeView
* or any other platform using PHP Binance API from JaggedSoft.
*
* limit_order.php
* Adds a LIMIT order to a BUY order adding fees and markup.
*
*/
// Do some calculations
$buy_fee = $commission;
$sell_fee = ($quantity * $price) * ($fee / 100);
$fees = $buy_fee + $sell_fee;
$markups = ($quantity * $price) * ($markup / 100);
$sell = ($quantity * $price) + $fees + $markups;
$sell_price = $sell / $quantity;
$sell_price = roundStep($sell_price, minimumQuote()['tickSize']); // Adjust for Binance
// Report
echo "<b>LIVE LIMIT Order</b><br />";
echo "Quantity : " . $quantity . "<br />";
echo "Markup : " . $markups . "<br />";
echo "BUY Fee : " . $buy_fee . " (" . $fee . "%)<br />";
echo "SELL Fee : " . $sell_fee . " (" . $fee . "%)<br />";
echo "SELL Price : " . $sell_price . "<br />";
echo "SELL Value : " . $sell . "<br /><br />";
// Place the Limit order
$order = $api->sell($pair, $quantity, $sell_price);
logCommand($order, "binance");
// Get the correct ID so it can be matched later
$unique_id = extractBinance($order)['order'];
// Report
echo "<b>LIVE LIMIT Trade</b><br />";
echo "Symbol : " . $order['symbol'] . "<br />";
echo "Order ID : " . $order['orderId'] . "<br />";
echo "Time : " . $order['transactTime'] . "<br />";
echo "Status : " . $order['status'] . "<br /><br />";
?>