-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTransactionStrategy.class.php
36 lines (30 loc) · 1.06 KB
/
TransactionStrategy.class.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
<?php
namespace BinanceBot;
abstract class TransactionStrategy implements ITransactionStrategy
{
protected $api = null;
protected $BinanceBotPrices = null;
protected $BinanceBotOrders = null;
protected $BinanceBotHoldings = null;
protected $BinanceBotCandles = null;
public function __construct( $arrs )
{
$this->api = $arrs[0];
$this->BinanceBotHoldings = $arrs[1];
$this->BinanceBotOrders = $arrs[2];
$this->BinanceBotPrices = $arrs[3];
$this->BinanceBotCandles = $arrs[4];
}
public function getBuySpread( $symbol, $TotalPriceUSD, $quantity )
{
return round( $TotalPriceUSD - ( BinanceBotPrices::getBTCUSD() * ( $this->BinanceBotPrices->getPrice( $symbol ) * $quantity ) ), 2 );
}
public function getSellSpread( $symbol, $TotalPriceUSD, $quantity )
{
if( $this->BinanceBotHoldings->getHoldings( $symbol ) != false )
{
return round( $TotalPriceUSD - ( BinanceBotPrices::getBTCUSD() * ( $this->BinanceBotPrices->getPrice( $symbol ) * $quantity ) ), 2 );
}
return 0.0;
}
}