-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added methods for getting, transforming stock options. Test to validate
- Loading branch information
Showing
4 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Scheb\YahooFinanceApi\Results; | ||
|
||
class Option implements \JsonSerializable | ||
{ | ||
private $contractSymbol; | ||
private $strike; | ||
private $currency; | ||
private $lastPrice; | ||
private $change; | ||
private $percentChange; | ||
private $volume; | ||
private $openInterest; | ||
private $bid; | ||
private $ask; | ||
private $contractSize; | ||
private $expiration; | ||
private $lastTradeDate; | ||
private $impliedVolatility; | ||
private $inTheMoney; | ||
|
||
public function __construct(array $values) | ||
{ | ||
foreach ($values as $property => $value) { | ||
$this->{$property} = $value; | ||
} | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
return get_object_vars($this); | ||
} | ||
|
||
public function getContractSymbol(): string | ||
{ | ||
return $this->contractSymbol; | ||
} | ||
|
||
public function getStrike(): float | ||
{ | ||
return $this->strike; | ||
} | ||
|
||
public function getCurrency(): string | ||
{ | ||
return $this->currency; | ||
} | ||
|
||
public function getLastPrice(): float | ||
{ | ||
return $this->lastPrice; | ||
} | ||
|
||
public function getChange(): float | ||
{ | ||
return $this->change; | ||
} | ||
|
||
public function getPercentChange(): float | ||
{ | ||
return $this->percentChange; | ||
} | ||
|
||
public function getVolume(): int | ||
{ | ||
return $this->volume; | ||
} | ||
|
||
public function getOpenInterest(): int | ||
{ | ||
return $this->openInterest; | ||
} | ||
|
||
public function getBid(): float | ||
{ | ||
return $this->bid; | ||
} | ||
|
||
public function getAsk(): float | ||
{ | ||
return $this->ask; | ||
} | ||
|
||
public function getContractSize(): string | ||
{ | ||
return $this->contractSize; | ||
} | ||
|
||
public function getExpiration(): \DateTimeInterface | ||
{ | ||
return $this->expiration; | ||
} | ||
|
||
public function getLastTradeDate(): \DateTimeInterface | ||
{ | ||
return $this->lastTradeDate; | ||
} | ||
|
||
public function getImpliedVolatility(): float | ||
{ | ||
return $this->impliedVolatility; | ||
} | ||
|
||
public function getInTheMoney(): bool | ||
{ | ||
return $this->inTheMoney; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters