Method CreateOrderAsync
- Namespace
- WhalesSecret.TradeScriptLib.API.TradingV1
- Assembly
- WhalesSecret.TradeScriptLib.dll
CreateOrderAsync(LimitOrderRequest, CancellationToken)
Sends a new limit order request to the exchange.
Task<ILiveLimitOrder> CreateOrderAsync(LimitOrderRequest orderRequest, CancellationToken cancellationToken = default)
Parameters
orderRequest
LimitOrderRequestLimit order request.
cancellationToken
CancellationTokenCancellation token that allows the caller to cancel the operation.
Returns
- Task<ILiveLimitOrder>
ILiveLimitOrder when a response was received from the exchange and the order was accepted by the exchange.
Remarks
Note that if the operation is canceled, the order may still be placed.
Unlike other methods, it's not possible to safely follow the connection strategy when placing orders. If there is a network problem and we get disconnected from an exchange, other methods can be safely retried when the connection is re-established. However, when placing orders, the order may or may not be successfully placed when the disconnection happens. Therefore, it's not safe to repeat the operation when the connection is re-established. That is why this method may only wait for reconnection before the request to place the order was sent. After that if we get disconnected, the call fails.
Exceptions
- RejectedException
Thrown if the exchange rejected an order request.
- NotConnectedException
Thrown if the request could not be sent to the exchange.
- NotAvailableException
Thrown if the used connection has not been created with Trading support.
- ExchangeResponseTimeoutException
Thrown if exchange does not respond in timely manner.
- InvalidExchangeResponseException
Thrown if the exchange responded with invalid response.
- ExchangeIsUnderMaintenanceException
Thrown if the exchange is in maintenance mode and does not accept new requests.
- ApiRequestLimitReachedException
Thrown if the exchange rejected to create a new order due to an API rate limit.
- InvalidRequestDataException
Thrown if the exchange rejected to create a new order because some value in the order is malformed or otherwise invalid.
- InvalidArgumentException
Thrown if the order request is
null
, an unsupported exchange market is passed, or an invalid client order ID has been provided.- OperationCanceledException
Thrown if the operation was cancelled including cancellation due to shutdown or object disposal.
- NotConnectedTimeoutException
Thrown if the connection strategy associated with this instance is BlockUntilReconnectedOrTimeout with non-infinite timeout value and this timeout expired while the connection to the exchange is interrupted. That is, this exception does not limit the request itself, it rather limits the period of time that allows the client to recover from the interruption of the connection to the exchange.
- OperationFailedException
Thrown if the request failed for an unknown reason with an unknown outcome.
- BudgetExceededException
Thrown if a trading strategy budget is associated with the trade API client and placing the order would exceed the budget.
- BudgetCalculationException
Thrown if a trading strategy budget is associated with the trade API client and it is not possible to calculate whether an order would exceed it if it was placed.
CreateOrderAsync(MarketOrderRequest, CancellationToken)
Sends a new market order request to the exchange.
Task<ILiveMarketOrder> CreateOrderAsync(MarketOrderRequest orderRequest, CancellationToken cancellationToken = default)
Parameters
orderRequest
MarketOrderRequestMarket order request.
cancellationToken
CancellationTokenCancellation token that allows the caller to cancel the operation.
Returns
- Task<ILiveMarketOrder>
ILiveMarketOrder when a response was received from exchange and the order was accepted by the exchange.
Remarks
Note that if the operation is canceled, the order may still be placed.
Unlike other methods, it's not possible to safely follow the connection strategy when placing orders. If there is a network problem and we get disconnected from an exchange, other methods can be safely retried when the connection is re-established. However, when placing orders, the order may or may not be successfully placed when the disconnection happens. Therefore, it's not safe to repeat the operation when the connection is re-established. That is why this method may only wait for reconnection before the request to place the order was sent. After that if we get disconnected, the call fails.
Exceptions
- RejectedException
Thrown if the exchange rejected an order request.
- NotConnectedException
Thrown if the request could not be sent to the exchange.
- NotAvailableException
Thrown if the used connection has not been created with Trading support.
- ExchangeResponseTimeoutException
Thrown if exchange does not respond in timely manner.
- InvalidExchangeResponseException
Thrown if the exchange responded with invalid response.
- ExchangeIsUnderMaintenanceException
Thrown if the exchange is in maintenance mode and does not accept new requests.
- ApiRequestLimitReachedException
Thrown if the exchange rejected to create a new order due to an API rate limit.
- InvalidRequestDataException
Thrown if the exchange rejected to create a new order because some value in the order is malformed or otherwise invalid.
- InvalidArgumentException
Thrown if the order request is
null
, an unsupported exchange market is passed, or an invalid client order ID has been provided.- OperationCanceledException
Thrown if the operation was cancelled including cancellation due to shutdown or object disposal.
- NotConnectedTimeoutException
Thrown if the connection strategy associated with this instance is BlockUntilReconnectedOrTimeout with non-infinite timeout value and this timeout expired while the connection to the exchange is interrupted. That is, this exception does not limit the request itself, it rather limits the period of time that allows the client to recover from the interruption of the connection to the exchange.
- OperationFailedException
Thrown if the request failed for an unknown reason with an unknown outcome.
- BudgetExceededException
Thrown if a trading strategy budget is associated with the trade API client and placing the order would exceed the budget.
- BudgetCalculationException
Thrown if a trading strategy budget is associated with the trade API client and it is not possible to calculate whether an order would exceed it if it was placed.
CreateOrderAsync(StopLossOrderRequest, CancellationToken)
Sends a new stop-loss order request to the exchange.
Task<ILiveStopLossOrder> CreateOrderAsync(StopLossOrderRequest orderRequest, CancellationToken cancellationToken = default)
Parameters
orderRequest
StopLossOrderRequestStop-loss order request.
cancellationToken
CancellationTokenCancellation token that allows the caller to cancel the operation.
Returns
- Task<ILiveStopLossOrder>
ILiveStopLossOrder when a response was received from exchange and the order was accepted by the exchange.
Remarks
Note that if the operation is canceled, the order may still be placed.
Unlike other methods, it's not possible to safely follow the connection strategy when placing orders. If there is a network problem and we get disconnected from an exchange, other methods can be safely retried when the connection is re-established. However, when placing orders, the order may or may not be successfully placed when the disconnection happens. Therefore, it's not safe to repeat the operation when the connection is re-established. That is why this method may only wait for reconnection before the request to place the order was sent. After that if we get disconnected, the call fails.
Exceptions
- RejectedException
Thrown if the exchange rejected an order request.
- NotConnectedException
Thrown if the request could not be sent to the exchange.
- NotAvailableException
Thrown if the used connection has not been created with Trading support.
- ExchangeResponseTimeoutException
Thrown if exchange does not respond in timely manner.
- InvalidExchangeResponseException
Thrown if the exchange responded with invalid response.
- ExchangeIsUnderMaintenanceException
Thrown if the exchange is in maintenance mode and does not accept new requests.
- ApiRequestLimitReachedException
Thrown if the exchange rejected to create a new order due to an API rate limit.
- InvalidRequestDataException
Thrown if the exchange rejected to create a new order because some value in the order is malformed or otherwise invalid.
- InvalidArgumentException
Thrown if the order request is
null
, an unsupported exchange market is passed, or an invalid client order ID has been provided.- OperationCanceledException
Thrown if the operation was cancelled including cancellation due to shutdown or object disposal.
- NotConnectedTimeoutException
Thrown if the connection strategy associated with this instance is BlockUntilReconnectedOrTimeout with non-infinite timeout value and this timeout expired while the connection to the exchange is interrupted. That is, this exception does not limit the request itself, it rather limits the period of time that allows the client to recover from the interruption of the connection to the exchange.
- OperationFailedException
Thrown if the request failed for an unknown reason with an unknown outcome.
- BudgetExceededException
Thrown if a trading strategy budget is associated with the trade API client and placing the order would exceed the budget.
- BudgetCalculationException
Thrown if a trading strategy budget is associated with the trade API client and it is not possible to calculate whether an order would exceed it if it was placed.
CreateOrderAsync(StopLimitOrderRequest, CancellationToken)
Sends a new stop-limit order request to the exchange.
Task<ILiveStopLimitOrder> CreateOrderAsync(StopLimitOrderRequest orderRequest, CancellationToken cancellationToken = default)
Parameters
orderRequest
StopLimitOrderRequestStop-limit order request.
cancellationToken
CancellationTokenCancellation token that allows the caller to cancel the operation.
Returns
- Task<ILiveStopLimitOrder>
ILiveStopLimitOrder when a response was received from exchange and the order was accepted by the exchange.
Remarks
Note that if the operation is canceled, the order may still be placed.
Unlike other methods, it's not possible to safely follow the connection strategy when placing orders. If there is a network problem and we get disconnected from an exchange, other methods can be safely retried when the connection is re-established. However, when placing orders, the order may or may not be successfully placed when the disconnection happens. Therefore, it's not safe to repeat the operation when the connection is re-established. That is why this method may only wait for reconnection before the request to place the order was sent. After that if we get disconnected, the call fails.
Exceptions
- RejectedException
Thrown if the exchange rejected an order request.
- NotConnectedException
Thrown if the request could not be sent to the exchange.
- NotAvailableException
Thrown if the used connection has not been created with Trading support.
- ExchangeResponseTimeoutException
Thrown if exchange does not respond in timely manner.
- InvalidExchangeResponseException
Thrown if the exchange responded with invalid response.
- ExchangeIsUnderMaintenanceException
Thrown if the exchange is in maintenance mode and does not accept new requests.
- ApiRequestLimitReachedException
Thrown if the exchange rejected to create a new order due to an API rate limit.
- InvalidRequestDataException
Thrown if the exchange rejected to create a new order because some value in the order is malformed or otherwise invalid.
- InvalidArgumentException
Thrown if the order request is
null
, an unsupported exchange market is passed, or an invalid client order ID has been provided.- OperationCanceledException
Thrown if the operation was cancelled including cancellation due to shutdown or object disposal.
- NotConnectedTimeoutException
Thrown if the connection strategy associated with this instance is BlockUntilReconnectedOrTimeout with non-infinite timeout value and this timeout expired while the connection to the exchange is interrupted. That is, this exception does not limit the request itself, it rather limits the period of time that allows the client to recover from the interruption of the connection to the exchange.
- OperationFailedException
Thrown if the request failed for an unknown reason with an unknown outcome.
- BudgetExceededException
Thrown if a trading strategy budget is associated with the trade API client and placing the order would exceed the budget.
- BudgetCalculationException
Thrown if a trading strategy budget is associated with the trade API client and it is not possible to calculate whether an order would exceed it if it was placed.
CreateOrderAsync(TakeProfitOrderRequest, CancellationToken)
Sends a new take-profit order request to an exchange.
Task<ILiveTakeProfitOrder> CreateOrderAsync(TakeProfitOrderRequest orderRequest, CancellationToken cancellationToken = default)
Parameters
orderRequest
TakeProfitOrderRequestTake-profit order request.
cancellationToken
CancellationTokenCancellation token that allows the caller to cancel the operation.
Returns
- Task<ILiveTakeProfitOrder>
ILiveTakeProfitOrder when a response was received from exchange and the order was accepted by the exchange.
Remarks
Note that if the operation is canceled, the order may still be placed.
Unlike other methods, it's not possible to safely follow the connection strategy when placing orders. If there is a network problem and we get disconnected from an exchange, other methods can be safely retried when the connection is re-established. However, when placing orders, the order may or may not be successfully placed when the disconnection happens. Therefore, it's not safe to repeat the operation when the connection is re-established. That is why this method may only wait for reconnection before the request to place the order was sent. After that if we get disconnected, the call fails.
Exceptions
- RejectedException
Thrown if the exchange rejected an order request.
- NotConnectedException
Thrown if the request could not be sent to the exchange.
- NotAvailableException
Thrown if the used connection has not been created with Trading support.
- ExchangeResponseTimeoutException
Thrown if exchange does not respond in timely manner.
- InvalidExchangeResponseException
Thrown if the exchange responded with invalid response.
- ExchangeIsUnderMaintenanceException
Thrown if the exchange is in maintenance mode and does not accept new requests.
- ApiRequestLimitReachedException
Thrown if the exchange rejected to create a new order due to an API rate limit.
- InvalidRequestDataException
Thrown if the exchange rejected to create a new order because some value in the order is malformed or otherwise invalid.
- InvalidArgumentException
Thrown if the order request is
null
, an unsupported exchange market is passed, or an invalid client order ID has been provided.- OperationCanceledException
Thrown if the operation was cancelled including cancellation due to shutdown or object disposal.
- NotConnectedTimeoutException
Thrown if the connection strategy associated with this instance is BlockUntilReconnectedOrTimeout with non-infinite timeout value and this timeout expired while the connection to the exchange is interrupted. That is, this exception does not limit the request itself, it rather limits the period of time that allows the client to recover from the interruption of the connection to the exchange.
- OperationFailedException
Thrown if the request failed for an unknown reason with an unknown outcome.
- BudgetExceededException
Thrown if a trading strategy budget is associated with the trade API client and placing the order would exceed the budget.
- BudgetCalculationException
Thrown if a trading strategy budget is associated with the trade API client and it is not possible to calculate whether an order would exceed it if it was placed.
CreateOrderAsync(TakeProfitLimitOrderRequest, CancellationToken)
Sends a new take-profit-limit order request to the exchange.
Task<ILiveTakeProfitLimitOrder> CreateOrderAsync(TakeProfitLimitOrderRequest orderRequest, CancellationToken cancellationToken = default)
Parameters
orderRequest
TakeProfitLimitOrderRequestTake-profit-limit order request.
cancellationToken
CancellationTokenCancellation token that allows the caller to cancel the operation.
Returns
- Task<ILiveTakeProfitLimitOrder>
ILiveTakeProfitLimitOrder when a response was received from exchange and the order was accepted by the exchange.
Remarks
Note that if the operation is canceled, the order may still be placed.
Unlike other methods, it's not possible to safely follow the connection strategy when placing orders. If there is a network problem and we get disconnected from an exchange, other methods can be safely retried when the connection is re-established. However, when placing orders, the order may or may not be successfully placed when the disconnection happens. Therefore, it's not safe to repeat the operation when the connection is re-established. That is why this method may only wait for reconnection before the request to place the order was sent. After that if we get disconnected, the call fails.
Exceptions
- RejectedException
Thrown if the exchange rejected an order request.
- NotConnectedException
Thrown if the request could not be sent to the exchange.
- NotAvailableException
Thrown if the used connection has not been created with Trading support.
- ExchangeResponseTimeoutException
Thrown if exchange does not respond in timely manner.
- InvalidExchangeResponseException
Thrown if the exchange responded with invalid response.
- ExchangeIsUnderMaintenanceException
Thrown if the exchange is in maintenance mode and does not accept new requests.
- ApiRequestLimitReachedException
Thrown if the exchange rejected to create a new order due to an API rate limit.
- InvalidRequestDataException
Thrown if the exchange rejected to create a new order because some value in the order is malformed or otherwise invalid.
- InvalidArgumentException
Thrown if the order request is
null
, an unsupported exchange market is passed, or an invalid client order ID has been provided.- OperationCanceledException
Thrown if the operation was cancelled including cancellation due to shutdown or object disposal.
- NotConnectedTimeoutException
Thrown if the connection strategy associated with this instance is BlockUntilReconnectedOrTimeout with non-infinite timeout value and this timeout expired while the connection to the exchange is interrupted. That is, this exception does not limit the request itself, it rather limits the period of time that allows the client to recover from the interruption of the connection to the exchange.
- OperationFailedException
Thrown if the request failed for an unknown reason with an unknown outcome.
- BudgetExceededException
Thrown if a trading strategy budget is associated with the trade API client and placing the order would exceed the budget.
- BudgetCalculationException
Thrown if a trading strategy budget is associated with the trade API client and it is not possible to calculate whether an order would exceed it if it was placed.