|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Laratrade\Indicators; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
use Laratrade\Indicators\Contracts\IndicatorManager as IndicatorManagerContract; |
|
7
|
|
|
|
|
8
|
|
|
class IndicatorServiceProvider extends ServiceProvider |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* Indicates if loading of the provider is deferred. |
|
12
|
|
|
* |
|
13
|
|
|
* @var bool |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $defer = true; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Register the service provider. |
|
19
|
|
|
*/ |
|
20
|
|
|
public function register() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->app->bind(IndicatorManagerContract::class, function () { |
|
23
|
8 |
|
return tap(new IndicatorManager, function ($manager) { |
|
24
|
8 |
|
$this->registerIndicators($manager); |
|
25
|
8 |
|
}); |
|
26
|
8 |
|
}); |
|
27
|
8 |
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Register the indicators on the manager. |
|
31
|
|
|
* |
|
32
|
|
|
* @param IndicatorManagerContract $manager |
|
33
|
|
|
*/ |
|
34
|
8 |
|
protected function registerIndicators(IndicatorManagerContract $manager) |
|
35
|
|
|
{ |
|
36
|
8 |
|
foreach (['Ao', 'Cmo'] as $indicator) { |
|
37
|
8 |
|
$this->{"register{$indicator}Indicator"}($manager); |
|
38
|
|
|
} |
|
39
|
8 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Register the awesome oscillator indicator. |
|
43
|
|
|
* |
|
44
|
|
|
* @param IndicatorManagerContract $manager |
|
45
|
|
|
*/ |
|
46
|
|
|
protected function registerAoIndicator(IndicatorManagerContract $manager) |
|
47
|
|
|
{ |
|
48
|
8 |
|
$manager->extend('ao', function () { |
|
49
|
2 |
|
return new AwesomeOscillatorIndicator; |
|
50
|
8 |
|
}); |
|
51
|
8 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Register the change momentum oscillator indicator. |
|
55
|
|
|
* |
|
56
|
|
|
* @param IndicatorManagerContract $manager |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function registerCmoIndicator(IndicatorManagerContract $manager) |
|
59
|
|
|
{ |
|
60
|
8 |
|
$manager->extend('cmo', function () { |
|
61
|
2 |
|
return new ChangeMomentumOscillatorIndicator; |
|
62
|
8 |
|
}); |
|
63
|
8 |
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Get the services provided by the provider. |
|
67
|
|
|
* |
|
68
|
|
|
* @return array |
|
69
|
|
|
*/ |
|
70
|
2 |
|
public function provides() |
|
71
|
|
|
{ |
|
72
|
|
|
return [ |
|
73
|
2 |
|
IndicatorManagerContract::class, |
|
74
|
|
|
]; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|