|
11 | 11 | use MarketDataApp\Endpoints\Responses\Options\Quote; |
12 | 12 | use MarketDataApp\Endpoints\Responses\Options\Quotes; |
13 | 13 | use MarketDataApp\Endpoints\Responses\Options\Strikes; |
| 14 | +use MarketDataApp\Enums\Expiration; |
14 | 15 | use MarketDataApp\Enums\Side; |
15 | 16 | use PHPUnit\Framework\TestCase; |
16 | 17 |
|
@@ -107,6 +108,50 @@ public function testOptionChain_success() |
107 | 108 | $option_chain = array_pop($response->option_chains); |
108 | 109 | $this->assertNotEmpty($option_chain); |
109 | 110 |
|
| 111 | + // Verify each item in the response is an object of the correct type and has the correct values. |
| 112 | + $option_strike = array_pop($option_chain); |
| 113 | + $this->assertInstanceOf(OptionChainStrike::class, $option_strike); |
| 114 | + $this->assertEquals('string', gettype($option_strike->option_symbol)); |
| 115 | + $this->assertEquals('string', gettype($option_strike->underlying)); |
| 116 | + $this->assertInstanceOf(Carbon::class, $option_strike->expiration); |
| 117 | + $this->assertInstanceOf(Side::class, $option_strike->side); |
| 118 | + $this->assertEquals('double', gettype($option_strike->strike)); |
| 119 | + $this->assertInstanceOf(Carbon::class, $option_strike->first_traded); |
| 120 | + $this->assertEquals('integer', gettype($option_strike->dte)); |
| 121 | + $this->assertInstanceOf(Carbon::class, $option_strike->updated); |
| 122 | + $this->assertEquals('double', gettype($option_strike->bid)); |
| 123 | + $this->assertEquals('integer', gettype($option_strike->bid_size)); |
| 124 | + $this->assertEquals('double', gettype($option_strike->mid)); |
| 125 | + $this->assertEquals('double', gettype($option_strike->ask)); |
| 126 | + $this->assertEquals('integer', gettype($option_strike->ask_size)); |
| 127 | + $this->assertTrue(in_array(gettype($option_strike->last), ['double', 'NULL'])); |
| 128 | + $this->assertEquals('integer', gettype($option_strike->open_interest)); |
| 129 | + $this->assertEquals('integer', gettype($option_strike->volume)); |
| 130 | + $this->assertEquals('boolean', gettype($option_strike->in_the_money)); |
| 131 | + $this->assertEquals('double', gettype($option_strike->intrinsic_value)); |
| 132 | + $this->assertEquals('double', gettype($option_strike->extrinsic_value)); |
| 133 | + $this->assertEquals('double', gettype($option_strike->implied_volatility)); |
| 134 | + $this->assertTrue(in_array(gettype($option_strike->delta), ['double', 'NULL'])); |
| 135 | + $this->assertEquals('double', gettype($option_strike->gamma)); |
| 136 | + $this->assertEquals('double', gettype($option_strike->theta)); |
| 137 | + $this->assertEquals('double', gettype($option_strike->vega)); |
| 138 | + $this->assertEquals('double', gettype($option_strike->rho)); |
| 139 | + $this->assertEquals('double', gettype($option_strike->underlying_price)); |
| 140 | + } |
| 141 | + public function testOptionChain_expirationEnum_success() |
| 142 | + { |
| 143 | + $response = $this->client->options->option_chain( |
| 144 | + symbol: 'AAPL', |
| 145 | + expiration: Expiration::ALL, |
| 146 | + side: Side::CALL, |
| 147 | + ); |
| 148 | + |
| 149 | + // Verify that the response is an object of the correct type. |
| 150 | + $this->assertInstanceOf(OptionChains::class, $response); |
| 151 | + $this->assertNotEmpty($response->option_chains); |
| 152 | + $option_chain = array_pop($response->option_chains); |
| 153 | + $this->assertNotEmpty($option_chain); |
| 154 | + |
110 | 155 | // Verify each item in the response is an object of the correct type and has the correct values. |
111 | 156 | $option_strike = array_pop($option_chain); |
112 | 157 | $this->assertInstanceOf(OptionChainStrike::class, $option_strike); |
|
0 commit comments