| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public function __invoke(Collection $ohlcv, int $timePeriod = 12, int $slowPeriod = 26, int $signalPeriod = 9): int |
||
| 32 | { |
||
| 33 | $macd = trader_macd( |
||
| 34 | $ohlcv->get('close'), |
||
| 35 | $timePeriod, |
||
| 36 | $slowPeriod, |
||
| 37 | $signalPeriod |
||
| 38 | ); |
||
| 39 | |||
| 40 | throw_unless($macd, NotEnoughDataException::class); |
||
| 41 | |||
| 42 | $macdValue = array_pop($macd[0]) - array_pop($macd[1]); |
||
| 43 | |||
| 44 | if ($macdValue < 0) { |
||
| 45 | return static::SELL; |
||
| 46 | } elseif ($macdValue > 0) { |
||
| 47 | return static::BUY; |
||
| 48 | } |
||
| 49 | |||
| 50 | return static::HOLD; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |