diff --git a/.konfig/generate-id.txt b/.konfig/generate-id.txt
index c7ecfd6..90b3099 100644
--- a/.konfig/generate-id.txt
+++ b/.konfig/generate-id.txt
@@ -1 +1 @@
-8b72df76-d8c1-430c-906f-5166bc539e1b
\ No newline at end of file
+806a7e3d-c1f3-4a2d-aed7-9b89894bb6c2
\ No newline at end of file
diff --git a/README.md b/README.md
index e3dc7a8..298724a 100644
--- a/README.md
+++ b/README.md
@@ -68,6 +68,7 @@ Connect brokerage accounts to your app for live positions and trading
* [`snaptrade.trading.getUserAccountQuotes`](#snaptradetradinggetuseraccountquotes)
* [`snaptrade.trading.placeBracketOrder`](#snaptradetradingplacebracketorder)
* [`snaptrade.trading.placeForceOrder`](#snaptradetradingplaceforceorder)
+ * [`snaptrade.trading.placeMlegOrder`](#snaptradetradingplacemlegorder)
* [`snaptrade.trading.placeOrder`](#snaptradetradingplaceorder)
* [`snaptrade.trading.placeSimpleOrder`](#snaptradetradingplacesimpleorder)
* [`snaptrade.trading.previewSimpleOrder`](#snaptradetradingpreviewsimpleorder)
@@ -1314,7 +1315,7 @@ Places the option strategy order and returns the order record received from the
```php
$result = $snaptrade->options->placeOptionStrategy(
order_type: "Market",
- time_in_force: "FOK",
+ time_in_force: "Day",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
@@ -1826,7 +1827,7 @@ $result = $snaptrade->trading->getOrderImpact(
action: "BUY",
universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
order_type: "Market",
- time_in_force: "FOK",
+ time_in_force: "Day",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
price: 31.33,
@@ -1946,7 +1947,7 @@ $result = $snaptrade->trading->placeBracketOrder(
"type" => "EQUITY",
],
order_type: "Market",
- time_in_force: "FOK",
+ time_in_force: "Day",
stop_loss: [
"stop_price" => "48.55",
"limit_price" => "48.50",
@@ -2033,7 +2034,7 @@ $result = $snaptrade->trading->placeForceOrder(
account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
action: "BUY",
order_type: "Market",
- time_in_force: "FOK",
+ time_in_force: "Day",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
universal_symbol_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
@@ -2097,6 +2098,74 @@ For Equity orders, this represents the number of shares for the order. This can
---
+### `snaptrade.trading.placeMlegOrder`
+
+Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
+
+
+
+#### 🛠️ Usage
+
+```php
+$result = $snaptrade->trading->placeMlegOrder(
+ type: "MARKET",
+ time_in_force: "Day",
+ legs: [
+ [
+ "instrument" => [
+ "symbol" => "PBI 250718C00006000",
+ "type" => "OPTION",
+ ],
+ "action" => "BUY_TO_OPEN",
+ "units" => 1,
+ ]
+ ],
+ user_id: "snaptrade-user-123",
+ user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
+ account_id: "917c8734-8470-4a3e-a18f-57c3f2ee6631",
+ limit_price: "",
+ stop_price: ""
+);
+```
+
+#### ⚙️ Parameters
+
+##### type: `string`
+
+The type of order to place.
+
+##### time_in_force:
+
+##### legs: [`MlegLeg`](./lib/Model/MlegLeg.php)[]
+
+##### user_id: `string`
+
+##### user_secret: `string`
+
+##### account_id: `string`
+
+##### limit_price: `float`
+
+The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT.
+
+##### stop_price: `float`
+
+The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT.
+
+
+#### 🔄 Return
+
+[**MlegOrderResponse**](./lib/Model/MlegOrderResponse.php)
+
+#### 🌐 Endpoint
+
+`/accounts/{accountId}/trading/options` `POST`
+
+[🔙 **Back to Table of Contents**](#table-of-contents)
+
+---
+
+
### `snaptrade.trading.placeOrder`
Places the previously checked order with the brokerage. The `tradeId` is obtained from the [check order impact endpoint](/reference/Trading/Trading_getOrderImpact). If you prefer to place the order without checking for impact first, you can use the [place order endpoint](/reference/Trading/Trading_placeForceOrder).
@@ -2161,7 +2230,7 @@ $result = $snaptrade->trading->placeSimpleOrder(
],
side: "BUY",
type: "MARKET",
- time_in_force: "GTC",
+ time_in_force: "Day",
amount: "123.45",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
@@ -2183,9 +2252,7 @@ $result = $snaptrade->trading->placeSimpleOrder(
The type of order to place.
-##### time_in_force: `string`
-
-The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date.
+##### time_in_force:
##### amount: `float`
@@ -2243,7 +2310,7 @@ $result = $snaptrade->trading->previewSimpleOrder(
],
side: "BUY",
type: "MARKET",
- time_in_force: "GTC",
+ time_in_force: "Day",
amount: "123.45",
user_id: "snaptrade-user-123",
user_secret: "adf2aa34-8219-40f7-a6b3-60156985cc61",
@@ -2265,9 +2332,7 @@ $result = $snaptrade->trading->previewSimpleOrder(
The type of order to place.
-##### time_in_force: `string`
-
-The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date.
+##### time_in_force:
##### amount: `float`
@@ -2323,7 +2388,7 @@ returned in the response going forward. Only supported on some brokerages
$result = $snaptrade->trading->replaceOrder(
action: "BUY",
order_type: "Market",
- time_in_force: "FOK",
+ time_in_force: "Day",
account_id: "2bcd7cc3-e922-4976-bce1-9858296801c3",
brokerage_order_id: "66a033fa-da74-4fcf-b527-feefdec9257e",
user_id: "snaptrade-user-123",
diff --git a/lib/Api/TradingApi.php b/lib/Api/TradingApi.php
index 9e0c979..b54d4f5 100644
--- a/lib/Api/TradingApi.php
+++ b/lib/Api/TradingApi.php
@@ -83,6 +83,9 @@ class TradingApi extends \SnapTrade\CustomApi
'placeForceOrder' => [
'application/json',
],
+ 'placeMlegOrder' => [
+ 'application/json',
+ ],
'placeOrder' => [
'application/json',
],
@@ -3527,6 +3530,482 @@ public function placeForceOrderRequest($user_id, $user_secret, $manual_trade_for
];
}
+ /**
+ * Operation placeMlegOrder
+ *
+ * Place multi-leg option order
+ *
+ * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
+ *
+ * @param string $user_id user_id (required)
+ * @param string $user_secret user_secret (required)
+ * @param string $account_id account_id (required)
+ * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request trading_place_mleg_order_request (required)
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation
+ *
+ * @throws \SnapTrade\ApiException on non-2xx response
+ * @throws \InvalidArgumentException
+ * @return \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse
+ */
+ public function placeMlegOrder(
+
+ $type,
+ $time_in_force,
+ $legs,
+ $user_id,
+ $user_secret,
+ $account_id,
+ $limit_price = SENTINEL_VALUE,
+ $stop_price = SENTINEL_VALUE,
+ string $contentType = self::contentTypes['placeMlegOrder'][0]
+ )
+ {
+ $_body = [];
+ $this->setRequestBodyProperty($_body, "type", $type);
+ $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force);
+ $this->setRequestBodyProperty($_body, "limit_price", $limit_price);
+ $this->setRequestBodyProperty($_body, "stop_price", $stop_price);
+ $this->setRequestBodyProperty($_body, "legs", $legs);
+ $trading_place_mleg_order_request = $_body;
+
+ list($response) = $this->placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType);
+ return $response;
+ }
+
+ /**
+ * Operation placeMlegOrderWithHttpInfo
+ *
+ * Place multi-leg option order
+ *
+ * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
+ *
+ * @param string $user_id (required)
+ * @param string $user_secret (required)
+ * @param string $account_id (required)
+ * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required)
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation
+ *
+ * @throws \SnapTrade\ApiException on non-2xx response
+ * @throws \InvalidArgumentException
+ * @return array of \SnapTrade\Model\MlegOrderResponse|\SnapTrade\Model\Model400FailedRequestResponse, HTTP status code, HTTP response headers (array of strings)
+ */
+ public function placeMlegOrderWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions())
+ {
+ ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType);
+
+ // Customization hook
+ $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody);
+
+ try {
+ $options = $this->createHttpClientOption();
+ try {
+ $response = $this->client->send($request, $options);
+ } catch (RequestException $e) {
+ if (
+ ($e->getCode() == 401 || $e->getCode() == 403) &&
+ !empty($this->getConfig()->getAccessToken()) &&
+ $requestOptions->shouldRetryOAuth()
+ ) {
+ return $this->placeMlegOrderWithHttpInfo(
+ $user_id,
+ $user_secret,
+ $account_id,
+ $trading_place_mleg_order_request,
+ $contentType,
+ $requestOptions->setRetryOAuth(false)
+ );
+ }
+
+ throw new ApiException(
+ "[{$e->getCode()}] {$e->getMessage()}",
+ (int) $e->getCode(),
+ $e->getResponse() ? $e->getResponse()->getHeaders() : null,
+ $e->getResponse() ? (string) $e->getResponse()->getBody() : null
+ );
+ } catch (ConnectException $e) {
+ throw new ApiException(
+ "[{$e->getCode()}] {$e->getMessage()}",
+ (int) $e->getCode(),
+ null,
+ null
+ );
+ }
+
+ $statusCode = $response->getStatusCode();
+
+ if ($statusCode < 200 || $statusCode > 299) {
+ throw new ApiException(
+ sprintf(
+ '[%d] Error connecting to the API (%s)',
+ $statusCode,
+ (string) $request->getUri()
+ ),
+ $statusCode,
+ $response->getHeaders(),
+ (string) $response->getBody()
+ );
+ }
+
+ switch($statusCode) {
+ case 200:
+ if ('\SnapTrade\Model\MlegOrderResponse' === '\SplFileObject') {
+ $content = $response->getBody(); //stream goes to serializer
+ } else {
+ $content = (string) $response->getBody();
+ if ('\SnapTrade\Model\MlegOrderResponse' !== 'string') {
+ $content = json_decode($content);
+ }
+ }
+
+ return [
+ ObjectSerializer::deserialize($content, '\SnapTrade\Model\MlegOrderResponse', []),
+ $response->getStatusCode(),
+ $response->getHeaders()
+ ];
+ case 400:
+ if ('\SnapTrade\Model\Model400FailedRequestResponse' === '\SplFileObject') {
+ $content = $response->getBody(); //stream goes to serializer
+ } else {
+ $content = (string) $response->getBody();
+ if ('\SnapTrade\Model\Model400FailedRequestResponse' !== 'string') {
+ $content = json_decode($content);
+ }
+ }
+
+ return [
+ ObjectSerializer::deserialize($content, '\SnapTrade\Model\Model400FailedRequestResponse', []),
+ $response->getStatusCode(),
+ $response->getHeaders()
+ ];
+ }
+
+ $returnType = '\SnapTrade\Model\MlegOrderResponse';
+ if ($returnType === '\SplFileObject') {
+ $content = $response->getBody(); //stream goes to serializer
+ } else {
+ $content = (string) $response->getBody();
+ if ($returnType !== 'string') {
+ $content = json_decode($content);
+ }
+ }
+
+ return [
+ ObjectSerializer::deserialize($content, $returnType, []),
+ $response->getStatusCode(),
+ $response->getHeaders()
+ ];
+
+ } catch (ApiException $e) {
+ switch ($e->getCode()) {
+ case 200:
+ $data = ObjectSerializer::deserialize(
+ $e->getResponseBody(),
+ '\SnapTrade\Model\MlegOrderResponse',
+ $e->getResponseHeaders()
+ );
+ $e->setResponseObject($data);
+ break;
+ case 400:
+ $data = ObjectSerializer::deserialize(
+ $e->getResponseBody(),
+ '\SnapTrade\Model\Model400FailedRequestResponse',
+ $e->getResponseHeaders()
+ );
+ $e->setResponseObject($data);
+ break;
+ }
+ throw $e;
+ }
+ }
+
+ /**
+ * Operation placeMlegOrderAsync
+ *
+ * Place multi-leg option order
+ *
+ * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
+ *
+ * @param string $user_id (required)
+ * @param string $user_secret (required)
+ * @param string $account_id (required)
+ * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required)
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation
+ *
+ * @throws \InvalidArgumentException
+ * @return \GuzzleHttp\Promise\PromiseInterface
+ */
+ public function placeMlegOrderAsync(
+
+ $type,
+ $time_in_force,
+ $legs,
+ $user_id,
+ $user_secret,
+ $account_id,
+ $limit_price = SENTINEL_VALUE,
+ $stop_price = SENTINEL_VALUE,
+ string $contentType = self::contentTypes['placeMlegOrder'][0]
+ )
+ {
+ $_body = [];
+ $this->setRequestBodyProperty($_body, "type", $type);
+ $this->setRequestBodyProperty($_body, "time_in_force", $time_in_force);
+ $this->setRequestBodyProperty($_body, "limit_price", $limit_price);
+ $this->setRequestBodyProperty($_body, "stop_price", $stop_price);
+ $this->setRequestBodyProperty($_body, "legs", $legs);
+ $trading_place_mleg_order_request = $_body;
+
+ return $this->placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType)
+ ->then(
+ function ($response) {
+ return $response[0];
+ }
+ );
+ }
+
+ /**
+ * Operation placeMlegOrderAsyncWithHttpInfo
+ *
+ * Place multi-leg option order
+ *
+ * Places a multi-leg option order. Only supported on certain option trading brokerages. https://snaptrade.notion.site/brokerages has information on brokerage trading support
+ *
+ * @param string $user_id (required)
+ * @param string $user_secret (required)
+ * @param string $account_id (required)
+ * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required)
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation
+ *
+ * @throws \InvalidArgumentException
+ * @return \GuzzleHttp\Promise\PromiseInterface
+ */
+ public function placeMlegOrderAsyncWithHttpInfo($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, string $contentType = self::contentTypes['placeMlegOrder'][0], \SnapTrade\RequestOptions $requestOptions = new \SnapTrade\RequestOptions())
+ {
+ $returnType = '\SnapTrade\Model\MlegOrderResponse';
+ ["request" => $request, "serializedBody" => $serializedBody] = $this->placeMlegOrderRequest($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, $contentType);
+
+ // Customization hook
+ $this->beforeSendHook($request, $requestOptions, $this->config, $serializedBody);
+
+ return $this->client
+ ->sendAsync($request, $this->createHttpClientOption())
+ ->then(
+ function ($response) use ($returnType) {
+ if ($returnType === '\SplFileObject') {
+ $content = $response->getBody(); //stream goes to serializer
+ } else {
+ $content = (string) $response->getBody();
+ if ($returnType !== 'string') {
+ $content = json_decode($content);
+ }
+ }
+
+ return [
+ ObjectSerializer::deserialize($content, $returnType, []),
+ $response->getStatusCode(),
+ $response->getHeaders()
+ ];
+ },
+ function ($exception) {
+ $response = $exception->getResponse();
+ $statusCode = $response->getStatusCode();
+ throw new ApiException(
+ sprintf(
+ '[%d] Error connecting to the API (%s)',
+ $statusCode,
+ $exception->getRequest()->getUri()
+ ),
+ $statusCode,
+ $response->getHeaders(),
+ (string) $response->getBody()
+ );
+ }
+ );
+ }
+
+ /**
+ * Create request for operation 'placeMlegOrder'
+ *
+ * @param string $user_id (required)
+ * @param string $user_secret (required)
+ * @param string $account_id (required)
+ * @param \SnapTrade\Model\TradingPlaceMlegOrderRequest $trading_place_mleg_order_request (required)
+ * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeMlegOrder'] to see the possible values for this operation
+ *
+ * @throws \InvalidArgumentException
+ * @return \GuzzleHttp\Psr7\Request
+ */
+ public function placeMlegOrderRequest($user_id, $user_secret, $account_id, $trading_place_mleg_order_request, string $contentType = self::contentTypes['placeMlegOrder'][0])
+ {
+
+ // Check if $user_id is a string
+ if ($user_id !== SENTINEL_VALUE && !is_string($user_id)) {
+ throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_id, true), gettype($user_id)));
+ }
+ // verify the required parameter 'user_id' is set
+ if ($user_id === SENTINEL_VALUE || (is_array($user_id) && count($user_id) === 0)) {
+ throw new \InvalidArgumentException(
+ 'Missing the required parameter user_id when calling placeMlegOrder'
+ );
+ }
+ // Check if $user_secret is a string
+ if ($user_secret !== SENTINEL_VALUE && !is_string($user_secret)) {
+ throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($user_secret, true), gettype($user_secret)));
+ }
+ // verify the required parameter 'user_secret' is set
+ if ($user_secret === SENTINEL_VALUE || (is_array($user_secret) && count($user_secret) === 0)) {
+ throw new \InvalidArgumentException(
+ 'Missing the required parameter user_secret when calling placeMlegOrder'
+ );
+ }
+ // Check if $account_id is a string
+ if ($account_id !== SENTINEL_VALUE && !is_string($account_id)) {
+ throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($account_id, true), gettype($account_id)));
+ }
+ // verify the required parameter 'account_id' is set
+ if ($account_id === SENTINEL_VALUE || (is_array($account_id) && count($account_id) === 0)) {
+ throw new \InvalidArgumentException(
+ 'Missing the required parameter account_id when calling placeMlegOrder'
+ );
+ }
+ if ($trading_place_mleg_order_request !== SENTINEL_VALUE) {
+ if (!($trading_place_mleg_order_request instanceof \SnapTrade\Model\TradingPlaceMlegOrderRequest)) {
+ if (!is_array($trading_place_mleg_order_request))
+ throw new \InvalidArgumentException('"trading_place_mleg_order_request" must be associative array or an instance of \SnapTrade\Model\TradingPlaceMlegOrderRequest TradingApi.placeMlegOrder.');
+ else
+ $trading_place_mleg_order_request = new \SnapTrade\Model\TradingPlaceMlegOrderRequest($trading_place_mleg_order_request);
+ }
+ }
+ // verify the required parameter 'trading_place_mleg_order_request' is set
+ if ($trading_place_mleg_order_request === SENTINEL_VALUE || (is_array($trading_place_mleg_order_request) && count($trading_place_mleg_order_request) === 0)) {
+ throw new \InvalidArgumentException(
+ 'Missing the required parameter trading_place_mleg_order_request when calling placeMlegOrder'
+ );
+ }
+
+
+ $resourcePath = '/accounts/{accountId}/trading/options';
+ $formParams = [];
+ $queryParams = [];
+ $headerParams = [];
+ $httpBody = '';
+ $multipart = false;
+
+ if ($user_id !== SENTINEL_VALUE) {
+ // query params
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+ $user_id,
+ 'userId', // param base name
+ 'string', // openApiType
+ 'form', // style
+ true, // explode
+ true // required
+ ) ?? []);
+ }
+ if ($user_secret !== SENTINEL_VALUE) {
+ // query params
+ $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
+ $user_secret,
+ 'userSecret', // param base name
+ 'string', // openApiType
+ 'form', // style
+ true, // explode
+ true // required
+ ) ?? []);
+ }
+
+
+ // path params
+ if ($account_id !== SENTINEL_VALUE) {
+ $resourcePath = str_replace(
+ '{' . 'accountId' . '}',
+ ObjectSerializer::toPathValue($account_id),
+ $resourcePath
+ );
+ }
+
+
+ $headers = $this->headerSelector->selectHeaders(
+ ['application/json', ],
+ $contentType,
+ $multipart
+ );
+
+ // for model (json/xml)
+ if (isset($trading_place_mleg_order_request)) {
+ if (stripos($headers['Content-Type'], 'application/json') !== false) {
+ # if Content-Type contains "application/json", json_encode the body
+ $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($trading_place_mleg_order_request));
+ } else {
+ $httpBody = $trading_place_mleg_order_request;
+ }
+ } elseif (count($formParams) > 0) {
+ if ($multipart) {
+ $multipartContents = [];
+ foreach ($formParams as $formParamName => $formParamValue) {
+ $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
+ foreach ($formParamValueItems as $formParamValueItem) {
+ $multipartContents[] = [
+ 'name' => $formParamName,
+ 'contents' => $formParamValueItem
+ ];
+ }
+ }
+ // for HTTP post (form)
+ $httpBody = new MultipartStream($multipartContents);
+
+ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
+ # if Content-Type contains "application/json", json_encode the form parameters
+ $httpBody = \GuzzleHttp\json_encode($formParams);
+ } else {
+ // for HTTP post (form)
+ $httpBody = ObjectSerializer::buildQuery($formParams);
+ }
+ }
+
+ // this endpoint requires API key authentication
+ $apiKey = $this->config->getApiKeyWithPrefix('clientId');
+ if ($apiKey !== null) {
+ $queryParams['clientId'] = $apiKey;
+ }
+ // this endpoint requires API key authentication
+ $apiKey = $this->config->getApiKeyWithPrefix('Signature');
+ if ($apiKey !== null) {
+ $headers['Signature'] = $apiKey;
+ }
+ // this endpoint requires API key authentication
+ $apiKey = $this->config->getApiKeyWithPrefix('timestamp');
+ if ($apiKey !== null) {
+ $queryParams['timestamp'] = $apiKey;
+ }
+
+ $defaultHeaders = [];
+ if ($this->config->getUserAgent()) {
+ $defaultHeaders['User-Agent'] = $this->config->getUserAgent();
+ }
+
+ $headers = array_merge(
+ $defaultHeaders,
+ $headerParams,
+ $headers
+ );
+
+ $method = 'POST';
+ $this->beforeCreateRequestHook($method, $resourcePath, $queryParams, $headers, $httpBody);
+
+ $operationHost = $this->config->getHost();
+ $query = ObjectSerializer::buildQuery($queryParams);
+ return [
+ "request" => new Request(
+ $method,
+ $operationHost . $resourcePath . ($query ? "?{$query}" : ''),
+ $headers,
+ $httpBody
+ ),
+ "serializedBody" => $httpBody
+ ];
+ }
+
/**
* Operation placeOrder
*
diff --git a/lib/Model/MlegActionStrict.php b/lib/Model/MlegActionStrict.php
new file mode 100644
index 0000000..18137d4
--- /dev/null
+++ b/lib/Model/MlegActionStrict.php
@@ -0,0 +1,68 @@
+
+ */
+class MlegLeg implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+ public const DISCRIMINATOR = null;
+
+ /**
+ * The original name of the model.
+ *
+ * @var string
+ */
+ protected static $openAPIModelName = 'MlegLeg';
+
+ /**
+ * Array of property to type mappings. Used for (de)serialization
+ *
+ * @var string[]
+ */
+ protected static $openAPITypes = [
+ 'instrument' => '\SnapTrade\Model\MlegTradingInstrument',
+ 'action' => '\SnapTrade\Model\MlegActionStrict',
+ 'units' => 'int'
+ ];
+
+ /**
+ * Array of property to format mappings. Used for (de)serialization
+ *
+ * @var string[]
+ * @phpstan-var array
+ * @psalm-var array
+ */
+ protected static $openAPIFormats = [
+ 'instrument' => null,
+ 'action' => null,
+ 'units' => null
+ ];
+
+ /**
+ * Array of nullable properties. Used for (de)serialization
+ *
+ * @var boolean[]
+ */
+ protected static array $openAPINullables = [
+ 'instrument' => false,
+ 'action' => false,
+ 'units' => false
+ ];
+
+ /**
+ * If a nullable field gets set to null, insert it here
+ *
+ * @var boolean[]
+ */
+ protected array $openAPINullablesSetToNull = [];
+
+ /**
+ * Array of property to type mappings. Used for (de)serialization
+ *
+ * @return array
+ */
+ public static function openAPITypes()
+ {
+ return self::$openAPITypes;
+ }
+
+ /**
+ * Array of property to format mappings. Used for (de)serialization
+ *
+ * @return array
+ */
+ public static function openAPIFormats()
+ {
+ return self::$openAPIFormats;
+ }
+
+ /**
+ * Array of nullable properties
+ *
+ * @return array
+ */
+ protected static function openAPINullables(): array
+ {
+ return self::$openAPINullables;
+ }
+
+ /**
+ * Array of nullable field names deliberately set to null
+ *
+ * @return boolean[]
+ */
+ private function getOpenAPINullablesSetToNull(): array
+ {
+ return $this->openAPINullablesSetToNull;
+ }
+
+ /**
+ * Setter - Array of nullable field names deliberately set to null
+ *
+ * @param boolean[] $openAPINullablesSetToNull
+ */
+ private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+ {
+ $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+ }
+
+ /**
+ * Checks if a property is nullable
+ *
+ * @param string $property
+ * @return bool
+ */
+ public static function isNullable(string $property): bool
+ {
+ return self::openAPINullables()[$property] ?? false;
+ }
+
+ /**
+ * Checks if a nullable property is set to null.
+ *
+ * @param string $property
+ * @return bool
+ */
+ public function isNullableSetToNull(string $property): bool
+ {
+ return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+ }
+
+ /**
+ * Array of attributes where the key is the local name,
+ * and the value is the original name
+ *
+ * @var string[]
+ */
+ protected static $attributeMap = [
+ 'instrument' => 'instrument',
+ 'action' => 'action',
+ 'units' => 'units'
+ ];
+
+ /**
+ * Array of attributes to setter functions (for deserialization of responses)
+ *
+ * @var string[]
+ */
+ protected static $setters = [
+ 'instrument' => 'setInstrument',
+ 'action' => 'setAction',
+ 'units' => 'setUnits'
+ ];
+
+ /**
+ * Array of attributes to getter functions (for serialization of requests)
+ *
+ * @var string[]
+ */
+ protected static $getters = [
+ 'instrument' => 'getInstrument',
+ 'action' => 'getAction',
+ 'units' => 'getUnits'
+ ];
+
+ /**
+ * Array of attributes where the key is the local name,
+ * and the value is the original name
+ *
+ * @return array
+ */
+ public static function attributeMap()
+ {
+ return self::$attributeMap;
+ }
+
+ /**
+ * Array of attributes to setter functions (for deserialization of responses)
+ *
+ * @return array
+ */
+ public static function setters()
+ {
+ return self::$setters;
+ }
+
+ /**
+ * Array of attributes to getter functions (for serialization of requests)
+ *
+ * @return array
+ */
+ public static function getters()
+ {
+ return self::$getters;
+ }
+
+ /**
+ * The original name of the model.
+ *
+ * @return string
+ */
+ public function getModelName()
+ {
+ return self::$openAPIModelName;
+ }
+
+
+ /**
+ * Associative array for storing property values
+ *
+ * @var mixed[]
+ */
+ protected $container = [];
+
+ /**
+ * Constructor
+ *
+ * @param mixed[] $data Associated array of property values
+ * initializing the model
+ */
+ public function __construct(array $data = null)
+ {
+ $this->setIfExists('instrument', $data ?? [], null);
+ $this->setIfExists('action', $data ?? [], null);
+ $this->setIfExists('units', $data ?? [], null);
+ }
+
+ /**
+ * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+ * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+ * $this->openAPINullablesSetToNull array
+ *
+ * @param string $variableName
+ * @param array $fields
+ * @param mixed $defaultValue
+ */
+ private function setIfExists(string $variableName, array $fields, $defaultValue): void
+ {
+ if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+ $this->openAPINullablesSetToNull[] = $variableName;
+ }
+
+ $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+ }
+
+ /**
+ * Show all the invalid properties with reasons.
+ *
+ * @return array invalid properties with reasons
+ */
+ public function listInvalidProperties()
+ {
+ $invalidProperties = [];
+
+ if ($this->container['instrument'] === null) {
+ $invalidProperties[] = "'instrument' can't be null";
+ }
+ if ($this->container['action'] === null) {
+ $invalidProperties[] = "'action' can't be null";
+ }
+ if ($this->container['units'] === null) {
+ $invalidProperties[] = "'units' can't be null";
+ }
+ return $invalidProperties;
+ }
+
+ /**
+ * Validate all the properties in the model
+ * return true if all passed
+ *
+ * @return bool True if all properties are valid
+ */
+ public function valid()
+ {
+ return count($this->listInvalidProperties()) === 0;
+ }
+
+
+ /**
+ * Gets instrument
+ *
+ * @return \SnapTrade\Model\MlegTradingInstrument
+ */
+ public function getInstrument()
+ {
+ return $this->container['instrument'];
+ }
+
+ /**
+ * Sets instrument
+ *
+ * @param \SnapTrade\Model\MlegTradingInstrument $instrument instrument
+ *
+ * @return self
+ */
+ public function setInstrument($instrument)
+ {
+
+ if (is_null($instrument)) {
+ throw new \InvalidArgumentException('non-nullable instrument cannot be null');
+ }
+
+ $this->container['instrument'] = $instrument;
+
+ return $this;
+ }
+
+ /**
+ * Gets action
+ *
+ * @return \SnapTrade\Model\MlegActionStrict
+ */
+ public function getAction()
+ {
+ return $this->container['action'];
+ }
+
+ /**
+ * Sets action
+ *
+ * @param \SnapTrade\Model\MlegActionStrict $action action
+ *
+ * @return self
+ */
+ public function setAction($action)
+ {
+
+ if (is_null($action)) {
+ throw new \InvalidArgumentException('non-nullable action cannot be null');
+ }
+
+ $this->container['action'] = $action;
+
+ return $this;
+ }
+
+ /**
+ * Gets units
+ *
+ * @return int
+ */
+ public function getUnits()
+ {
+ return $this->container['units'];
+ }
+
+ /**
+ * Sets units
+ *
+ * @param int $units The quantity to trade. For options this represents the number of contracts. For equity this represents the number of shares.
+ *
+ * @return self
+ */
+ public function setUnits($units)
+ {
+
+ if (is_null($units)) {
+ throw new \InvalidArgumentException('non-nullable units cannot be null');
+ }
+
+ $this->container['units'] = $units;
+
+ return $this;
+ }
+ /**
+ * Returns true if offset exists. False otherwise.
+ *
+ * @param integer $offset Offset
+ *
+ * @return boolean
+ */
+ public function offsetExists($offset): bool
+ {
+ return isset($this->container[$offset]);
+ }
+
+ /**
+ * Gets offset.
+ *
+ * @param integer $offset Offset
+ *
+ * @return mixed|null
+ */
+ #[\ReturnTypeWillChange]
+ public function offsetGet($offset)
+ {
+ return $this->container[$offset] ?? null;
+ }
+
+ /**
+ * Sets value based on offset.
+ *
+ * @param int|null $offset Offset
+ * @param mixed $value Value to be set
+ *
+ * @return void
+ */
+ public function offsetSet($offset, $value): void
+ {
+ if (is_null($offset)) {
+ $this->container[] = $value;
+ } else {
+ $this->container[$offset] = $value;
+ }
+ }
+
+ /**
+ * Unsets offset.
+ *
+ * @param integer $offset Offset
+ *
+ * @return void
+ */
+ public function offsetUnset($offset): void
+ {
+ unset($this->container[$offset]);
+ }
+
+ /**
+ * Serializes the object to a value that can be serialized natively by json_encode().
+ * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+ *
+ * @return mixed Returns data which can be serialized by json_encode(), which is a value
+ * of any type other than a resource.
+ */
+ #[\ReturnTypeWillChange]
+ public function jsonSerialize()
+ {
+ return ObjectSerializer::sanitizeForSerialization($this);
+ }
+
+ /**
+ * Gets the string presentation of the object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return json_encode(
+ ObjectSerializer::sanitizeForSerialization($this),
+ JSON_PRETTY_PRINT
+ );
+ }
+
+ /**
+ * Gets a header-safe presentation of the object
+ *
+ * @return string
+ */
+ public function toHeaderValue()
+ {
+ return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+ }
+}
+
+
diff --git a/lib/Model/MlegOrderResponse.php b/lib/Model/MlegOrderResponse.php
new file mode 100644
index 0000000..73f9553
--- /dev/null
+++ b/lib/Model/MlegOrderResponse.php
@@ -0,0 +1,446 @@
+
+ */
+class MlegOrderResponse implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+ public const DISCRIMINATOR = null;
+
+ /**
+ * The original name of the model.
+ *
+ * @var string
+ */
+ protected static $openAPIModelName = 'MlegOrderResponse';
+
+ /**
+ * Array of property to type mappings. Used for (de)serialization
+ *
+ * @var string[]
+ */
+ protected static $openAPITypes = [
+ 'brokerage_order_id' => 'string',
+ 'orders' => '\SnapTrade\Model\AccountOrderRecord[]'
+ ];
+
+ /**
+ * Array of property to format mappings. Used for (de)serialization
+ *
+ * @var string[]
+ * @phpstan-var array
+ * @psalm-var array
+ */
+ protected static $openAPIFormats = [
+ 'brokerage_order_id' => null,
+ 'orders' => null
+ ];
+
+ /**
+ * Array of nullable properties. Used for (de)serialization
+ *
+ * @var boolean[]
+ */
+ protected static array $openAPINullables = [
+ 'brokerage_order_id' => false,
+ 'orders' => false
+ ];
+
+ /**
+ * If a nullable field gets set to null, insert it here
+ *
+ * @var boolean[]
+ */
+ protected array $openAPINullablesSetToNull = [];
+
+ /**
+ * Array of property to type mappings. Used for (de)serialization
+ *
+ * @return array
+ */
+ public static function openAPITypes()
+ {
+ return self::$openAPITypes;
+ }
+
+ /**
+ * Array of property to format mappings. Used for (de)serialization
+ *
+ * @return array
+ */
+ public static function openAPIFormats()
+ {
+ return self::$openAPIFormats;
+ }
+
+ /**
+ * Array of nullable properties
+ *
+ * @return array
+ */
+ protected static function openAPINullables(): array
+ {
+ return self::$openAPINullables;
+ }
+
+ /**
+ * Array of nullable field names deliberately set to null
+ *
+ * @return boolean[]
+ */
+ private function getOpenAPINullablesSetToNull(): array
+ {
+ return $this->openAPINullablesSetToNull;
+ }
+
+ /**
+ * Setter - Array of nullable field names deliberately set to null
+ *
+ * @param boolean[] $openAPINullablesSetToNull
+ */
+ private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+ {
+ $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+ }
+
+ /**
+ * Checks if a property is nullable
+ *
+ * @param string $property
+ * @return bool
+ */
+ public static function isNullable(string $property): bool
+ {
+ return self::openAPINullables()[$property] ?? false;
+ }
+
+ /**
+ * Checks if a nullable property is set to null.
+ *
+ * @param string $property
+ * @return bool
+ */
+ public function isNullableSetToNull(string $property): bool
+ {
+ return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+ }
+
+ /**
+ * Array of attributes where the key is the local name,
+ * and the value is the original name
+ *
+ * @var string[]
+ */
+ protected static $attributeMap = [
+ 'brokerage_order_id' => 'brokerage_order_id',
+ 'orders' => 'orders'
+ ];
+
+ /**
+ * Array of attributes to setter functions (for deserialization of responses)
+ *
+ * @var string[]
+ */
+ protected static $setters = [
+ 'brokerage_order_id' => 'setBrokerageOrderId',
+ 'orders' => 'setOrders'
+ ];
+
+ /**
+ * Array of attributes to getter functions (for serialization of requests)
+ *
+ * @var string[]
+ */
+ protected static $getters = [
+ 'brokerage_order_id' => 'getBrokerageOrderId',
+ 'orders' => 'getOrders'
+ ];
+
+ /**
+ * Array of attributes where the key is the local name,
+ * and the value is the original name
+ *
+ * @return array
+ */
+ public static function attributeMap()
+ {
+ return self::$attributeMap;
+ }
+
+ /**
+ * Array of attributes to setter functions (for deserialization of responses)
+ *
+ * @return array
+ */
+ public static function setters()
+ {
+ return self::$setters;
+ }
+
+ /**
+ * Array of attributes to getter functions (for serialization of requests)
+ *
+ * @return array
+ */
+ public static function getters()
+ {
+ return self::$getters;
+ }
+
+ /**
+ * The original name of the model.
+ *
+ * @return string
+ */
+ public function getModelName()
+ {
+ return self::$openAPIModelName;
+ }
+
+
+ /**
+ * Associative array for storing property values
+ *
+ * @var mixed[]
+ */
+ protected $container = [];
+
+ /**
+ * Constructor
+ *
+ * @param mixed[] $data Associated array of property values
+ * initializing the model
+ */
+ public function __construct(array $data = null)
+ {
+ $this->setIfExists('brokerage_order_id', $data ?? [], null);
+ $this->setIfExists('orders', $data ?? [], null);
+ }
+
+ /**
+ * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+ * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+ * $this->openAPINullablesSetToNull array
+ *
+ * @param string $variableName
+ * @param array $fields
+ * @param mixed $defaultValue
+ */
+ private function setIfExists(string $variableName, array $fields, $defaultValue): void
+ {
+ if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+ $this->openAPINullablesSetToNull[] = $variableName;
+ }
+
+ $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+ }
+
+ /**
+ * Show all the invalid properties with reasons.
+ *
+ * @return array invalid properties with reasons
+ */
+ public function listInvalidProperties()
+ {
+ $invalidProperties = [];
+
+ if ($this->container['brokerage_order_id'] === null) {
+ $invalidProperties[] = "'brokerage_order_id' can't be null";
+ }
+ if ($this->container['orders'] === null) {
+ $invalidProperties[] = "'orders' can't be null";
+ }
+ return $invalidProperties;
+ }
+
+ /**
+ * Validate all the properties in the model
+ * return true if all passed
+ *
+ * @return bool True if all properties are valid
+ */
+ public function valid()
+ {
+ return count($this->listInvalidProperties()) === 0;
+ }
+
+
+ /**
+ * Gets brokerage_order_id
+ *
+ * @return string
+ */
+ public function getBrokerageOrderId()
+ {
+ return $this->container['brokerage_order_id'];
+ }
+
+ /**
+ * Sets brokerage_order_id
+ *
+ * @param string $brokerage_order_id Order ID returned by brokerage. This is the unique identifier for the order in the brokerage system.
+ *
+ * @return self
+ */
+ public function setBrokerageOrderId($brokerage_order_id)
+ {
+
+ if (is_null($brokerage_order_id)) {
+ throw new \InvalidArgumentException('non-nullable brokerage_order_id cannot be null');
+ }
+
+ $this->container['brokerage_order_id'] = $brokerage_order_id;
+
+ return $this;
+ }
+
+ /**
+ * Gets orders
+ *
+ * @return \SnapTrade\Model\AccountOrderRecord[]
+ */
+ public function getOrders()
+ {
+ return $this->container['orders'];
+ }
+
+ /**
+ * Sets orders
+ *
+ * @param \SnapTrade\Model\AccountOrderRecord[] $orders orders
+ *
+ * @return self
+ */
+ public function setOrders($orders)
+ {
+
+ if (is_null($orders)) {
+ throw new \InvalidArgumentException('non-nullable orders cannot be null');
+ }
+
+ $this->container['orders'] = $orders;
+
+ return $this;
+ }
+ /**
+ * Returns true if offset exists. False otherwise.
+ *
+ * @param integer $offset Offset
+ *
+ * @return boolean
+ */
+ public function offsetExists($offset): bool
+ {
+ return isset($this->container[$offset]);
+ }
+
+ /**
+ * Gets offset.
+ *
+ * @param integer $offset Offset
+ *
+ * @return mixed|null
+ */
+ #[\ReturnTypeWillChange]
+ public function offsetGet($offset)
+ {
+ return $this->container[$offset] ?? null;
+ }
+
+ /**
+ * Sets value based on offset.
+ *
+ * @param int|null $offset Offset
+ * @param mixed $value Value to be set
+ *
+ * @return void
+ */
+ public function offsetSet($offset, $value): void
+ {
+ if (is_null($offset)) {
+ $this->container[] = $value;
+ } else {
+ $this->container[$offset] = $value;
+ }
+ }
+
+ /**
+ * Unsets offset.
+ *
+ * @param integer $offset Offset
+ *
+ * @return void
+ */
+ public function offsetUnset($offset): void
+ {
+ unset($this->container[$offset]);
+ }
+
+ /**
+ * Serializes the object to a value that can be serialized natively by json_encode().
+ * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+ *
+ * @return mixed Returns data which can be serialized by json_encode(), which is a value
+ * of any type other than a resource.
+ */
+ #[\ReturnTypeWillChange]
+ public function jsonSerialize()
+ {
+ return ObjectSerializer::sanitizeForSerialization($this);
+ }
+
+ /**
+ * Gets the string presentation of the object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return json_encode(
+ ObjectSerializer::sanitizeForSerialization($this),
+ JSON_PRETTY_PRINT
+ );
+ }
+
+ /**
+ * Gets a header-safe presentation of the object
+ *
+ * @return string
+ */
+ public function toHeaderValue()
+ {
+ return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+ }
+}
+
+
diff --git a/lib/Model/MlegTradingInstrument.php b/lib/Model/MlegTradingInstrument.php
new file mode 100644
index 0000000..897bff9
--- /dev/null
+++ b/lib/Model/MlegTradingInstrument.php
@@ -0,0 +1,480 @@
+
+ */
+class MlegTradingInstrument implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+ public const DISCRIMINATOR = null;
+
+ /**
+ * The original name of the model.
+ *
+ * @var string
+ */
+ protected static $openAPIModelName = 'MlegTradingInstrument';
+
+ /**
+ * Array of property to type mappings. Used for (de)serialization
+ *
+ * @var string[]
+ */
+ protected static $openAPITypes = [
+ 'symbol' => 'string',
+ 'type' => 'string'
+ ];
+
+ /**
+ * Array of property to format mappings. Used for (de)serialization
+ *
+ * @var string[]
+ * @phpstan-var array
+ * @psalm-var array
+ */
+ protected static $openAPIFormats = [
+ 'symbol' => null,
+ 'type' => null
+ ];
+
+ /**
+ * Array of nullable properties. Used for (de)serialization
+ *
+ * @var boolean[]
+ */
+ protected static array $openAPINullables = [
+ 'symbol' => false,
+ 'type' => false
+ ];
+
+ /**
+ * If a nullable field gets set to null, insert it here
+ *
+ * @var boolean[]
+ */
+ protected array $openAPINullablesSetToNull = [];
+
+ /**
+ * Array of property to type mappings. Used for (de)serialization
+ *
+ * @return array
+ */
+ public static function openAPITypes()
+ {
+ return self::$openAPITypes;
+ }
+
+ /**
+ * Array of property to format mappings. Used for (de)serialization
+ *
+ * @return array
+ */
+ public static function openAPIFormats()
+ {
+ return self::$openAPIFormats;
+ }
+
+ /**
+ * Array of nullable properties
+ *
+ * @return array
+ */
+ protected static function openAPINullables(): array
+ {
+ return self::$openAPINullables;
+ }
+
+ /**
+ * Array of nullable field names deliberately set to null
+ *
+ * @return boolean[]
+ */
+ private function getOpenAPINullablesSetToNull(): array
+ {
+ return $this->openAPINullablesSetToNull;
+ }
+
+ /**
+ * Setter - Array of nullable field names deliberately set to null
+ *
+ * @param boolean[] $openAPINullablesSetToNull
+ */
+ private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+ {
+ $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+ }
+
+ /**
+ * Checks if a property is nullable
+ *
+ * @param string $property
+ * @return bool
+ */
+ public static function isNullable(string $property): bool
+ {
+ return self::openAPINullables()[$property] ?? false;
+ }
+
+ /**
+ * Checks if a nullable property is set to null.
+ *
+ * @param string $property
+ * @return bool
+ */
+ public function isNullableSetToNull(string $property): bool
+ {
+ return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+ }
+
+ /**
+ * Array of attributes where the key is the local name,
+ * and the value is the original name
+ *
+ * @var string[]
+ */
+ protected static $attributeMap = [
+ 'symbol' => 'symbol',
+ 'type' => 'type'
+ ];
+
+ /**
+ * Array of attributes to setter functions (for deserialization of responses)
+ *
+ * @var string[]
+ */
+ protected static $setters = [
+ 'symbol' => 'setSymbol',
+ 'type' => 'setType'
+ ];
+
+ /**
+ * Array of attributes to getter functions (for serialization of requests)
+ *
+ * @var string[]
+ */
+ protected static $getters = [
+ 'symbol' => 'getSymbol',
+ 'type' => 'getType'
+ ];
+
+ /**
+ * Array of attributes where the key is the local name,
+ * and the value is the original name
+ *
+ * @return array
+ */
+ public static function attributeMap()
+ {
+ return self::$attributeMap;
+ }
+
+ /**
+ * Array of attributes to setter functions (for deserialization of responses)
+ *
+ * @return array
+ */
+ public static function setters()
+ {
+ return self::$setters;
+ }
+
+ /**
+ * Array of attributes to getter functions (for serialization of requests)
+ *
+ * @return array
+ */
+ public static function getters()
+ {
+ return self::$getters;
+ }
+
+ /**
+ * The original name of the model.
+ *
+ * @return string
+ */
+ public function getModelName()
+ {
+ return self::$openAPIModelName;
+ }
+
+ public const TYPE_OPTION = 'OPTION';
+ public const TYPE_EQUITY = 'EQUITY';
+
+ /**
+ * Gets allowable values of the enum
+ *
+ * @return string[]
+ */
+ public function getTypeAllowableValues()
+ {
+ return [
+ self::TYPE_OPTION,
+ self::TYPE_EQUITY,
+ ];
+ }
+
+ /**
+ * Associative array for storing property values
+ *
+ * @var mixed[]
+ */
+ protected $container = [];
+
+ /**
+ * Constructor
+ *
+ * @param mixed[] $data Associated array of property values
+ * initializing the model
+ */
+ public function __construct(array $data = null)
+ {
+ $this->setIfExists('symbol', $data ?? [], null);
+ $this->setIfExists('type', $data ?? [], null);
+ }
+
+ /**
+ * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+ * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+ * $this->openAPINullablesSetToNull array
+ *
+ * @param string $variableName
+ * @param array $fields
+ * @param mixed $defaultValue
+ */
+ private function setIfExists(string $variableName, array $fields, $defaultValue): void
+ {
+ if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+ $this->openAPINullablesSetToNull[] = $variableName;
+ }
+
+ $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+ }
+
+ /**
+ * Show all the invalid properties with reasons.
+ *
+ * @return array invalid properties with reasons
+ */
+ public function listInvalidProperties()
+ {
+ $invalidProperties = [];
+
+ if ($this->container['symbol'] === null) {
+ $invalidProperties[] = "'symbol' can't be null";
+ }
+ if ($this->container['type'] === null) {
+ $invalidProperties[] = "'type' can't be null";
+ }
+ $allowedValues = $this->getTypeAllowableValues();
+ if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) {
+ $invalidProperties[] = sprintf(
+ "invalid value '%s' for 'type', must be one of '%s'",
+ $this->container['type'],
+ implode("', '", $allowedValues)
+ );
+ }
+
+ return $invalidProperties;
+ }
+
+ /**
+ * Validate all the properties in the model
+ * return true if all passed
+ *
+ * @return bool True if all properties are valid
+ */
+ public function valid()
+ {
+ return count($this->listInvalidProperties()) === 0;
+ }
+
+
+ /**
+ * Gets symbol
+ *
+ * @return string
+ */
+ public function getSymbol()
+ {
+ return $this->container['symbol'];
+ }
+
+ /**
+ * Sets symbol
+ *
+ * @param string $symbol The security's trading ticker symbol. This currently supports stock symbols and Options symbols in the 21 character OCC format. For example \"AAPL 131124C00240000\" represents a call option on AAPL expiring on 2024-11-13 with a strike price of $240. For more information on the OCC format, see [here](https://en.wikipedia.org/wiki/Option_symbol#OCC_format)
+ *
+ * @return self
+ */
+ public function setSymbol($symbol)
+ {
+
+ if (is_null($symbol)) {
+ throw new \InvalidArgumentException('non-nullable symbol cannot be null');
+ }
+
+ $this->container['symbol'] = $symbol;
+
+ return $this;
+ }
+
+ /**
+ * Gets type
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->container['type'];
+ }
+
+ /**
+ * Sets type
+ *
+ * @param string $type The instrument's type
+ *
+ * @return self
+ */
+ public function setType($type)
+ {
+ $allowedValues = $this->getTypeAllowableValues();
+ if (!in_array($type, $allowedValues, true)) {
+ throw new \InvalidArgumentException(
+ sprintf(
+ "Invalid value '%s' for 'type', must be one of '%s'",
+ $type,
+ implode("', '", $allowedValues)
+ )
+ );
+ }
+
+ if (is_null($type)) {
+ throw new \InvalidArgumentException('non-nullable type cannot be null');
+ }
+
+ $this->container['type'] = $type;
+
+ return $this;
+ }
+ /**
+ * Returns true if offset exists. False otherwise.
+ *
+ * @param integer $offset Offset
+ *
+ * @return boolean
+ */
+ public function offsetExists($offset): bool
+ {
+ return isset($this->container[$offset]);
+ }
+
+ /**
+ * Gets offset.
+ *
+ * @param integer $offset Offset
+ *
+ * @return mixed|null
+ */
+ #[\ReturnTypeWillChange]
+ public function offsetGet($offset)
+ {
+ return $this->container[$offset] ?? null;
+ }
+
+ /**
+ * Sets value based on offset.
+ *
+ * @param int|null $offset Offset
+ * @param mixed $value Value to be set
+ *
+ * @return void
+ */
+ public function offsetSet($offset, $value): void
+ {
+ if (is_null($offset)) {
+ $this->container[] = $value;
+ } else {
+ $this->container[$offset] = $value;
+ }
+ }
+
+ /**
+ * Unsets offset.
+ *
+ * @param integer $offset Offset
+ *
+ * @return void
+ */
+ public function offsetUnset($offset): void
+ {
+ unset($this->container[$offset]);
+ }
+
+ /**
+ * Serializes the object to a value that can be serialized natively by json_encode().
+ * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+ *
+ * @return mixed Returns data which can be serialized by json_encode(), which is a value
+ * of any type other than a resource.
+ */
+ #[\ReturnTypeWillChange]
+ public function jsonSerialize()
+ {
+ return ObjectSerializer::sanitizeForSerialization($this);
+ }
+
+ /**
+ * Gets the string presentation of the object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return json_encode(
+ ObjectSerializer::sanitizeForSerialization($this),
+ JSON_PRETTY_PRINT
+ );
+ }
+
+ /**
+ * Gets a header-safe presentation of the object
+ *
+ * @return string
+ */
+ public function toHeaderValue()
+ {
+ return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+ }
+}
+
+
diff --git a/lib/Model/TimeInForceStrict.php b/lib/Model/TimeInForceStrict.php
index 66ae91c..06f7bb9 100644
--- a/lib/Model/TimeInForceStrict.php
+++ b/lib/Model/TimeInForceStrict.php
@@ -28,7 +28,7 @@
* TimeInForceStrict Class Doc Comment
*
* @category Class
- * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely.
+ * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.
* @package SnapTrade
*/
class TimeInForceStrict
@@ -42,6 +42,8 @@ class TimeInForceStrict
public const GTC = 'GTC';
+ public const IOC = 'IOC';
+
/**
* Gets allowable values of the enum
* @return string[]
@@ -51,7 +53,8 @@ public static function getAllowableEnumValues()
return [
self::FOK,
self::DAY,
- self::GTC
+ self::GTC,
+ self::IOC
];
}
}
diff --git a/lib/Model/TradingPlaceMlegOrderRequest.php b/lib/Model/TradingPlaceMlegOrderRequest.php
new file mode 100644
index 0000000..34e9972
--- /dev/null
+++ b/lib/Model/TradingPlaceMlegOrderRequest.php
@@ -0,0 +1,609 @@
+
+ */
+class TradingPlaceMlegOrderRequest implements ModelInterface, ArrayAccess, \JsonSerializable
+{
+ public const DISCRIMINATOR = null;
+
+ /**
+ * The original name of the model.
+ *
+ * @var string
+ */
+ protected static $openAPIModelName = 'Trading_placeMlegOrder_request';
+
+ /**
+ * Array of property to type mappings. Used for (de)serialization
+ *
+ * @var string[]
+ */
+ protected static $openAPITypes = [
+ 'type' => 'string',
+ 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict',
+ 'limit_price' => 'float',
+ 'stop_price' => 'float',
+ 'legs' => '\SnapTrade\Model\MlegLeg[]'
+ ];
+
+ /**
+ * Array of property to format mappings. Used for (de)serialization
+ *
+ * @var string[]
+ * @phpstan-var array
+ * @psalm-var array
+ */
+ protected static $openAPIFormats = [
+ 'type' => null,
+ 'time_in_force' => null,
+ 'limit_price' => 'decimal',
+ 'stop_price' => 'decimal',
+ 'legs' => null
+ ];
+
+ /**
+ * Array of nullable properties. Used for (de)serialization
+ *
+ * @var boolean[]
+ */
+ protected static array $openAPINullables = [
+ 'type' => false,
+ 'time_in_force' => false,
+ 'limit_price' => true,
+ 'stop_price' => true,
+ 'legs' => false
+ ];
+
+ /**
+ * If a nullable field gets set to null, insert it here
+ *
+ * @var boolean[]
+ */
+ protected array $openAPINullablesSetToNull = [];
+
+ /**
+ * Array of property to type mappings. Used for (de)serialization
+ *
+ * @return array
+ */
+ public static function openAPITypes()
+ {
+ return self::$openAPITypes;
+ }
+
+ /**
+ * Array of property to format mappings. Used for (de)serialization
+ *
+ * @return array
+ */
+ public static function openAPIFormats()
+ {
+ return self::$openAPIFormats;
+ }
+
+ /**
+ * Array of nullable properties
+ *
+ * @return array
+ */
+ protected static function openAPINullables(): array
+ {
+ return self::$openAPINullables;
+ }
+
+ /**
+ * Array of nullable field names deliberately set to null
+ *
+ * @return boolean[]
+ */
+ private function getOpenAPINullablesSetToNull(): array
+ {
+ return $this->openAPINullablesSetToNull;
+ }
+
+ /**
+ * Setter - Array of nullable field names deliberately set to null
+ *
+ * @param boolean[] $openAPINullablesSetToNull
+ */
+ private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
+ {
+ $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
+ }
+
+ /**
+ * Checks if a property is nullable
+ *
+ * @param string $property
+ * @return bool
+ */
+ public static function isNullable(string $property): bool
+ {
+ return self::openAPINullables()[$property] ?? false;
+ }
+
+ /**
+ * Checks if a nullable property is set to null.
+ *
+ * @param string $property
+ * @return bool
+ */
+ public function isNullableSetToNull(string $property): bool
+ {
+ return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
+ }
+
+ /**
+ * Array of attributes where the key is the local name,
+ * and the value is the original name
+ *
+ * @var string[]
+ */
+ protected static $attributeMap = [
+ 'type' => 'type',
+ 'time_in_force' => 'time_in_force',
+ 'limit_price' => 'limit_price',
+ 'stop_price' => 'stop_price',
+ 'legs' => 'legs'
+ ];
+
+ /**
+ * Array of attributes to setter functions (for deserialization of responses)
+ *
+ * @var string[]
+ */
+ protected static $setters = [
+ 'type' => 'setType',
+ 'time_in_force' => 'setTimeInForce',
+ 'limit_price' => 'setLimitPrice',
+ 'stop_price' => 'setStopPrice',
+ 'legs' => 'setLegs'
+ ];
+
+ /**
+ * Array of attributes to getter functions (for serialization of requests)
+ *
+ * @var string[]
+ */
+ protected static $getters = [
+ 'type' => 'getType',
+ 'time_in_force' => 'getTimeInForce',
+ 'limit_price' => 'getLimitPrice',
+ 'stop_price' => 'getStopPrice',
+ 'legs' => 'getLegs'
+ ];
+
+ /**
+ * Array of attributes where the key is the local name,
+ * and the value is the original name
+ *
+ * @return array
+ */
+ public static function attributeMap()
+ {
+ return self::$attributeMap;
+ }
+
+ /**
+ * Array of attributes to setter functions (for deserialization of responses)
+ *
+ * @return array
+ */
+ public static function setters()
+ {
+ return self::$setters;
+ }
+
+ /**
+ * Array of attributes to getter functions (for serialization of requests)
+ *
+ * @return array
+ */
+ public static function getters()
+ {
+ return self::$getters;
+ }
+
+ /**
+ * The original name of the model.
+ *
+ * @return string
+ */
+ public function getModelName()
+ {
+ return self::$openAPIModelName;
+ }
+
+ public const TYPE_MARKET = 'MARKET';
+ public const TYPE_LIMIT = 'LIMIT';
+ public const TYPE_STOP_LOSS_MARKET = 'STOP_LOSS_MARKET';
+ public const TYPE_STOP_LOSS_LIMIT = 'STOP_LOSS_LIMIT';
+
+ /**
+ * Gets allowable values of the enum
+ *
+ * @return string[]
+ */
+ public function getTypeAllowableValues()
+ {
+ return [
+ self::TYPE_MARKET,
+ self::TYPE_LIMIT,
+ self::TYPE_STOP_LOSS_MARKET,
+ self::TYPE_STOP_LOSS_LIMIT,
+ ];
+ }
+
+ /**
+ * Associative array for storing property values
+ *
+ * @var mixed[]
+ */
+ protected $container = [];
+
+ /**
+ * Constructor
+ *
+ * @param mixed[] $data Associated array of property values
+ * initializing the model
+ */
+ public function __construct(array $data = null)
+ {
+ $this->setIfExists('type', $data ?? [], null);
+ $this->setIfExists('time_in_force', $data ?? [], null);
+ $this->setIfExists('limit_price', $data ?? [], null);
+ $this->setIfExists('stop_price', $data ?? [], null);
+ $this->setIfExists('legs', $data ?? [], null);
+ }
+
+ /**
+ * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
+ * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
+ * $this->openAPINullablesSetToNull array
+ *
+ * @param string $variableName
+ * @param array $fields
+ * @param mixed $defaultValue
+ */
+ private function setIfExists(string $variableName, array $fields, $defaultValue): void
+ {
+ if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
+ $this->openAPINullablesSetToNull[] = $variableName;
+ }
+
+ $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
+ }
+
+ /**
+ * Show all the invalid properties with reasons.
+ *
+ * @return array invalid properties with reasons
+ */
+ public function listInvalidProperties()
+ {
+ $invalidProperties = [];
+
+ if ($this->container['type'] === null) {
+ $invalidProperties[] = "'type' can't be null";
+ }
+ $allowedValues = $this->getTypeAllowableValues();
+ if (!is_null($this->container['type']) && !in_array($this->container['type'], $allowedValues, true)) {
+ $invalidProperties[] = sprintf(
+ "invalid value '%s' for 'type', must be one of '%s'",
+ $this->container['type'],
+ implode("', '", $allowedValues)
+ );
+ }
+
+ if ($this->container['time_in_force'] === null) {
+ $invalidProperties[] = "'time_in_force' can't be null";
+ }
+ if ($this->container['legs'] === null) {
+ $invalidProperties[] = "'legs' can't be null";
+ }
+ return $invalidProperties;
+ }
+
+ /**
+ * Validate all the properties in the model
+ * return true if all passed
+ *
+ * @return bool True if all properties are valid
+ */
+ public function valid()
+ {
+ return count($this->listInvalidProperties()) === 0;
+ }
+
+
+ /**
+ * Gets type
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->container['type'];
+ }
+
+ /**
+ * Sets type
+ *
+ * @param string $type The type of order to place.
+ *
+ * @return self
+ */
+ public function setType($type)
+ {
+ $allowedValues = $this->getTypeAllowableValues();
+ if (!in_array($type, $allowedValues, true)) {
+ throw new \InvalidArgumentException(
+ sprintf(
+ "Invalid value '%s' for 'type', must be one of '%s'",
+ $type,
+ implode("', '", $allowedValues)
+ )
+ );
+ }
+
+ if (is_null($type)) {
+ throw new \InvalidArgumentException('non-nullable type cannot be null');
+ }
+
+ $this->container['type'] = $type;
+
+ return $this;
+ }
+
+ /**
+ * Gets time_in_force
+ *
+ * @return \SnapTrade\Model\TimeInForceStrict
+ */
+ public function getTimeInForce()
+ {
+ return $this->container['time_in_force'];
+ }
+
+ /**
+ * Sets time_in_force
+ *
+ * @param \SnapTrade\Model\TimeInForceStrict $time_in_force time_in_force
+ *
+ * @return self
+ */
+ public function setTimeInForce($time_in_force)
+ {
+
+ if (is_null($time_in_force)) {
+ throw new \InvalidArgumentException('non-nullable time_in_force cannot be null');
+ }
+
+ $this->container['time_in_force'] = $time_in_force;
+
+ return $this;
+ }
+
+ /**
+ * Gets limit_price
+ *
+ * @return float|null
+ */
+ public function getLimitPrice()
+ {
+ return $this->container['limit_price'];
+ }
+
+ /**
+ * Sets limit_price
+ *
+ * @param float|null $limit_price The limit price. Required if the order type is LIMIT, STOP_LOSS_LIMIT.
+ *
+ * @return self
+ */
+ public function setLimitPrice($limit_price)
+ {
+
+ if (is_null($limit_price)) {
+ array_push($this->openAPINullablesSetToNull, 'limit_price');
+ } else {
+ $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+ $index = array_search('limit_price', $nullablesSetToNull);
+ if ($index !== FALSE) {
+ unset($nullablesSetToNull[$index]);
+ $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+ }
+ }
+
+ $this->container['limit_price'] = $limit_price;
+
+ return $this;
+ }
+
+ /**
+ * Gets stop_price
+ *
+ * @return float|null
+ */
+ public function getStopPrice()
+ {
+ return $this->container['stop_price'];
+ }
+
+ /**
+ * Sets stop_price
+ *
+ * @param float|null $stop_price The stop price. Required if the order type is STOP_LOSS_MARKET, STOP_LOSS_LIMIT.
+ *
+ * @return self
+ */
+ public function setStopPrice($stop_price)
+ {
+
+ if (is_null($stop_price)) {
+ array_push($this->openAPINullablesSetToNull, 'stop_price');
+ } else {
+ $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
+ $index = array_search('stop_price', $nullablesSetToNull);
+ if ($index !== FALSE) {
+ unset($nullablesSetToNull[$index]);
+ $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
+ }
+ }
+
+ $this->container['stop_price'] = $stop_price;
+
+ return $this;
+ }
+
+ /**
+ * Gets legs
+ *
+ * @return \SnapTrade\Model\MlegLeg[]
+ */
+ public function getLegs()
+ {
+ return $this->container['legs'];
+ }
+
+ /**
+ * Sets legs
+ *
+ * @param \SnapTrade\Model\MlegLeg[] $legs legs
+ *
+ * @return self
+ */
+ public function setLegs($legs)
+ {
+
+ if (is_null($legs)) {
+ throw new \InvalidArgumentException('non-nullable legs cannot be null');
+ }
+
+ $this->container['legs'] = $legs;
+
+ return $this;
+ }
+ /**
+ * Returns true if offset exists. False otherwise.
+ *
+ * @param integer $offset Offset
+ *
+ * @return boolean
+ */
+ public function offsetExists($offset): bool
+ {
+ return isset($this->container[$offset]);
+ }
+
+ /**
+ * Gets offset.
+ *
+ * @param integer $offset Offset
+ *
+ * @return mixed|null
+ */
+ #[\ReturnTypeWillChange]
+ public function offsetGet($offset)
+ {
+ return $this->container[$offset] ?? null;
+ }
+
+ /**
+ * Sets value based on offset.
+ *
+ * @param int|null $offset Offset
+ * @param mixed $value Value to be set
+ *
+ * @return void
+ */
+ public function offsetSet($offset, $value): void
+ {
+ if (is_null($offset)) {
+ $this->container[] = $value;
+ } else {
+ $this->container[$offset] = $value;
+ }
+ }
+
+ /**
+ * Unsets offset.
+ *
+ * @param integer $offset Offset
+ *
+ * @return void
+ */
+ public function offsetUnset($offset): void
+ {
+ unset($this->container[$offset]);
+ }
+
+ /**
+ * Serializes the object to a value that can be serialized natively by json_encode().
+ * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
+ *
+ * @return mixed Returns data which can be serialized by json_encode(), which is a value
+ * of any type other than a resource.
+ */
+ #[\ReturnTypeWillChange]
+ public function jsonSerialize()
+ {
+ return ObjectSerializer::sanitizeForSerialization($this);
+ }
+
+ /**
+ * Gets the string presentation of the object
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return json_encode(
+ ObjectSerializer::sanitizeForSerialization($this),
+ JSON_PRETTY_PRINT
+ );
+ }
+
+ /**
+ * Gets a header-safe presentation of the object
+ *
+ * @return string
+ */
+ public function toHeaderValue()
+ {
+ return json_encode(ObjectSerializer::sanitizeForSerialization($this));
+ }
+}
+
+
diff --git a/lib/Model/TradingPlaceSimpleOrderRequest.php b/lib/Model/TradingPlaceSimpleOrderRequest.php
index 5ce098e..556e7de 100644
--- a/lib/Model/TradingPlaceSimpleOrderRequest.php
+++ b/lib/Model/TradingPlaceSimpleOrderRequest.php
@@ -53,7 +53,7 @@ class TradingPlaceSimpleOrderRequest implements ModelInterface, ArrayAccess, \Js
'instrument' => '\SnapTrade\Model\TradingInstrument',
'side' => '\SnapTrade\Model\ActionStrict',
'type' => 'string',
- 'time_in_force' => 'string',
+ 'time_in_force' => '\SnapTrade\Model\TimeInForceStrict',
'amount' => 'float',
'limit_price' => 'float',
'stop_price' => 'float',
@@ -275,10 +275,6 @@ public function getModelName()
public const TYPE_STOP_LOSS_LIMIT = 'STOP_LOSS_LIMIT';
public const TYPE_TAKE_PROFIT_MARKET = 'TAKE_PROFIT_MARKET';
public const TYPE_TAKE_PROFIT_LIMIT = 'TAKE_PROFIT_LIMIT';
- public const TIME_IN_FORCE_GTC = 'GTC';
- public const TIME_IN_FORCE_FOK = 'FOK';
- public const TIME_IN_FORCE_IOC = 'IOC';
- public const TIME_IN_FORCE_GTD = 'GTD';
/**
* Gets allowable values of the enum
@@ -297,21 +293,6 @@ public function getTypeAllowableValues()
];
}
- /**
- * Gets allowable values of the enum
- *
- * @return string[]
- */
- public function getTimeInForceAllowableValues()
- {
- return [
- self::TIME_IN_FORCE_GTC,
- self::TIME_IN_FORCE_FOK,
- self::TIME_IN_FORCE_IOC,
- self::TIME_IN_FORCE_GTD,
- ];
- }
-
/**
* Associative array for storing property values
*
@@ -386,15 +367,6 @@ public function listInvalidProperties()
if ($this->container['time_in_force'] === null) {
$invalidProperties[] = "'time_in_force' can't be null";
}
- $allowedValues = $this->getTimeInForceAllowableValues();
- if (!is_null($this->container['time_in_force']) && !in_array($this->container['time_in_force'], $allowedValues, true)) {
- $invalidProperties[] = sprintf(
- "invalid value '%s' for 'time_in_force', must be one of '%s'",
- $this->container['time_in_force'],
- implode("', '", $allowedValues)
- );
- }
-
if ($this->container['amount'] === null) {
$invalidProperties[] = "'amount' can't be null";
}
@@ -513,7 +485,7 @@ public function setType($type)
/**
* Gets time_in_force
*
- * @return string
+ * @return \SnapTrade\Model\TimeInForceStrict
*/
public function getTimeInForce()
{
@@ -523,22 +495,12 @@ public function getTimeInForce()
/**
* Sets time_in_force
*
- * @param string $time_in_force The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled. - `GTD` - Good Til Date. The order is valid until the specified date.
+ * @param \SnapTrade\Model\TimeInForceStrict $time_in_force time_in_force
*
* @return self
*/
public function setTimeInForce($time_in_force)
{
- $allowedValues = $this->getTimeInForceAllowableValues();
- if (!in_array($time_in_force, $allowedValues, true)) {
- throw new \InvalidArgumentException(
- sprintf(
- "Invalid value '%s' for 'time_in_force', must be one of '%s'",
- $time_in_force,
- implode("', '", $allowedValues)
- )
- );
- }
if (is_null($time_in_force)) {
throw new \InvalidArgumentException('non-nullable time_in_force cannot be null');
diff --git a/test/Api/TradingApiTest.php b/test/Api/TradingApiTest.php
index 07394f9..add1d24 100644
--- a/test/Api/TradingApiTest.php
+++ b/test/Api/TradingApiTest.php
@@ -142,6 +142,18 @@ public function testPlaceForceOrder()
$this->markTestIncomplete('Not implemented');
}
+ /**
+ * Test case for placeMlegOrder
+ *
+ * Place multi-leg option order.
+ *
+ */
+ public function testPlaceMlegOrder()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+
/**
* Test case for placeOrder
*
diff --git a/test/Model/MlegActionStrictTest.php b/test/Model/MlegActionStrictTest.php
new file mode 100644
index 0000000..ed89490
--- /dev/null
+++ b/test/Model/MlegActionStrictTest.php
@@ -0,0 +1,74 @@
+markTestIncomplete('Not implemented');
+ }
+}
diff --git a/test/Model/MlegLegTest.php b/test/Model/MlegLegTest.php
new file mode 100644
index 0000000..9fb2f12
--- /dev/null
+++ b/test/Model/MlegLegTest.php
@@ -0,0 +1,101 @@
+markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "instrument"
+ */
+ public function testPropertyInstrument()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "action"
+ */
+ public function testPropertyAction()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "units"
+ */
+ public function testPropertyUnits()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+}
diff --git a/test/Model/MlegOrderResponseTest.php b/test/Model/MlegOrderResponseTest.php
new file mode 100644
index 0000000..1c29091
--- /dev/null
+++ b/test/Model/MlegOrderResponseTest.php
@@ -0,0 +1,92 @@
+markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "brokerage_order_id"
+ */
+ public function testPropertyBrokerageOrderId()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "orders"
+ */
+ public function testPropertyOrders()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+}
diff --git a/test/Model/MlegTradingInstrumentTest.php b/test/Model/MlegTradingInstrumentTest.php
new file mode 100644
index 0000000..27e7cad
--- /dev/null
+++ b/test/Model/MlegTradingInstrumentTest.php
@@ -0,0 +1,92 @@
+markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "symbol"
+ */
+ public function testPropertySymbol()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "type"
+ */
+ public function testPropertyType()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+}
diff --git a/test/Model/TimeInForceStrictTest.php b/test/Model/TimeInForceStrictTest.php
index 228e9c8..45d137f 100644
--- a/test/Model/TimeInForceStrictTest.php
+++ b/test/Model/TimeInForceStrictTest.php
@@ -29,7 +29,7 @@
* TimeInForceStrictTest Class Doc Comment
*
* @category Class
- * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely.
+ * @description The Time in Force type for the order. This field indicates how long the order will remain active before it is executed or expires. Here are the supported values: - `Day` - Day. The order is valid only for the trading day on which it is placed. - `GTC` - Good Til Canceled. The order is valid until it is executed or canceled. - `FOK` - Fill Or Kill. The order must be executed in its entirety immediately or be canceled completely. - `IOC` - Immediate Or Cancel. The order must be executed immediately. Any portion of the order that cannot be filled immediately will be canceled.
* @package SnapTrade
*/
class TimeInForceStrictTest extends TestCase
diff --git a/test/Model/TradingPlaceMlegOrderRequestTest.php b/test/Model/TradingPlaceMlegOrderRequestTest.php
new file mode 100644
index 0000000..10cf01e
--- /dev/null
+++ b/test/Model/TradingPlaceMlegOrderRequestTest.php
@@ -0,0 +1,119 @@
+markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "type"
+ */
+ public function testPropertyType()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "time_in_force"
+ */
+ public function testPropertyTimeInForce()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "limit_price"
+ */
+ public function testPropertyLimitPrice()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "stop_price"
+ */
+ public function testPropertyStopPrice()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+
+ /**
+ * Test attribute "legs"
+ */
+ public function testPropertyLegs()
+ {
+ // TODO: implement
+ $this->markTestIncomplete('Not implemented');
+ }
+}