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