Skip to content

Commit

Permalink
chore(): extract order types
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagosiebler committed Sep 13, 2024
1 parent 92e1573 commit 8805dae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/AdvancedTradeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from './lib/requestUtils.js';
import {
AllocateAdvTradePortfolioRequest,
CloseAdvTradePositionRequest,
GetAdvTradeFillsRequest,
GetAdvTradeMarketTradesRequest,
GetAdvTradeOrdersRequest,
Expand Down Expand Up @@ -342,12 +343,9 @@ export class AdvancedTradeClient extends BaseRestClient {
* Places an order to close any open positions for a specified product_id.
*
*/
closePosition(params: {
// TODO: extract type
client_order_id: string;
product_id: string;
size?: string;
}): Promise<AdvTradeClosePositionResponse> {
closePosition(
params: CloseAdvTradePositionRequest,
): Promise<AdvTradeClosePositionResponse> {
this.validateOrderId(params as any, 'client_order_id');
return this.postPrivate(`/api/v3/brokerage/orders/close_position`, {
body: params,
Expand Down
15 changes: 14 additions & 1 deletion src/types/request/advanced-trade-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export interface GetAdvTradeMarketTradesRequest {
/**
* Note: client_order_id is optional, because the SDK will automatically generate a value for you during the request.
*
* If you are generating your own, make sure you either use the client.generateNewOrderId() method or make sure to prefix your value with "cbnode". The SDK will automatically do this, if the prefix is missing.
* If you are generating your own, make sure you either use the client.generateNewOrderId() method or make sure to prefix your value with "cbnode".
* The SDK will automatically add the prefix if the prefix is missing.
*/
export interface SubmitAdvTradeOrderRequest {
client_order_id?: string;
Expand Down Expand Up @@ -123,6 +124,18 @@ export interface PreviewAdvTradeOrderRequest {
retail_portfolio_id?: string;
}

/**
* Note: client_order_id is optional, because the SDK will automatically generate a value for you during the request.
*
* If you are generating your own, make sure you either use the client.generateNewOrderId() method or make sure to prefix your value with "cbnode".
* The SDK will automatically add the prefix if the prefix is missing.
*/
export interface CloseAdvTradePositionRequest {
client_order_id?: string;
product_id: string;
size?: string;
}

/**
*
* Portfolios Endpoints
Expand Down

0 comments on commit 8805dae

Please sign in to comment.