Chartbreaker
    Preparing search index...

    Interface Session

    Representation of one specific broker session. Sessions are created using the broker.createSession function with a SessionToken.

    interface Session {
        authorizeOrderCancellation(
            portfolioId: string,
            order: string | CancelOrderOpts,
            authenticationMethodId: string,
            abortSignal?: AbortSignal_2,
        ): Promise<AuthorizedOperation<void>>;
        authorizePositionClosing?(
            portfolioId: string,
            orderId: string,
            size: number,
            authenticationMethodId: string,
            abortSignal?: AbortSignal_2,
        ): Promise<AuthorizedOperation<void>>;
        authorizeSessionTan(
            authenticationMethodId: string,
            abortSignal?: AbortSignal_2,
        ): Promise<AuthorizedOperation<void>>;
        checkValidity(): Promise<void>;
        createAuthorizationInfoObservable(): Observable<AuthorizationInfo>;
        createBuyingPowerObservable(
            portfolioId: string,
            clearingAccountId?: string,
        ): Observable<Amount>;
        createCurrentStopValueObservable?(
            portfolioId: string,
            orderId: string,
        ): Observable<Amount>;
        createOrderList(opts: OrderListOpts): OrderList;
        createPortfolioListObservable(): Observable<Portfolio[]>;
        createPortfolioQuotesObservable(
            portfolioId: string,
        ): Observable<PortfolioQuotes>;
        createPortfolioQuotesObservableSinceDate?(
            portfolioId: string,
            date: string,
        ): Observable<PortfolioQuotes>;
        createPositionQuotesAggregationObservable(
            portfolioId: string,
            positionIds: string[],
            realtimeCalculator?: RealtimeCalculator,
        ): Observable<
            {
                profitLossAbs?: Amount;
                profitLossNulledForXetraRealtime?: boolean;
                profitLossRel?: string;
                size: string;
            },
        >;
        createPositionQuotesObservable?(
            portfolioId: string,
            positionId: string,
        ): Observable<PositionQuotes>;
        createPositionsObservable(portfolioId: string): Observable<Position[]>;
        createPotentialProfitLossObservable?(
            portfolioId: string,
            orderId: string,
        ): Observable<PotentialOrderProfitLoss>;
        createSyncStatusObservable?(
            portfolioId: string,
        ): Observable<PortfolioSyncStatus>;
        createTradeSummaryWarningsObservable?(
            portfolioId: string,
        ): Observable<TradeSummaryWarningStatus>;
        createTradeTrackerObservable?(
            opts: { dateRanges: DateRange[]; portfolioId: string },
        ): Observable<TradeTrackerData>;
        createValidityObservable(): Observable<void>;
        destroy(): void;
        endSessionTan?(): Promise<SessionTanEndedResult>;
        getAdditionalActions?(): AdditionalAction[];
        getBroker(): Broker;
        getDetailedCostEstimationTable(
            costEstimationToken: string,
            signal?: AbortSignal_2,
        ): Promise<GenericTable>;
        getInstrumentInfoTable(
            token: string,
            signal?: AbortSignal_2,
        ): Promise<GenericTable>;
        getOrder(
            portfolioId: string,
            orderId: string,
            signal?: AbortSignal_2,
        ): Promise<Order>;
        getOrderListFulltextQueryFieldLabel?(view: OrderListView): string;
        getOrderListSupportedSortFields(view: OrderListView): string[];
        getPortfolio?(
            portfolioId: string,
            abortSignal?: AbortSignal_2,
        ): Promise<Portfolio>;
        getPortfolioList(abortSignal?: AbortSignal_2): Promise<Portfolio[]>;
        getRealtimeCalculator?(
            portfolioId: string,
            selectedExchangesStore?: SelectedExchangesStore,
        ): RealtimeCalculator;
        getSellPositions(
            portfolioId: string,
            instrumentId: string,
            abortSignal?: AbortSignal_2,
        ): Promise<SellPosition[]>;
        hintFullReloadMayBeAppropriate(): void;
        hintPositionReloadMayBeAppropriate(portfolioId: string): void;
        logout(): Promise<void>;
        prepareEditOrder(
            portfolioId: string,
            orderId: string,
            signal?: AbortSignal_2,
        ): Promise<PreparedEditOrder>;
        prepareInstrument(
            portfolioId: string,
            instrumentId: string,
            abortSignal?: AbortSignal_2,
        ): Promise<PreparedInstrument>;
        pxCreateCashTransaction?(
            data: PxCreateCashTransactionParams,
        ): Promise<PerformedOrder>;
        pxCreateDividendTransaction?(
            data: PxCreateDividendParams,
        ): Promise<PerformedOrder>;
        pxDeleteTransaction?(transactionId: string): Promise<void>;
        setPaused?(paused: boolean): void;
        updatePositionComment?(
            portfolioId: string,
            positionId: string,
            comment: string,
        ): Promise<void>;
        updatePositionExchangeId?(
            portfolioId: string,
            positionId: string,
            exchangeId: string,
        ): Promise<void>;
    }
    Index

    Methods

    • Prepare an order cancellation. This may prompt a challege (e.g. TAN). The resulting PreparedCancellation can then be perform()ed.

      Parameters

      • portfolioId: string

        id of the portfolio the order belongs to

      • order: string | CancelOrderOpts

        either the orderId as a string, or CancelOrderOpts

      • authenticationMethodId: string

        the authenticion method to use

      • OptionalabortSignal: AbortSignal_2

        to abort the request

      Returns Promise<AuthorizedOperation<void>>

    • Prepare an position closing. This may prompt a challege (e.g. TAN). The resulting PreparedCancellation can then be perform()ed. Used by CFD/FX broker

      Parameters

      • portfolioId: string

        id of the portfolio the order belongs to

      • orderId: string

        orderId

      • size: number

        which amount of the order should be closed

      • authenticationMethodId: string

        the authenticion method to use

      • OptionalabortSignal: AbortSignal_2

        to abort the request

      Returns Promise<AuthorizedOperation<void>>

    • Uses the given authenticationMethod to enable Session TAN.

      Parameters

      • authenticationMethodId: string

        the authentication method to use

      • OptionalabortSignal: AbortSignal_2

        to abort the request

      Returns Promise<AuthorizedOperation<void>>

    • Check if the session is (still) valid. If it's resolved, the session is valid. If it's rejected, it is not valid (anymore). The error may be a TradingError, indicating why it's not valid.

      Returns Promise<void>

    • Observe the buying power related to the given portfolio.

      Parameters

      • portfolioId: string
      • OptionalclearingAccountId: string

      Returns Observable<Amount>

    • If an order has mayObserveCurrentStop

      Parameters

      • portfolioId: string
      • orderId: string

      Returns Observable<Amount>

    • The list of portfolios can be subscribed, so that creation and deletion of portfolios can be handled during an active session.

      Returns Observable<Portfolio[]>

    • Observe quotes/keydata of the given portfolio, as provided by the broker (for realtime quotes, use getRealtimeCalculations instead).

      Parameters

      • portfolioId: string

        portfolio to observe

      Returns Observable<PortfolioQuotes>

    • If supported by broker, observe quotes/keydata of the given portfolio since the given date, as provided by the broker.

      Parameters

      • portfolioId: string

        portfolio to observe

      • date: string

      Returns Observable<PortfolioQuotes>

    • Aggregated performance information (currently size and P/L) for a set of positions, with the performance as it is provided by the positionQuotesObservable.

      Parameters

      • portfolioId: string
      • positionIds: string[]
      • OptionalrealtimeCalculator: RealtimeCalculator

        if the values provided by a realtime should be used, provide the instance here

      Returns Observable<
          {
              profitLossAbs?: Amount;
              profitLossNulledForXetraRealtime?: boolean;
              profitLossRel?: string;
              size: string;
          },
      >

    • Position quotes, as provided by the broker. It is possible that this is either not implemented at all, or never emits any quote. The initial quote should be read from the positions observable itself.

      Parameters

      • portfolioId: string
      • positionId: string

      Returns Observable<PositionQuotes>

    • Observe the positions of the given portfolio. Whenever the positions in the portfolio change, the new list is emitted.

      Parameters

      • portfolioId: string

        portfolio to subscribe to

      Returns Observable<Position[]>

    • If present, this can be used to compute the potential profit/loss of a given sell order, taking into account the average purchase price of the open position. It is converted to the portfolio currency.

      For trailing stop orders, this uses the current stop as defined by createCurrentStopObservable.

      Parameters

      • portfolioId: string

        the portfolioId

      • orderId: string

        the orderId

      Returns Observable<PotentialOrderProfitLoss>

    • If available for the broker, allows to observe the synchronization status of a portfolio.

      For example, if tradeStatsAvailable is true, trade statistics (= createTradeTrackerObservable and OrderLists with the view history) are available. As trade statistics rely on the order history being synced from the broker, this may take a while after login.

      It can be used to notify the user in the frontend (e.g. about their trading report).

      Parameters

      • portfolioId: string

        the portfolio to observe

      Returns Observable<PortfolioSyncStatus>

    • If available for the broker, this provides warning status regarding trade summaries. For example, it may indicate that FIFO calculations cannot be made because the order execution history is incomplete for some instruments.

      It can be visualized together with trade tracker or with trade history lists.

      Parameters

      • portfolioId: string

      Returns Observable<TradeSummaryWarningStatus>

    • Observe the session's validity. When the returned Observable ends with an error, the session has become invalid and should be destroyed. If the error is a TradingError, that may be displayed to the user.

      Returns Observable<void>

    • Frees resources assigned to the session (e.g. if it has some kind of ping to the broker, that will be cancelled). It does not perform a logout request, so it can be used to resume a session later (e.g. when apps go into background etc.) with the same sessionToken.

      Returns void

    • The broker that this session belongs to.

      Returns Broker

    • Get a detailed cost estimation table from a token generated by buildDetailedOrderCostEstimationToken.

      Parameters

      Returns Promise<GenericTable>

    • Get a detailed instrument info table from a token in PreparedInstrument.instrumentExplanation.infoTableToken

      Parameters

      • token: string

        token, as it can be retrived by PreparedInstrument.instrumentExplanation.infoTableToken

      • Optionalsignal: AbortSignal_2

        abortSignal

      Returns Promise<GenericTable>

    • Get order details (e.g. for order receipts).

      Parameters

      • portfolioId: string

        the order's portfolioId

      • orderId: string

        the orderId

      • Optionalsignal: AbortSignal_2

        to abort the operation

      Returns Promise<Order>

    • If present, this can be used to get the label for a fulltext search field in OrderLists of the given view. If this is not present, or if it returns null, no fulltext query can be applied.

      Parameters

      • view: OrderListView

        the order list view which should be displayed

      Returns string

    • Check which fields can be sorted by in the given order list view.

      Parameters

      • view: OrderListView

        the order list view which should be displayed

      Returns string[]

    • Get the list of portfolios that this session may access.

      Normally you should use createPortfolioListObservable instead to handle creation/deletion of portfolios during an active session. However for one-time actions, this will return the currently available (or next, when it's not loaded yet) portfolio list.

      Parameters

      Returns Promise<Portfolio[]>

    • By default, position and portfolio quotes are values provided by the broker (as in createPositionsObservable, createPositionQuotesObservable and createPortfolioQuotesObservable). However, it is possible to augment the broker data with the external instruments and quotes data in order to get more up-to-date values.

      If this is available for the given broker, a RealtimeCalculationsHelper can be created for a given portfolio (so the getRealtimeCalculations function is defined). If the user should be able to select the exchanges to use per instrument, a selectedExchangesStore with the user's selection can be provided.

      Parameters

      Returns RealtimeCalculator

    • Some brokers allow to sell instruments from a specific position. This may be the case when there are two different storage locations etc. In this case, the user must be allowed to choose the position they want to sell from.

      Parameters

      • portfolioId: string
      • instrumentId: string
      • OptionalabortSignal: AbortSignal_2

        to abort the request

      Returns Promise<SellPosition[]>

    • When the application detects that the network connection has been unstable or that the application may have been suspended for a while, it may be appropriate to reload certain data (e.g. open positions etc.). This function can be called to let the session reload that kind of data.

      Returns void

    • Positions may be cached aggressively by broker implementations. In that case, user interactions may indicate that it's time to reload (e.g. when users switch tabs, come back to the page after a while etc.). This function can be called so that the broker can decide whether a reload should be done.

      Parameters

      • portfolioId: string

        id of the affected portfolio

      Returns void

    • Ends the session at the broker.

      Returns Promise<void>

    • Prepare for edit order: find out in which ways the given order can be edited and provides to methods to actually perform an order updae.

      Parameters

      • portfolioId: string

        the order's portfolio

      • orderId: string

        the order id

      • Optionalsignal: AbortSignal_2

        to abort the preparation

      Returns Promise<PreparedEditOrder>

    • Prepare an instrument for trading in a given portfolio).

      Parameters

      • portfolioId: string

        id of the portfolio

      • instrumentId: string

        id of the instrument

      • OptionalabortSignal: AbortSignal_2

        to abort the preparation

      Returns Promise<PreparedInstrument>

    • Only available for the PX broker. Used to delete transactions in BoerseGo PX portfolios.

      Parameters

      • transactionId: string

      Returns Promise<void>

    • Pause or resume a session (e.g., if a browser tab gets hidden). Sessions may use this to pause expensive operations (e.g. unsubscribing from WebSocket channels).

      Parameters

      • paused: boolean

        if true, the session should be paused. If false, it should be resumed.

      Returns void

    • If present, a comment can be defined for a position (if position.commentIsEditable) using this method.

      Parameters

      • portfolioId: string

        the position's portfolioId

      • positionId: string

        the position id

      • comment: string

        the comment to set. null to delete the comment.

      Returns Promise<void>

    • If present, the selected exchange can be selected for a position. This is used to update the position.

      Parameters

      • portfolioId: string

        the position's portfolioId

      • positionId: string

        the position id

      • exchangeId: string

        the exchangeId to set, as defined in the instruments dependency

      Returns Promise<void>