| Conditions | 5 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function __invoke(Collection $ohlcv): int |
||
| 22 | { |
||
| 23 | $obv = trader_obv( |
||
| 24 | $ohlcv->get('close'), |
||
| 25 | $ohlcv->get('volume') |
||
| 26 | ); |
||
| 27 | |||
| 28 | throw_unless($obv, NotEnoughDataException::class); |
||
| 29 | |||
| 30 | $currentValue = array_pop($obv); |
||
| 31 | $priorValue = array_pop($obv); |
||
| 32 | $earlierValue = array_pop($obv); |
||
| 33 | |||
| 34 | if (($currentValue > $priorValue) && ($priorValue > $earlierValue)) { |
||
| 35 | return static::BUY; |
||
| 36 | } elseif (($currentValue < $priorValue) && ($priorValue < $earlierValue)) { |
||
| 37 | return static::SELL; |
||
| 38 | } |
||
| 39 | |||
| 40 | return static::HOLD; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |