Skip to content

Commit

Permalink
Documentation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rylorin committed Mar 9, 2024
1 parent 8b5bcd5 commit d0e4708
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 66 deletions.
103 changes: 52 additions & 51 deletions src/api-next/api-next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,13 @@ export class IBApiNext {
/**
* Response to API updateAccountValue control message.
*
* @param subscriptions: listeners
* @param account: The IBKR account Id.
* @param tag: the tag of the value.
* @param value: numetical value associated to the tag.
* @param currency: the currency of the value.
* @param subscriptions listeners
* @param account The IBKR account Id.
* @param tag the tag of the value.
* @param value numetical value associated to the tag.
* @param currency the currency of the value.
*
* @see [[reqOpenOrders]]
* @see [[reqAccountUpdates]]
*/
private readonly onUpdateAccountValue = (
subscriptions: Map<number, IBApiNextSubscription<AccountUpdate>>,
Expand Down Expand Up @@ -605,17 +605,17 @@ export class IBApiNext {
/**
* Response to API updatePortfolio control message.
*
* @param subscriptions: listeners
* @param contract: The position's [[Contract]]
* @param pos: The number of units held.
* @param marketPrice: the market price of the contract.
* @param marketValue: the market value of the position.
* @param avgCost: The average cost of the position.
* @param unrealizedPNL: The unrealized PNL of the position.
* @param realizedPNL: The realized PNL of the position.
* @param account: The IBKR account Id.
*
* @see [[reqOpenOrders]]
* @param subscriptions listeners
* @param contract The position's [[Contract]]
* @param pos The number of units held.
* @param marketPrice the market price of the contract.
* @param marketValue the market value of the position.
* @param avgCost The average cost of the position.
* @param unrealizedPNL The unrealized PNL of the position.
* @param realizedPNL The realized PNL of the position.
* @param account The IBKR account Id.
*
* @see [[reqAccountUpdates]]
*/
private readonly onUpdatePortfolio = (
subscriptions: Map<number, IBApiNextSubscription<AccountUpdate>>,
Expand Down Expand Up @@ -704,10 +704,10 @@ export class IBApiNext {
/**
* Response to API updateAccountTime control message.
*
* @param subscriptions: listeners
* @param timeStamp: the current timestamp
* @param subscriptions listeners
* @param timeStamp the current timestamp
*
* @see [[reqOpenOrders]]
* @see [[reqAccountUpdates]]
*/
private readonly onUpdateAccountTime = (
subscriptions: Map<number, IBApiNextSubscription<AccountUpdate>>,
Expand All @@ -728,10 +728,10 @@ export class IBApiNext {
/**
* Response to API accountDownloadEnd control message.
*
* @param subscriptions: listeners
* @param accountName: the account name
* @param subscriptions listeners
* @param accountName the account name
*
* @see [[reqOpenOrders]]
* @see [[reqAccountUpdates]]
*/
private readonly onAccountDownloadEnd = (
subscriptions: Map<number, IBApiNextSubscription<AccountUpdate>>,
Expand Down Expand Up @@ -1060,17 +1060,17 @@ export class IBApiNext {
* @param account Account for which to receive PnL updates.
* @param modelCode Specify to request PnL updates for a specific model.
*/
getPnL(account: string, model?: string): Observable<PnL> {
getPnL(account: string, modelCode?: string): Observable<PnL> {
return this.subscriptions
.register(
(reqId) => {
this.api.reqPnL(reqId, account, model);
this.api.reqPnL(reqId, account, modelCode);
},
(reqId) => {
this.api.cancelPnL(reqId);
},
[[EventName.pnl, this.onPnL]],
`${account}:${model}`,
`${account}:${modelCode}`,
)
.pipe(map((v: { all: PnL }) => v.all));
}
Expand Down Expand Up @@ -2548,11 +2548,11 @@ export class IBApiNext {
/**
* Feeds in currently open orders.
*
* @param subscriptions: listeners
* @param orderId: The order's unique id.
* @param contract: The order's [[Contract]]
* @param order: The currently active [[Order]]
* @param orderState: The order's [[OrderState]]
* @param subscriptions listeners
* @param orderId The order's unique id.
* @param contract The order's [[Contract]]
* @param order The currently active [[Order]]
* @param orderState The order's [[OrderState]]
*
* @see [[placeOrder]], [[reqAllOpenOrders]], [[reqAutoOpenOrders]]
*/
Expand Down Expand Up @@ -2608,7 +2608,7 @@ export class IBApiNext {

/**
* Ends the subscription once all openOrders are recieved
* @param subscriptions: listeners
* @param subscriptions listeners
*/
private readonly onOpenOrderComplete = (
subscriptions: Map<number, IBApiNextSubscription<OpenOrder[]>>,
Expand All @@ -2624,10 +2624,10 @@ export class IBApiNext {
/**
* Response to API bind order control message.
*
* @param subscriptions: listeners
* @param orderId: permId (mistake from IB documentation, value is orderId not permId)
* @param apiClientId: API client id.
* @param apiOrderId: API order id.
* @param subscriptions listeners
* @param orderId permId (mistake from IB documentation, value is orderId not permId)
* @param apiClientId API client id.
* @param apiOrderId API order id.
*
* @see [[reqOpenOrders]]
*/
Expand All @@ -2652,17 +2652,17 @@ export class IBApiNext {
/**
* Response to API status order control message.
*
* @param orderId
* @param status
* @param filled
* @param remaining
* @param avgFillPrice
* @param permId
* @param parentId
* @param lastFillPrice
* @param clientId
* @param whyHeld
* @param mktCapPrice
* @param orderId the order's client id.
* @param status the current status of the order. Possible values: PendingSubmit - indicates that you have transmitted the order, but have not yet received confirmation that it has been accepted by the order destination. PendingCancel - indicates that you have sent a request to cancel the order but have not yet received cancel confirmation from the order destination. At this point, your order is not confirmed canceled. It is not guaranteed that the cancellation will be successful. PreSubmitted - indicates that a simulated order type has been accepted by the IB system and that this order has yet to be elected. The order is held in the IB system until the election criteria are met. At that time the order is transmitted to the order destination as specified . Submitted - indicates that your order has been accepted by the system. ApiCancelled - after an order has been submitted and before it has been acknowledged, an API client client can request its cancelation, producing this state. Cancelled - indicates that the balance of your order has been confirmed canceled by the IB system. This could occur unexpectedly when IB or the destination has rejected your order. Filled - indicates that the order has been completely filled. Market orders executions will not always trigger a Filled status. Inactive - indicates that the order was received by the system but is no longer active because it was rejected or canceled.
* @param filled number of filled positions.
* @param remaining the remnant positions.
* @param avgFillPrice average filling price.
* @param permId the order's permId used by the TWS to identify orders.
* @param parentId parent's id. Used for bracket and auto trailing stop orders.
* @param lastFillPrice price at which the last positions were filled.
* @param clientId API client which submitted the order.
* @param whyHeld this field is used to identify an order held when TWS is trying to locate shares for a short sell. The value used to indicate this is 'locate'.
* @param mktCapPrice If an order has been capped, this indicates the current capped price. Requires TWS 967+ and API v973.04+. Python API specifically requires API v973.06+.
*
* @see [[reqOpenOrders]]
*/
Expand Down Expand Up @@ -2723,7 +2723,7 @@ export class IBApiNext {

/**
* Ends the subscription once all openOrders are recieved
* @param subscriptions: listeners
* @param subscriptions listeners
*/
private readonly onOpenOrderEnd = (
subscriptions: Map<number, IBApiNextSubscription<OpenOrder[]>>,
Expand Down Expand Up @@ -2886,10 +2886,11 @@ export class IBApiNext {
* Note: API clients cannot cancel individual orders placed by other clients.
* Use [[cancelAllOrders]] instead.
*
* @param id The order id.
* @param orderId Specify which order should be cancelled by its identifier.
* @param manualOrderCancelTime Specify the time the order should be cancelled. An empty string will cancel the order immediately.
*/
cancelOrder(id: number): void {
this.api.cancelOrder(id);
cancelOrder(orderId: number, manualOrderCancelTime?: string): void {
this.api.cancelOrder(orderId, manualOrderCancelTime);
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,14 @@ export class IBApi extends EventEmitter {
* Note: API clients cannot cancel individual orders placed by other clients.
* Use [[reqGlobalCancel]] instead.
*
* @param id The order's client id.
* @param orderId Specify which order should be cancelled by its identifier.
* @param manualOrderCancelTime Specify the time the order should be cancelled. An empty string will cancel the order immediately.
*
* @see [[placeOrder]], [[reqGlobalCancel]]
*/
cancelOrder(orderId: number): IBApi {
cancelOrder(orderId: number, manualOrderCancelTime?: string): IBApi {
this.controller.schedule(() =>
this.controller.encoder.cancelOrder(orderId),
this.controller.encoder.cancelOrder(orderId, manualOrderCancelTime),
);
return this;
}
Expand Down Expand Up @@ -737,7 +738,7 @@ export class IBApi extends EventEmitter {
* Requests event data from the wSH calendar.
*
* @param reqId The unique request identifier.
* @param conId Contract id of ticker or WshEventData describing wanted events.
* @param wshEventData Contract id (conId) of ticker or WshEventData describing wanted events.
*
* @see [[reqCancelWshEventData]]
*/
Expand Down
3 changes: 2 additions & 1 deletion src/api/order/condition/margin-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ export class MarginCondition implements OperatorCondition {
* Create a [[MarginCondition]] object.
*
* @param percent TODO document
* @param isMore TODO document
* @param conjunctionConnection Conjunction connection type.
*/
constructor(
public percent: number,
public isMore: boolean,
public conjunctionConnection: ConjunctionConnection
public conjunctionConnection: ConjunctionConnection,
) {}

get strValue(): string {
Expand Down
3 changes: 2 additions & 1 deletion src/api/order/condition/percent-change-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ export class PercentChangeCondition implements ContractCondition {
* @param percent TODO document
* @param conId The contract id.
* @param exchange The exchange code.
* @param isMore TODO document
* @param conjunctionConnection Conjunction connection type.
*/
constructor(
public percent: number,
public conId: number,
public exchange: string,
public isMore: boolean,
public conjunctionConnection: ConjunctionConnection
public conjunctionConnection: ConjunctionConnection,
) {}

get strValue(): string {
Expand Down
7 changes: 4 additions & 3 deletions src/api/order/condition/price-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export class PriceCondition implements ContractCondition {
/**
* Create a [[PriceCondition]] object.
*
* @param conId The contract id.
* @param exchange The exchange code.
* @param price TODO document
* @param triggerMethod TODO document
* @param conId The contract id.
* @param exchange The exchange code.
* @param isMore TODO document
* @param conjunctionConnection Conjunction connection type.
*/
constructor(
Expand All @@ -24,7 +25,7 @@ export class PriceCondition implements ContractCondition {
public conId: number,
public exchange: string,
public isMore: boolean,
public conjunctionConnection: ConjunctionConnection
public conjunctionConnection: ConjunctionConnection,
) {}

get strValue(): string {
Expand Down
3 changes: 2 additions & 1 deletion src/api/order/condition/time-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ export class TimeCondition implements OperatorCondition {
* Create a [[TimeCondition]] object.
*
* @param time Time field used in conditional order logic. Valid format: YYYYMMDD HH:MM:SS.
* @param isMore TODO
* @param conjunctionConnection Conjunction connection type.
*/
constructor(
public time: string,
public isMore: boolean,
public conjunctionConnection: ConjunctionConnection
public conjunctionConnection: ConjunctionConnection,
) {}

get strValue(): string {
Expand Down
4 changes: 2 additions & 2 deletions src/api/order/condition/volume-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export class VolumeCondition implements ContractCondition {
* @param volume TODO document
* @param conId The contract id.
* @param exchange The exchange code.
* @param triggerMethod TODO document
* @param isMore TODO document
* @param conjunctionConnection Conjunction connection type.
*/
constructor(
public volume: number,
public conId: number,
public exchange: string,
public isMore: boolean,
public conjunctionConnection: ConjunctionConnection
public conjunctionConnection: ConjunctionConnection,
) {}

get strValue(): string {
Expand Down
6 changes: 3 additions & 3 deletions src/core/io/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] {
/**
* Encode a CANCEL_ORDER message to an array of tokens.
*/
cancelOrder(id: number, manualCancelOrderTime?: string): void {
cancelOrder(orderId: number, manualCancelOrderTime?: string): void {
const version = 1;

if (
Expand All @@ -535,11 +535,11 @@ function tagValuesToTokens(tagValues: TagValue[]): unknown[] {
return this.emitError(
"It does not support manual order cancel time attribute",
ErrorCode.UPDATE_TWS,
id,
orderId,
);
}

const tokens: unknown[] = [OUT_MSG_ID.CANCEL_ORDER, version, id];
const tokens: unknown[] = [OUT_MSG_ID.CANCEL_ORDER, version, orderId];

if (this.serverVersion >= MIN_SERVER_VER.MANUAL_ORDER_TIME)
tokens.push(manualCancelOrderTime);
Expand Down

0 comments on commit d0e4708

Please sign in to comment.