@brokerize/client 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/authorizedApiContext.js +2 -3
  2. package/dist/cjs/authorizedApiContext.js +1 -2
  3. package/dist/cjs/errors.d.ts +14 -0
  4. package/dist/cjs/errors.js +48 -1
  5. package/dist/cjs/index.d.ts +2 -2
  6. package/dist/cjs/index.js +3 -4
  7. package/dist/cjs/modelExports.d.ts +1 -0
  8. package/dist/cjs/modelExports.js +3 -1
  9. package/dist/cjs/swagger/models/BrokerClientCfg.d.ts +7 -0
  10. package/dist/cjs/swagger/models/BrokerClientCfg.js +5 -0
  11. package/dist/cjs/swagger/models/BrokerMeta.d.ts +15 -0
  12. package/dist/cjs/swagger/models/BrokerMeta.js +2 -0
  13. package/dist/cjs/swagger/models/ClientConfigUpdateOAuthLoginForm.d.ts +12 -1
  14. package/dist/cjs/swagger/models/ClientConfigUpdateOAuthLoginForm.js +2 -0
  15. package/dist/cjs/swagger/models/OAuthLoginFormConfig.d.ts +12 -1
  16. package/dist/cjs/swagger/models/OAuthLoginFormConfig.js +2 -0
  17. package/dist/cjs/swagger/models/Order.d.ts +9 -1
  18. package/dist/cjs/swagger/models/OrderCreate.d.ts +2 -1
  19. package/dist/cjs/swagger/models/SmartbrokerClientCfg.d.ts +27 -0
  20. package/dist/cjs/swagger/models/SmartbrokerClientCfg.js +46 -0
  21. package/dist/cjs/swagger/models/SummarizedTrade.d.ts +14 -0
  22. package/dist/cjs/swagger/models/SummarizedTrade.js +4 -0
  23. package/dist/cjs/swagger/models/TradeWarning.d.ts +31 -1
  24. package/dist/cjs/swagger/models/TradeWarning.js +13 -0
  25. package/dist/cjs/swagger/models/TradeWarningReason.d.ts +45 -0
  26. package/dist/cjs/swagger/models/TradeWarningReason.js +58 -0
  27. package/dist/cjs/swagger/models/index.d.ts +2 -0
  28. package/dist/cjs/swagger/models/index.js +2 -0
  29. package/dist/client.d.ts +190 -15
  30. package/dist/errors.d.ts +14 -0
  31. package/dist/errors.js +45 -0
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +3 -5
  34. package/dist/modelExports.d.ts +1 -0
  35. package/dist/modelExports.js +1 -0
  36. package/dist/swagger/models/BrokerClientCfg.d.ts +7 -0
  37. package/dist/swagger/models/BrokerClientCfg.js +5 -0
  38. package/dist/swagger/models/BrokerMeta.d.ts +15 -0
  39. package/dist/swagger/models/BrokerMeta.js +2 -0
  40. package/dist/swagger/models/ClientConfigUpdateOAuthLoginForm.d.ts +12 -1
  41. package/dist/swagger/models/ClientConfigUpdateOAuthLoginForm.js +2 -0
  42. package/dist/swagger/models/OAuthLoginFormConfig.d.ts +12 -1
  43. package/dist/swagger/models/OAuthLoginFormConfig.js +2 -0
  44. package/dist/swagger/models/Order.d.ts +9 -1
  45. package/dist/swagger/models/OrderCreate.d.ts +2 -1
  46. package/dist/swagger/models/SmartbrokerClientCfg.d.ts +27 -0
  47. package/dist/swagger/models/SmartbrokerClientCfg.js +40 -0
  48. package/dist/swagger/models/SummarizedTrade.d.ts +14 -0
  49. package/dist/swagger/models/SummarizedTrade.js +4 -0
  50. package/dist/swagger/models/TradeWarning.d.ts +31 -1
  51. package/dist/swagger/models/TradeWarning.js +13 -0
  52. package/dist/swagger/models/TradeWarningReason.d.ts +45 -0
  53. package/dist/swagger/models/TradeWarningReason.js +52 -0
  54. package/dist/swagger/models/index.d.ts +2 -0
  55. package/dist/swagger/models/index.js +2 -0
  56. package/package.json +4 -4
@@ -0,0 +1,45 @@
1
+ /**
2
+ * brokerize
3
+ * The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
4
+ *
5
+ *
6
+ *
7
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
8
+ * https://openapi-generator.tech
9
+ * Do not edit the class manually.
10
+ */
11
+ /**
12
+ * Why a trade or portfolio-history computation could not give a complete answer. Clients switch on
13
+ * this instead of parsing `TradeWarning.message`, which is free text and may change at any time.
14
+ *
15
+ * - `executionsWithoutTimestamp`: order executions carry no execution time, so they cannot be placed
16
+ * on a timeline and were ignored altogether.
17
+ * - `inconsistentOrderHistory`: the executions of one security contradict each other or the reported
18
+ * holding (more sold than ever bought, a quantity that goes negative). Nothing can be reconstructed
19
+ * from them, so the security is left out of the value history and its trades are not reported.
20
+ * - `positionNotFullyExplained`: the order archive covers only part of a position — typical for
21
+ * brokers that return just the most recent weeks. What is held today is known, but its history
22
+ * reaches further back than the executions do.
23
+ * - `missingEodPrice`: no closing price was available for the security on some days; it was valued
24
+ * with the last price known before them.
25
+ * - `missingFxRate`: no exchange rate to the portfolio currency exists for the security's currency, so
26
+ * its amounts are *not* converted and the totals they enter are off by the conversion.
27
+ * - `unknownBuyPrice`: no purchase price could be determined for a position, so it is missing from the
28
+ * buy value (and from the profit it implies).
29
+ * - `realizedPnlUnavailable`: the completed trades could not be computed at all, which leaves the
30
+ * realized profit/loss empty rather than wrong.
31
+ * @export
32
+ */
33
+ export declare const TradeWarningReason: {
34
+ readonly ExecutionsWithoutTimestamp: "executionsWithoutTimestamp";
35
+ readonly InconsistentOrderHistory: "inconsistentOrderHistory";
36
+ readonly PositionNotFullyExplained: "positionNotFullyExplained";
37
+ readonly MissingEodPrice: "missingEodPrice";
38
+ readonly MissingFxRate: "missingFxRate";
39
+ readonly UnknownBuyPrice: "unknownBuyPrice";
40
+ readonly RealizedPnlUnavailable: "realizedPnlUnavailable";
41
+ };
42
+ export type TradeWarningReason = (typeof TradeWarningReason)[keyof typeof TradeWarningReason];
43
+ export declare function TradeWarningReasonFromJSON(json: any): TradeWarningReason;
44
+ export declare function TradeWarningReasonFromJSONTyped(json: any, ignoreDiscriminator: boolean): TradeWarningReason;
45
+ export declare function TradeWarningReasonToJSON(value?: TradeWarningReason | null): any;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * brokerize
6
+ * The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
7
+ *
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.TradeWarningReason = void 0;
16
+ exports.TradeWarningReasonFromJSON = TradeWarningReasonFromJSON;
17
+ exports.TradeWarningReasonFromJSONTyped = TradeWarningReasonFromJSONTyped;
18
+ exports.TradeWarningReasonToJSON = TradeWarningReasonToJSON;
19
+ /**
20
+ * Why a trade or portfolio-history computation could not give a complete answer. Clients switch on
21
+ * this instead of parsing `TradeWarning.message`, which is free text and may change at any time.
22
+ *
23
+ * - `executionsWithoutTimestamp`: order executions carry no execution time, so they cannot be placed
24
+ * on a timeline and were ignored altogether.
25
+ * - `inconsistentOrderHistory`: the executions of one security contradict each other or the reported
26
+ * holding (more sold than ever bought, a quantity that goes negative). Nothing can be reconstructed
27
+ * from them, so the security is left out of the value history and its trades are not reported.
28
+ * - `positionNotFullyExplained`: the order archive covers only part of a position — typical for
29
+ * brokers that return just the most recent weeks. What is held today is known, but its history
30
+ * reaches further back than the executions do.
31
+ * - `missingEodPrice`: no closing price was available for the security on some days; it was valued
32
+ * with the last price known before them.
33
+ * - `missingFxRate`: no exchange rate to the portfolio currency exists for the security's currency, so
34
+ * its amounts are *not* converted and the totals they enter are off by the conversion.
35
+ * - `unknownBuyPrice`: no purchase price could be determined for a position, so it is missing from the
36
+ * buy value (and from the profit it implies).
37
+ * - `realizedPnlUnavailable`: the completed trades could not be computed at all, which leaves the
38
+ * realized profit/loss empty rather than wrong.
39
+ * @export
40
+ */
41
+ exports.TradeWarningReason = {
42
+ ExecutionsWithoutTimestamp: "executionsWithoutTimestamp",
43
+ InconsistentOrderHistory: "inconsistentOrderHistory",
44
+ PositionNotFullyExplained: "positionNotFullyExplained",
45
+ MissingEodPrice: "missingEodPrice",
46
+ MissingFxRate: "missingFxRate",
47
+ UnknownBuyPrice: "unknownBuyPrice",
48
+ RealizedPnlUnavailable: "realizedPnlUnavailable",
49
+ };
50
+ function TradeWarningReasonFromJSON(json) {
51
+ return TradeWarningReasonFromJSONTyped(json, false);
52
+ }
53
+ function TradeWarningReasonFromJSONTyped(json, ignoreDiscriminator) {
54
+ return json;
55
+ }
56
+ function TradeWarningReasonToJSON(value) {
57
+ return value;
58
+ }
@@ -230,6 +230,7 @@ export * from "./SessionSyncInfoSyncedAllOf";
230
230
  export * from "./SessionSyncInfoSyncedSpecifics";
231
231
  export * from "./SetClientConfigRequest";
232
232
  export * from "./SizeUnitConstraint";
233
+ export * from "./SmartbrokerClientCfg";
233
234
  export * from "./StringMapByOrderModel";
234
235
  export * from "./SummarizedTrade";
235
236
  export * from "./SyncError";
@@ -256,6 +257,7 @@ export * from "./TradeStatisticsDateRange";
256
257
  export * from "./TradeStatisticsHoldingPeriodInDays";
257
258
  export * from "./TradeStatisticsItem";
258
259
  export * from "./TradeWarning";
260
+ export * from "./TradeWarningReason";
259
261
  export * from "./TradingSessionLifetime";
260
262
  export * from "./TrailingDistance";
261
263
  export * from "./TriggerSync200Response";
@@ -248,6 +248,7 @@ __exportStar(require("./SessionSyncInfoSyncedAllOf"), exports);
248
248
  __exportStar(require("./SessionSyncInfoSyncedSpecifics"), exports);
249
249
  __exportStar(require("./SetClientConfigRequest"), exports);
250
250
  __exportStar(require("./SizeUnitConstraint"), exports);
251
+ __exportStar(require("./SmartbrokerClientCfg"), exports);
251
252
  __exportStar(require("./StringMapByOrderModel"), exports);
252
253
  __exportStar(require("./SummarizedTrade"), exports);
253
254
  __exportStar(require("./SyncError"), exports);
@@ -274,6 +275,7 @@ __exportStar(require("./TradeStatisticsDateRange"), exports);
274
275
  __exportStar(require("./TradeStatisticsHoldingPeriodInDays"), exports);
275
276
  __exportStar(require("./TradeStatisticsItem"), exports);
276
277
  __exportStar(require("./TradeWarning"), exports);
278
+ __exportStar(require("./TradeWarningReason"), exports);
277
279
  __exportStar(require("./TradingSessionLifetime"), exports);
278
280
  __exportStar(require("./TrailingDistance"), exports);
279
281
  __exportStar(require("./TriggerSync200Response"), exports);
package/dist/client.d.ts CHANGED
@@ -1370,6 +1370,12 @@ declare interface BrokerClientCfg {
1370
1370
  * @memberof BrokerClientCfg
1371
1371
  */
1372
1372
  coinbase?: CoinbaseClientCfg;
1373
+ /**
1374
+ *
1375
+ * @type {SmartbrokerClientCfg}
1376
+ * @memberof BrokerClientCfg
1377
+ */
1378
+ smartbroker?: SmartbrokerClientCfg;
1373
1379
  }
1374
1380
 
1375
1381
  declare function BrokerClientCfgFromJSON(json: any): BrokerClientCfg;
@@ -1562,6 +1568,15 @@ export declare class BrokerizeError extends Error {
1562
1568
  constructor(statusCode: number, body: ErrorResponse);
1563
1569
  }
1564
1570
 
1571
+ /**
1572
+ * Thrown if a request to the brokerize API timed out (HTTP status 504). This is typically sent by
1573
+ * a load balancer or gateway in front of the API, so the response body usually is not a regular
1574
+ * `ErrorResponse`.
1575
+ */
1576
+ export declare class BrokerizeTimeoutError extends BrokerizeError {
1577
+ constructor(body: ErrorResponse);
1578
+ }
1579
+
1565
1580
  export declare interface BrokerizeWebSocketClient {
1566
1581
  subscribeInvalidate: (subscribe: SubscribeInvalidateDetails, callback: Callback) => Subscription;
1567
1582
  subscribeDecoupledOperation: (subscribe: Pick<SubscribeDecoupledOperation, "sessionId" | "decoupledOperationId">, callback: Callback) => Subscription;
@@ -1696,6 +1711,21 @@ declare interface BrokerMeta {
1696
1711
  * @memberof BrokerMeta
1697
1712
  */
1698
1713
  loginForm?: BrokerLoginForm;
1714
+ /**
1715
+ * All brokerize exchange ids this broker's exchanges are mapped to, ascending. Use it to tell
1716
+ * upfront which brokers may be relevant for a given exchange, e.g. to preselect brokers for a
1717
+ * security that is traded there.
1718
+ *
1719
+ * This is a static, broker-wide list: it means that brokerize knows how to translate between
1720
+ * this broker's exchanges and the listed ids, not that every security can be traded at every
1721
+ * one of them. The authoritative, security-specific list of tradable exchanges remains the
1722
+ * `exchanges` field of a prepared trade.
1723
+ *
1724
+ * Every id is contained in the `GetExchanges` response, so it can always be resolved to a name.
1725
+ * @type {Array<number>}
1726
+ * @memberof BrokerMeta
1727
+ */
1728
+ supportedExchangeIds: Array<number>;
1699
1729
  /**
1700
1730
  * If true, the user can login at the broker via OAuth (this involves browser redirects). Use `prepareOAuthRedirect` to obtain a URL to redirect to.
1701
1731
  * @type {boolean}
@@ -2978,13 +3008,22 @@ declare interface ClientConfigUpdateOAuthLoginForm {
2978
3008
  */
2979
3009
  logoUrlLight?: string;
2980
3010
  /**
3011
+ * How the browser is sent back to the `returnTo` URL after a successful broker login.
3012
+ *
3013
+ * `meta`, `js` and `link` render the interstitial callback screen and redirect from there (via a
3014
+ * meta refresh, via JavaScript, or by revealing a link the user clicks). `http` skips the screen
3015
+ * and answers the callback with a plain HTTP 302 instead.
2981
3016
  *
3017
+ * `http` only applies to `http`/`https` `returnTo` URLs. A `returnTo` in a custom app scheme
3018
+ * still gets the interstitial, because browsers handle a 302 into an app scheme inconsistently.
3019
+ *
3020
+ * Default is `meta`.
2982
3021
  * @type {string}
2983
3022
  * @memberof ClientConfigUpdateOAuthLoginForm
2984
3023
  */
2985
3024
  redirectStyle?: ClientConfigUpdateOAuthLoginFormRedirectStyleEnum;
2986
3025
  /**
2987
- *
3026
+ * Overrides `redirectStyle` for logins at bitpanda.
2988
3027
  * @type {string}
2989
3028
  * @memberof ClientConfigUpdateOAuthLoginForm
2990
3029
  */
@@ -3002,6 +3041,7 @@ declare const ClientConfigUpdateOAuthLoginFormRedirectStyleBitpandaEnum: {
3002
3041
  readonly Meta: "meta";
3003
3042
  readonly Js: "js";
3004
3043
  readonly Link: "link";
3044
+ readonly Http: "http";
3005
3045
  };
3006
3046
 
3007
3047
  declare type ClientConfigUpdateOAuthLoginFormRedirectStyleBitpandaEnum = (typeof ClientConfigUpdateOAuthLoginFormRedirectStyleBitpandaEnum)[keyof typeof ClientConfigUpdateOAuthLoginFormRedirectStyleBitpandaEnum];
@@ -3013,6 +3053,7 @@ declare const ClientConfigUpdateOAuthLoginFormRedirectStyleEnum: {
3013
3053
  readonly Meta: "meta";
3014
3054
  readonly Js: "js";
3015
3055
  readonly Link: "link";
3056
+ readonly Http: "http";
3016
3057
  };
3017
3058
 
3018
3059
  declare type ClientConfigUpdateOAuthLoginFormRedirectStyleEnum = (typeof ClientConfigUpdateOAuthLoginFormRedirectStyleEnum)[keyof typeof ClientConfigUpdateOAuthLoginFormRedirectStyleEnum];
@@ -7928,6 +7969,7 @@ declare namespace Models {
7928
7969
  OrderIntentAvailability,
7929
7970
  SummarizedTrade,
7930
7971
  TradeWarning,
7972
+ TradeWarningReason,
7931
7973
  GetPortfolioTradesResponse,
7932
7974
  GetPortfolioTradeStatisticsResponse,
7933
7975
  TradeStatisticsItem,
@@ -7982,13 +8024,22 @@ declare interface OAuthLoginFormConfig {
7982
8024
  */
7983
8025
  logoUrlLight?: string;
7984
8026
  /**
8027
+ * How the browser is sent back to the `returnTo` URL after a successful broker login.
8028
+ *
8029
+ * `meta`, `js` and `link` render the interstitial callback screen and redirect from there (via a
8030
+ * meta refresh, via JavaScript, or by revealing a link the user clicks). `http` skips the screen
8031
+ * and answers the callback with a plain HTTP 302 instead.
7985
8032
  *
8033
+ * `http` only applies to `http`/`https` `returnTo` URLs. A `returnTo` in a custom app scheme
8034
+ * still gets the interstitial, because browsers handle a 302 into an app scheme inconsistently.
8035
+ *
8036
+ * Default is `meta`.
7986
8037
  * @type {string}
7987
8038
  * @memberof OAuthLoginFormConfig
7988
8039
  */
7989
8040
  redirectStyle?: OAuthLoginFormConfigRedirectStyleEnum;
7990
8041
  /**
7991
- *
8042
+ * Overrides `redirectStyle` for logins at bitpanda.
7992
8043
  * @type {string}
7993
8044
  * @memberof OAuthLoginFormConfig
7994
8045
  */
@@ -8006,6 +8057,7 @@ declare const OAuthLoginFormConfigRedirectStyleBitpandaEnum: {
8006
8057
  readonly Meta: "meta";
8007
8058
  readonly Js: "js";
8008
8059
  readonly Link: "link";
8060
+ readonly Http: "http";
8009
8061
  };
8010
8062
 
8011
8063
  declare type OAuthLoginFormConfigRedirectStyleBitpandaEnum = (typeof OAuthLoginFormConfigRedirectStyleBitpandaEnum)[keyof typeof OAuthLoginFormConfigRedirectStyleBitpandaEnum];
@@ -8017,6 +8069,7 @@ declare const OAuthLoginFormConfigRedirectStyleEnum: {
8017
8069
  readonly Meta: "meta";
8018
8070
  readonly Js: "js";
8019
8071
  readonly Link: "link";
8072
+ readonly Http: "http";
8020
8073
  };
8021
8074
 
8022
8075
  declare type OAuthLoginFormConfigRedirectStyleEnum = (typeof OAuthLoginFormConfigRedirectStyleEnum)[keyof typeof OAuthLoginFormConfigRedirectStyleEnum];
@@ -9404,6 +9457,11 @@ declare namespace openApiClient {
9404
9457
  SizeUnitConstraintToJSONRecursive,
9405
9458
  SizeUnitConstraintToJSON,
9406
9459
  SizeUnitConstraint,
9460
+ SmartbrokerClientCfgFromJSON,
9461
+ SmartbrokerClientCfgFromJSONTyped,
9462
+ SmartbrokerClientCfgToJSONRecursive,
9463
+ SmartbrokerClientCfgToJSON,
9464
+ SmartbrokerClientCfg,
9407
9465
  StringMapByOrderModelFromJSON,
9408
9466
  StringMapByOrderModelFromJSONTyped,
9409
9467
  StringMapByOrderModelToJSONRecursive,
@@ -9538,6 +9596,10 @@ declare namespace openApiClient {
9538
9596
  TradeWarningToJSONRecursive,
9539
9597
  TradeWarningToJSON,
9540
9598
  TradeWarning,
9599
+ TradeWarningReasonFromJSON,
9600
+ TradeWarningReasonFromJSONTyped,
9601
+ TradeWarningReasonToJSON,
9602
+ TradeWarningReason,
9541
9603
  TradingSessionLifetimeFromJSON,
9542
9604
  TradingSessionLifetimeFromJSONTyped,
9543
9605
  TradingSessionLifetimeToJSON,
@@ -9639,7 +9701,14 @@ declare interface Order {
9639
9701
  */
9640
9702
  bondCurrencyIso?: string;
9641
9703
  /**
9704
+ * The id of the exchange, as defined by the *broker*.
9705
+ *
9706
+ * When reading an order this **can be an empty string**: not every order is traded on an exchange -- a securities
9707
+ * account transfer, for example, is booked into or out of the custody account and has no trading venue, so the
9708
+ * broker reports no exchange for it. Clients must handle the empty string.
9642
9709
  *
9710
+ * Note that this field will become optional in a future version of the API, so clients should not rely on it
9711
+ * being present at all. For creating an order it stays required, see `OrderCreate`.
9643
9712
  * @type {string}
9644
9713
  * @memberof Order
9645
9714
  */
@@ -9723,7 +9792,8 @@ declare interface Order {
9723
9792
  */
9724
9793
  exchangeName?: string;
9725
9794
  /**
9726
- * For fully executed orders: the timestamp of the *latest* execution.
9795
+ * For orders with at least one execution (`executed`, `open_executed`, `canceled_executed`):
9796
+ * the timestamp of the *latest* execution.
9727
9797
  * @type {Date}
9728
9798
  * @memberof Order
9729
9799
  */
@@ -10188,7 +10258,8 @@ declare function OrderCostEstimationToJSONRecursive(value?: OrderCostEstimation
10188
10258
  */
10189
10259
  declare interface OrderCreate {
10190
10260
  /**
10191
- *
10261
+ * The id of the exchange, as defined by the *broker*. Always required to create an order, and never empty --
10262
+ * unlike when reading an order, where the broker may report no exchange (see `OrderBase.brokerExchangeId`).
10192
10263
  * @type {string}
10193
10264
  * @memberof OrderCreate
10194
10265
  */
@@ -13609,6 +13680,38 @@ declare function SizeUnitConstraintToJSON(value?: SizeUnitConstraint | null): an
13609
13680
 
13610
13681
  declare function SizeUnitConstraintToJSONRecursive(value?: SizeUnitConstraint | null, ignoreParent?: boolean): any;
13611
13682
 
13683
+ /**
13684
+ * brokerize
13685
+ * The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
13686
+ *
13687
+ *
13688
+ *
13689
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
13690
+ * https://openapi-generator.tech
13691
+ * Do not edit the class manually.
13692
+ */
13693
+ /**
13694
+ *
13695
+ * @export
13696
+ * @interface SmartbrokerClientCfg
13697
+ */
13698
+ declare interface SmartbrokerClientCfg {
13699
+ /**
13700
+ * If the client must use a different broker-provided clientId, it can be configured here.
13701
+ * @type {string}
13702
+ * @memberof SmartbrokerClientCfg
13703
+ */
13704
+ clientIdProd?: string;
13705
+ }
13706
+
13707
+ declare function SmartbrokerClientCfgFromJSON(json: any): SmartbrokerClientCfg;
13708
+
13709
+ declare function SmartbrokerClientCfgFromJSONTyped(json: any, ignoreDiscriminator: boolean): SmartbrokerClientCfg;
13710
+
13711
+ declare function SmartbrokerClientCfgToJSON(value?: SmartbrokerClientCfg | null): any;
13712
+
13713
+ declare function SmartbrokerClientCfgToJSONRecursive(value?: SmartbrokerClientCfg | null, ignoreParent?: boolean): any;
13714
+
13612
13715
  /**
13613
13716
  * brokerize
13614
13717
  * The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
@@ -13753,6 +13856,20 @@ declare interface SummarizedTrade {
13753
13856
  * @memberof SummarizedTrade
13754
13857
  */
13755
13858
  closeDateTime: Date;
13859
+ /**
13860
+ * True if this trade was not closed by a sale but by the instrument being booked out — it knocked
13861
+ * out or expired, and the issuer removed the position from the depot without a sell order ever
13862
+ * reaching the order archive.
13863
+ *
13864
+ * The closing execution is therefore synthetic: brokerize derives it from the knock-out date and
13865
+ * prices it with the instrument's closing price on that day (0 where none is known, which is the
13866
+ * floor rather than a claim — the issuer's buy-back, if there was one, is not in the archive). The
13867
+ * P/L is otherwise computed exactly like any other trade's, FIFO-matched against the position's own
13868
+ * buys. Absent on an ordinary trade.
13869
+ * @type {boolean}
13870
+ * @memberof SummarizedTrade
13871
+ */
13872
+ closedByKnockOut?: boolean;
13756
13873
  /**
13757
13874
  *
13758
13875
  * @type {string}
@@ -15033,16 +15150,6 @@ declare function TradeStatisticsToJSON(value?: TradeStatistics | null): any;
15033
15150
 
15034
15151
  declare function TradeStatisticsToJSONRecursive(value?: TradeStatistics | null, ignoreParent?: boolean): any;
15035
15152
 
15036
- /**
15037
- * brokerize
15038
- * The brokerize API allows clients to implement multi-brokerage with a unified interface. For more information, visit brokerize.com
15039
- *
15040
- *
15041
- *
15042
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
15043
- * https://openapi-generator.tech
15044
- * Do not edit the class manually.
15045
- */
15046
15153
  /**
15047
15154
  *
15048
15155
  * @export
@@ -15050,17 +15157,85 @@ declare function TradeStatisticsToJSONRecursive(value?: TradeStatistics | null,
15050
15157
  */
15051
15158
  declare interface TradeWarning {
15052
15159
  /**
15053
- *
15160
+ * Date in the format YYYY-MM-DD for validityType: 'GTD'
15161
+ * Date in the format Date ISO string YYYY-MM-DDThh:mm:ss.fffZ for validityType: 'GTDT'
15162
+ * @type {string}
15163
+ * @memberof TradeWarning
15164
+ */
15165
+ fromDate?: string;
15166
+ /**
15167
+ * Human-readable description, currently German or English depending on where it originates. Meant
15168
+ * as a fallback for displaying something at all — a client that knows `reason` should build its
15169
+ * own text from the structured fields instead.
15054
15170
  * @type {string}
15055
15171
  * @memberof TradeWarning
15056
15172
  */
15057
15173
  message: string;
15174
+ /**
15175
+ *
15176
+ * @type {TradeWarningReason}
15177
+ * @memberof TradeWarning
15178
+ */
15179
+ reason: TradeWarningReason;
15180
+ /**
15181
+ *
15182
+ * @type {Security}
15183
+ * @memberof TradeWarning
15184
+ */
15185
+ security?: Security;
15186
+ /**
15187
+ * Date in the format YYYY-MM-DD for validityType: 'GTD'
15188
+ * Date in the format Date ISO string YYYY-MM-DDThh:mm:ss.fffZ for validityType: 'GTDT'
15189
+ * @type {string}
15190
+ * @memberof TradeWarning
15191
+ */
15192
+ toDate?: string;
15058
15193
  }
15059
15194
 
15060
15195
  declare function TradeWarningFromJSON(json: any): TradeWarning;
15061
15196
 
15062
15197
  declare function TradeWarningFromJSONTyped(json: any, ignoreDiscriminator: boolean): TradeWarning;
15063
15198
 
15199
+ /**
15200
+ * Why a trade or portfolio-history computation could not give a complete answer. Clients switch on
15201
+ * this instead of parsing `TradeWarning.message`, which is free text and may change at any time.
15202
+ *
15203
+ * - `executionsWithoutTimestamp`: order executions carry no execution time, so they cannot be placed
15204
+ * on a timeline and were ignored altogether.
15205
+ * - `inconsistentOrderHistory`: the executions of one security contradict each other or the reported
15206
+ * holding (more sold than ever bought, a quantity that goes negative). Nothing can be reconstructed
15207
+ * from them, so the security is left out of the value history and its trades are not reported.
15208
+ * - `positionNotFullyExplained`: the order archive covers only part of a position — typical for
15209
+ * brokers that return just the most recent weeks. What is held today is known, but its history
15210
+ * reaches further back than the executions do.
15211
+ * - `missingEodPrice`: no closing price was available for the security on some days; it was valued
15212
+ * with the last price known before them.
15213
+ * - `missingFxRate`: no exchange rate to the portfolio currency exists for the security's currency, so
15214
+ * its amounts are *not* converted and the totals they enter are off by the conversion.
15215
+ * - `unknownBuyPrice`: no purchase price could be determined for a position, so it is missing from the
15216
+ * buy value (and from the profit it implies).
15217
+ * - `realizedPnlUnavailable`: the completed trades could not be computed at all, which leaves the
15218
+ * realized profit/loss empty rather than wrong.
15219
+ * @export
15220
+ */
15221
+ declare const TradeWarningReason: {
15222
+ readonly ExecutionsWithoutTimestamp: "executionsWithoutTimestamp";
15223
+ readonly InconsistentOrderHistory: "inconsistentOrderHistory";
15224
+ readonly PositionNotFullyExplained: "positionNotFullyExplained";
15225
+ readonly MissingEodPrice: "missingEodPrice";
15226
+ readonly MissingFxRate: "missingFxRate";
15227
+ readonly UnknownBuyPrice: "unknownBuyPrice";
15228
+ readonly RealizedPnlUnavailable: "realizedPnlUnavailable";
15229
+ };
15230
+
15231
+ declare type TradeWarningReason = (typeof TradeWarningReason)[keyof typeof TradeWarningReason];
15232
+
15233
+ declare function TradeWarningReasonFromJSON(json: any): TradeWarningReason;
15234
+
15235
+ declare function TradeWarningReasonFromJSONTyped(json: any, ignoreDiscriminator: boolean): TradeWarningReason;
15236
+
15237
+ declare function TradeWarningReasonToJSON(value?: TradeWarningReason | null): any;
15238
+
15064
15239
  declare function TradeWarningToJSON(value?: TradeWarning | null): any;
15065
15240
 
15066
15241
  declare function TradeWarningToJSONRecursive(value?: TradeWarning | null, ignoreParent?: boolean): any;
package/dist/errors.d.ts CHANGED
@@ -65,3 +65,17 @@ export declare class BrokerizeError extends Error {
65
65
  httpStatusCode: number;
66
66
  constructor(statusCode: number, body: ErrorResponse);
67
67
  }
68
+ /**
69
+ * Thrown if a request to the brokerize API timed out (HTTP status 504). This is typically sent by
70
+ * a load balancer or gateway in front of the API, so the response body usually is not a regular
71
+ * `ErrorResponse`.
72
+ */
73
+ export declare class BrokerizeTimeoutError extends BrokerizeError {
74
+ constructor(body: ErrorResponse);
75
+ }
76
+ /**
77
+ * Create the error for a failed (status >= 400) API response. If the body is not a valid `ErrorResponse`
78
+ * (e.g. an HTML error page from a load balancer), a generic error body is used instead of failing with a
79
+ * JSON parse error.
80
+ */
81
+ export declare function createErrorFromResponse(response: Response): Promise<BrokerizeError>;
package/dist/errors.js CHANGED
@@ -23,3 +23,48 @@ export class BrokerizeError extends Error {
23
23
  this.msgBrokerName = body.msgBrokerName;
24
24
  }
25
25
  }
26
+ /**
27
+ * Thrown if a request to the brokerize API timed out (HTTP status 504). This is typically sent by
28
+ * a load balancer or gateway in front of the API, so the response body usually is not a regular
29
+ * `ErrorResponse`.
30
+ */
31
+ export class BrokerizeTimeoutError extends BrokerizeError {
32
+ constructor(body) {
33
+ super(504, body);
34
+ this.name = "BrokerizeTimeoutError";
35
+ }
36
+ }
37
+ function isErrorResponse(x) {
38
+ return (!!x &&
39
+ typeof x === "object" &&
40
+ typeof x.msg === "string" &&
41
+ typeof x.code === "string");
42
+ }
43
+ /**
44
+ * Create the error for a failed (status >= 400) API response. If the body is not a valid `ErrorResponse`
45
+ * (e.g. an HTML error page from a load balancer), a generic error body is used instead of failing with a
46
+ * JSON parse error.
47
+ */
48
+ export async function createErrorFromResponse(response) {
49
+ const statusCode = response.status;
50
+ let body;
51
+ try {
52
+ const parsed = JSON.parse(await response.text());
53
+ if (isErrorResponse(parsed)) {
54
+ body = parsed;
55
+ }
56
+ }
57
+ catch (_a) {
58
+ /* not JSON, use the fallback below */
59
+ }
60
+ if (statusCode == 504) {
61
+ return new BrokerizeTimeoutError(body || {
62
+ msg: "The request timed out. Please try again.",
63
+ code: "TIMEOUT",
64
+ });
65
+ }
66
+ return new BrokerizeError(statusCode, body || {
67
+ msg: "The request failed with status " + statusCode + ".",
68
+ code: "INTERNAL_SERVER_ERROR",
69
+ });
70
+ }
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Auth, AuthContextConfiguration, BrokerizeConfig, CognitoConfig, CognitoFacade, CognitoPoolConfig, GuestAuthContextConfiguration, RegisteredUserAuthContextConfiguration, TokenSet } from "./apiCtx";
2
2
  import { AuthorizedApiContext } from "./authorizedApiContext";
3
- import { BrokerizeError } from "./errors";
3
+ import { BrokerizeError, BrokerizeTimeoutError } from "./errors";
4
4
  import * as openApiClient from "./swagger";
5
5
  import * as Models from "./modelExports";
6
6
  import { BrokerizeWebSocketClient, Callback, Subscription } from "./websocketClient";
7
7
  import * as WebSocketTypes from "./websocketTypes";
8
8
  import * as Utils from "./utils";
9
- export { BrokerizeConfig, AuthContextConfiguration, AuthorizedApiContext, BrokerizeWebSocketClient, Models, WebSocketTypes, Subscription, Callback, Utils, BrokerizeError, Auth, TokenSet, };
9
+ export { BrokerizeConfig, AuthContextConfiguration, AuthorizedApiContext, BrokerizeWebSocketClient, Models, WebSocketTypes, Subscription, Callback, Utils, BrokerizeError, BrokerizeTimeoutError, Auth, TokenSet, };
10
10
  export { CognitoPoolConfig, RegisteredUserAuthContextConfiguration };
11
11
  export { CognitoConfig, CognitoFacade };
12
12
  export declare class Brokerize {
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@
2
2
  but reduced to the parts actually used by bg-trading. */
3
3
  import { createAuth, createConfiguration, withAcceptLanguage, } from "./apiCtx.js";
4
4
  import { AuthorizedApiContext, getWebSocketURLByBasePath, } from "./authorizedApiContext.js";
5
- import { BrokerizeError } from "./errors.js";
5
+ import { BrokerizeError, BrokerizeTimeoutError, createErrorFromResponse, } from "./errors.js";
6
6
  import * as openApiClient from "./swagger/index.js";
7
7
  import * as Models from "./modelExports.js";
8
8
  import { BrokerizeWebSocketClientImpl, } from "./websocketClient.js";
9
9
  import * as WebSocketTypes from "./websocketTypes.js";
10
10
  import * as Utils from "./utils.js";
11
- export { AuthorizedApiContext, Models, WebSocketTypes, Utils, BrokerizeError, };
11
+ export { AuthorizedApiContext, Models, WebSocketTypes, Utils, BrokerizeError, BrokerizeTimeoutError, };
12
12
  export class Brokerize {
13
13
  constructor(cfg) {
14
14
  if (!cfg.fetch) {
@@ -38,9 +38,7 @@ export class Brokerize {
38
38
  const postMiddleware = async (r) => {
39
39
  const statusCode = r.response.status;
40
40
  if (statusCode >= 400) {
41
- const decJson = (await r.response.json());
42
- const err = new BrokerizeError(statusCode, decJson);
43
- throw err;
41
+ throw await createErrorFromResponse(r.response);
44
42
  }
45
43
  };
46
44
  this._userApi = new openApiClient.UserApi(createConfiguration(cfg)).withPostMiddleware(postMiddleware);
@@ -157,6 +157,7 @@ export { OrderIntent } from "./swagger/models/OrderIntent";
157
157
  export { OrderIntentAvailability } from "./swagger/models/OrderIntentAvailability";
158
158
  export { SummarizedTrade } from "./swagger/models/SummarizedTrade";
159
159
  export { TradeWarning } from "./swagger/models/TradeWarning";
160
+ export { TradeWarningReason } from "./swagger/models/TradeWarningReason";
160
161
  export { GetPortfolioTradesResponse } from "./swagger/models/GetPortfolioTradesResponse";
161
162
  export { GetPortfolioTradeStatisticsResponse } from "./swagger/models/GetPortfolioTradeStatisticsResponse";
162
163
  export { TradeStatisticsItem } from "./swagger/models/TradeStatisticsItem";
@@ -19,3 +19,4 @@ export { PrepareOAuthRedirectParamsAppearanceEnum } from "./swagger/models/Prepa
19
19
  export { SessionSyncInfoStatus } from "./swagger/models/SessionSyncInfoStatus.js";
20
20
  export { TrailingDistanceModeEnum, } from "./swagger/models/TrailingDistance.js";
21
21
  export { OrderIntent } from "./swagger/models/OrderIntent.js";
22
+ export { TradeWarningReason } from "./swagger/models/TradeWarningReason.js";
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import { BitpandaClientCfg } from "./BitpandaClientCfg";
12
12
  import { CoinbaseClientCfg } from "./CoinbaseClientCfg";
13
+ import { SmartbrokerClientCfg } from "./SmartbrokerClientCfg";
13
14
  /**
14
15
  *
15
16
  * @export
@@ -28,6 +29,12 @@ export interface BrokerClientCfg {
28
29
  * @memberof BrokerClientCfg
29
30
  */
30
31
  coinbase?: CoinbaseClientCfg;
32
+ /**
33
+ *
34
+ * @type {SmartbrokerClientCfg}
35
+ * @memberof BrokerClientCfg
36
+ */
37
+ smartbroker?: SmartbrokerClientCfg;
31
38
  }
32
39
  export declare function BrokerClientCfgFromJSON(json: any): BrokerClientCfg;
33
40
  export declare function BrokerClientCfgFromJSONTyped(json: any, ignoreDiscriminator: boolean): BrokerClientCfg;
@@ -13,6 +13,7 @@
13
13
  import { exists } from "../runtime.js";
14
14
  import { BitpandaClientCfgFromJSON, BitpandaClientCfgToJSON, } from "./BitpandaClientCfg.js";
15
15
  import { CoinbaseClientCfgFromJSON, CoinbaseClientCfgToJSON, } from "./CoinbaseClientCfg.js";
16
+ import { SmartbrokerClientCfgFromJSON, SmartbrokerClientCfgToJSON, } from "./SmartbrokerClientCfg.js";
16
17
  export function BrokerClientCfgFromJSON(json) {
17
18
  return BrokerClientCfgFromJSONTyped(json, false);
18
19
  }
@@ -27,6 +28,9 @@ export function BrokerClientCfgFromJSONTyped(json, ignoreDiscriminator) {
27
28
  coinbase: !exists(json, "coinbase")
28
29
  ? undefined
29
30
  : CoinbaseClientCfgFromJSON(json["coinbase"]),
31
+ smartbroker: !exists(json, "smartbroker")
32
+ ? undefined
33
+ : SmartbrokerClientCfgFromJSON(json["smartbroker"]),
30
34
  };
31
35
  }
32
36
  export function BrokerClientCfgToJSONRecursive(value, ignoreParent = false) {
@@ -39,6 +43,7 @@ export function BrokerClientCfgToJSONRecursive(value, ignoreParent = false) {
39
43
  return {
40
44
  bitpanda: BitpandaClientCfgToJSON(value.bitpanda),
41
45
  coinbase: CoinbaseClientCfgToJSON(value.coinbase),
46
+ smartbroker: SmartbrokerClientCfgToJSON(value.smartbroker),
42
47
  };
43
48
  }
44
49
  export function BrokerClientCfgToJSON(value) {