@polyester/sdk 0.36.0-devnet-20261119195411 → 0.36.0-devnet-20261120040128
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.
- package/CHANGELOG.md +18 -2
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -0
- package/dist/client.js.map +1 -1
- package/dist/gen/ai/v1/assistant_pb.d.ts +56 -4
- package/dist/gen/ai/v1/assistant_pb.d.ts.map +1 -1
- package/dist/gen/ai/v1/assistant_pb.js +9 -2
- package/dist/gen/ai/v1/assistant_pb.js.map +1 -1
- package/dist/gen/alerts/v1/price_alerts_pb.d.ts +1 -1
- package/dist/gen/auth/v1/account_scope_pb.d.ts +40 -0
- package/dist/gen/auth/v1/account_scope_pb.d.ts.map +1 -0
- package/dist/gen/auth/v1/account_scope_pb.js +46 -0
- package/dist/gen/auth/v1/account_scope_pb.js.map +1 -0
- package/dist/gen/auth/v1/activity_pb.d.ts +1 -1
- package/dist/gen/auth/v1/address_book_pb.d.ts +4 -32
- package/dist/gen/auth/v1/address_book_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/address_book_pb.js +8 -38
- package/dist/gen/auth/v1/address_book_pb.js.map +1 -1
- package/dist/gen/auth/v1/api_keys_pb.d.ts +1 -1
- package/dist/gen/auth/v1/auth_pb.d.ts +16 -15
- package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/auth_pb.js +16 -15
- package/dist/gen/auth/v1/auth_pb.js.map +1 -1
- package/dist/gen/auth/v1/connected_apps_pb.d.ts +60 -59
- package/dist/gen/auth/v1/connected_apps_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/connected_apps_pb.js +38 -37
- package/dist/gen/auth/v1/connected_apps_pb.js.map +1 -1
- package/dist/gen/auth/v1/mfa_pb.d.ts +1 -1
- package/dist/gen/auth/v1/policies_pb.d.ts +28 -2
- package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/policies_pb.js +27 -1
- package/dist/gen/auth/v1/policies_pb.js.map +1 -1
- package/dist/gen/auth/v1/profile_pb.d.ts +1 -1
- package/dist/gen/auth/v1/resolve_pb.d.ts +1 -1
- package/dist/gen/auth/v1/social_verification_pb.d.ts +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js +1 -1
- package/dist/gen/chain/analytics/v1/analytics_read_pb.d.ts +1 -1
- package/dist/gen/chain/deposit/v1/deposit_pb.d.ts +1 -1
- package/dist/gen/chain/guard/v1/guard_signer_pb.d.ts +1 -1
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts +1 -1
- package/dist/gen/chain/lifecycle/v1/types_pb.d.ts +1 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +229 -3
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.js +32 -8
- package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
- package/dist/gen/chain/zipper/v1/reason_pb.d.ts +1 -1
- package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +1 -1
- package/dist/gen/changelog/v1/changelog_pb.d.ts +17 -5
- package/dist/gen/changelog/v1/changelog_pb.d.ts.map +1 -1
- package/dist/gen/changelog/v1/changelog_pb.js.map +1 -1
- package/dist/gen/checkpoints/v1/checkpoints_pb.d.ts +1 -1
- package/dist/gen/claims/v1/claims_pb.d.ts +1 -1
- package/dist/gen/fees/v1/fees_pb.d.ts +1 -1
- package/dist/gen/index.d.ts +8 -6
- package/dist/gen/index.js +28 -26
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +1 -1
- package/dist/gen/ledger/read/v1/statement_export_pb.d.ts +1 -1
- package/dist/gen/marketdata/v1/asset_info_pb.d.ts +1 -1
- package/dist/gen/marketdata/v1/heatmap_pb.d.ts +1 -1
- package/dist/gen/marketdata/v1/marketdata_pb.d.ts +289 -3
- package/dist/gen/marketdata/v1/marketdata_pb.d.ts.map +1 -1
- package/dist/gen/marketdata/v1/marketdata_pb.js +115 -2
- package/dist/gen/marketdata/v1/marketdata_pb.js.map +1 -1
- package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +1 -1
- package/dist/gen/notifications/v1/notifications_pb.d.ts +1 -1
- package/dist/gen/orderbook/v1/orderbook_pb.d.ts +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +79 -26
- package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_pb.js +36 -7
- package/dist/gen/orders/v1/orders_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +36 -2
- package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
- package/dist/gen/polyester/api/v1/request_error_pb.d.ts +1 -1
- package/dist/gen/polyester/ratelimit/v1/types_pb.d.ts +1 -1
- package/dist/gen/polyester/type/v1/u128_pb.d.ts +1 -1
- package/dist/gen/privatews/v1/private_ws_pb.d.ts +1 -1
- package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts +1 -1
- package/dist/gen/rewards/v1/rewards_pb.d.ts +1 -1
- package/dist/gen/strategies/v1/strategies_pb.d.ts +2928 -0
- package/dist/gen/strategies/v1/strategies_pb.d.ts.map +1 -0
- package/dist/gen/strategies/v1/strategies_pb.js +818 -0
- package/dist/gen/strategies/v1/strategies_pb.js.map +1 -0
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +39 -18
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js +4 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts +313 -133
- package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.js +31 -26
- package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +29 -14
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js +2 -2
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts +110 -3
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.js +23 -3
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.js.map +1 -1
- package/dist/gen/swap/v1/swap_pb.d.ts +1 -1
- package/dist/gen/system/v1/system_pb.d.ts +1 -1
- package/dist/gen/tradews/v1/trade_ws_pb.d.ts +1 -1
- package/dist/gen/transfer/v1/dust_conversion_pb.d.ts +1 -1
- package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +4 -3
- package/dist/gen/transfer/v1/internal_transfer_pb.d.ts.map +1 -1
- package/dist/gen/transfer/v1/internal_transfer_pb.js.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.d.ts +62 -12
- package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.js +4 -2
- package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
- package/dist/gen/vip/v1/vip_pb.d.ts +1 -1
- package/dist/index.d.ts +12 -6
- package/dist/services/account-activity/account-activity.js +1 -1
- package/dist/services/account-activity/account-activity.schemas.d.ts +4 -4
- package/dist/services/accounts/accounts.js +1 -1
- package/dist/services/accounts/accounts.schemas.js +1 -1
- package/dist/services/address-book/address-book.codecs.js +1 -0
- package/dist/services/address-book/address-book.codecs.js.map +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts +2 -2
- package/dist/services/api-keys/api-keys.schemas.d.ts +6 -6
- package/dist/services/assistant/assistant-events.schemas.d.ts +135 -37
- package/dist/services/assistant/assistant-events.schemas.d.ts.map +1 -1
- package/dist/services/assistant/assistant-events.schemas.js +15 -5
- package/dist/services/assistant/assistant-events.schemas.js.map +1 -1
- package/dist/services/assistant/assistant.codecs.d.ts +5 -2
- package/dist/services/assistant/assistant.codecs.d.ts.map +1 -1
- package/dist/services/assistant/assistant.codecs.js +10 -2
- package/dist/services/assistant/assistant.codecs.js.map +1 -1
- package/dist/services/assistant/assistant.js +1 -1
- package/dist/services/assistant/assistant.schemas.d.ts +1 -1
- package/dist/services/auth/auth.js +1 -1
- package/dist/services/auth/auth.js.map +1 -1
- package/dist/services/auth/profile/profile.js +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.js +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +9 -9
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js +5 -12
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js.map +1 -1
- package/dist/services/candles/candles.js +1 -1
- package/dist/services/chain-analytics/chain-analytics.js +1 -1
- package/dist/services/changelog/changelog.js +1 -1
- package/dist/services/checkpoints/checkpoints.js +1 -1
- package/dist/services/checkpoints/checkpoints.schemas.d.ts +1 -1
- package/dist/services/claims/claims.js +1 -1
- package/dist/services/claims/claims.schemas.d.ts +2 -2
- package/dist/services/claims/claims.schemas.js +1 -1
- package/dist/services/connected-apps/connected-apps.d.ts +4 -4
- package/dist/services/connected-apps/connected-apps.d.ts.map +1 -1
- package/dist/services/connected-apps/connected-apps.js +14 -14
- package/dist/services/connected-apps/connected-apps.js.map +1 -1
- package/dist/services/connected-apps/connected-apps.schemas.d.ts +7 -7
- package/dist/services/connected-apps/connected-apps.schemas.d.ts.map +1 -1
- package/dist/services/connected-apps/connected-apps.schemas.js +10 -10
- package/dist/services/connected-apps/connected-apps.schemas.js.map +1 -1
- package/dist/services/connected-apps/connected-apps.types.d.ts +2 -2
- package/dist/services/deposit/deposit.js +1 -1
- package/dist/services/dust-conversion/dust-conversion.js +1 -1
- package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +8 -8
- package/dist/services/dust-conversion/dust-conversion.schemas.js +1 -1
- package/dist/services/fees/fees.js +1 -1
- package/dist/services/guard-signer/guard-signer.js +1 -1
- package/dist/services/heatmap/heatmap.js +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/internal-transfers/internal-transfers.js +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +6 -6
- package/dist/services/lifecycle/lifecycle.js +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +13 -13
- package/dist/services/lifecycle/lifecycle.schemas.js +2 -2
- package/dist/services/market-data/market-data.codecs.d.ts +9 -1
- package/dist/services/market-data/market-data.codecs.d.ts.map +1 -1
- package/dist/services/market-data/market-data.codecs.js +14 -1
- package/dist/services/market-data/market-data.codecs.js.map +1 -1
- package/dist/services/market-data/market-data.d.ts +9 -1
- package/dist/services/market-data/market-data.d.ts.map +1 -1
- package/dist/services/market-data/market-data.js +15 -2
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/market-data/market-data.schemas.d.ts +40 -2
- package/dist/services/market-data/market-data.schemas.d.ts.map +1 -1
- package/dist/services/market-data/market-data.schemas.js +43 -8
- package/dist/services/market-data/market-data.schemas.js.map +1 -1
- package/dist/services/market-data/market-data.types.d.ts +3 -3
- package/dist/services/market-overview/market-overview.js +1 -1
- package/dist/services/market-overview/market-overview.schemas.js +1 -1
- package/dist/services/notifications/notifications.js +1 -1
- package/dist/services/notifications/notifications.schemas.d.ts +4 -4
- package/dist/services/orderbook/orderbook.js +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +9 -9
- package/dist/services/orders/order-errors.schemas.js +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +97 -97
- package/dist/services/orders/orders-batch.schemas.js +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +16 -16
- package/dist/services/orders/orders-input.schemas.js +1 -1
- package/dist/services/orders/orders-modify.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +14 -14
- package/dist/services/orders/orders-output.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-output.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.js.map +1 -1
- package/dist/services/orders/orders-risk.schemas.js +2 -2
- package/dist/services/orders/orders.d.ts +5 -0
- package/dist/services/orders/orders.d.ts.map +1 -1
- package/dist/services/orders/orders.js +7 -2
- package/dist/services/orders/orders.js.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +15 -15
- package/dist/services/policies/shared.codecs.js +12 -3
- package/dist/services/policies/shared.codecs.js.map +1 -1
- package/dist/services/policies/shared.d.ts +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +3 -3
- package/dist/services/price-alerts/price-alerts.js +1 -1
- package/dist/services/rate-limits/rate-limits.js +1 -1
- package/dist/services/rewards/rewards.js +1 -1
- package/dist/services/rewards/rewards.schemas.d.ts +4 -4
- package/dist/services/social-verification/social-verification.js +1 -1
- package/dist/services/social-verification/social-verification.schemas.js +1 -1
- package/dist/services/statement-exports/statement-exports.js +1 -1
- package/dist/services/statement-exports/statement-exports.schemas.d.ts +6 -6
- package/dist/services/strategies/service.d.ts +8 -0
- package/dist/services/strategies/service.d.ts.map +1 -0
- package/dist/services/strategies/service.js +9 -0
- package/dist/services/strategies/service.js.map +1 -0
- package/dist/services/strategies/strategies.codecs.d.ts +15 -0
- package/dist/services/strategies/strategies.codecs.d.ts.map +1 -0
- package/dist/services/strategies/strategies.codecs.js +50 -0
- package/dist/services/strategies/strategies.codecs.js.map +1 -0
- package/dist/services/strategies/strategies.d.ts +75 -0
- package/dist/services/strategies/strategies.d.ts.map +1 -0
- package/dist/services/strategies/strategies.js +135 -0
- package/dist/services/strategies/strategies.js.map +1 -0
- package/dist/services/strategies/strategies.schemas.d.ts +568 -0
- package/dist/services/strategies/strategies.schemas.d.ts.map +1 -0
- package/dist/services/strategies/strategies.schemas.js +408 -0
- package/dist/services/strategies/strategies.schemas.js.map +1 -0
- package/dist/services/strategies/strategies.types.d.ts +3 -0
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +19 -19
- package/dist/services/swap/service.d.ts +8 -0
- package/dist/services/swap/service.d.ts.map +1 -0
- package/dist/services/swap/service.js +9 -0
- package/dist/services/swap/service.js.map +1 -0
- package/dist/services/swap/swap.codecs.d.ts +19 -0
- package/dist/services/swap/swap.codecs.d.ts.map +1 -0
- package/dist/services/swap/swap.codecs.js +39 -0
- package/dist/services/swap/swap.codecs.js.map +1 -0
- package/dist/services/swap/swap.d.ts +51 -0
- package/dist/services/swap/swap.d.ts.map +1 -0
- package/dist/services/swap/swap.js +71 -0
- package/dist/services/swap/swap.js.map +1 -0
- package/dist/services/swap/swap.schemas.d.ts +520 -0
- package/dist/services/swap/swap.schemas.d.ts.map +1 -0
- package/dist/services/swap/swap.schemas.js +213 -0
- package/dist/services/swap/swap.schemas.js.map +1 -0
- package/dist/services/swap/swap.types.d.ts +3 -0
- package/dist/services/system/system.js +1 -1
- package/dist/services/trades/trades.js +1 -1
- package/dist/services/trades/trades.schemas.d.ts +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.d.ts +29 -2
- package/dist/services/trading-withdraws/trading-withdraws.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.js +75 -12
- package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +85 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +57 -2
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.types.d.ts +3 -3
- package/dist/services/trading-withdraws/wallet-message.js +30 -2
- package/dist/services/trading-withdraws/wallet-message.js.map +1 -1
- package/dist/services/triggers/trigger-child-order.schemas.js +2 -2
- package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
- package/dist/services/triggers/trigger-input.schemas.js +2 -2
- package/dist/services/triggers/triggers-output.schemas.d.ts +53 -53
- package/dist/services/triggers/triggers.js +1 -1
- package/dist/services/vip/vip.js +1 -1
- package/dist/services/vip/vip.schemas.d.ts +3 -3
- package/dist/services/vip/vip.schemas.js +1 -1
- package/dist/services/zipper/zipper.js +1 -1
- package/dist/services/zipper/zipper.schemas.js +1 -1
- package/dist/shared/connect-error-mapping.d.ts.map +1 -1
- package/dist/shared/connect-error-mapping.js +6 -0
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/decimal-surface.d.ts.map +1 -1
- package/dist/shared/decimal-surface.js +11 -1
- package/dist/shared/decimal-surface.js.map +1 -1
- package/dist/shared/error-detail.d.ts +37 -2
- package/dist/shared/error-detail.d.ts.map +1 -1
- package/dist/shared/error-detail.js +2 -0
- package/dist/shared/error-detail.js.map +1 -1
- package/dist/shared/error-details/alerts.js +1 -1
- package/dist/shared/error-details/assistant.js +1 -1
- package/dist/shared/error-details/auth.js +1 -1
- package/dist/shared/error-details/claims.js +1 -1
- package/dist/shared/error-details/internal-transfer.js +1 -1
- package/dist/shared/error-details/ledger.js +1 -1
- package/dist/shared/error-details/market-overview.js +1 -1
- package/dist/shared/error-details/notifications.js +1 -1
- package/dist/shared/error-details/orders.js +1 -1
- package/dist/shared/error-details/profile.js +1 -1
- package/dist/shared/error-details/rate-limit.js +1 -1
- package/dist/shared/error-details/strategies.js +36 -0
- package/dist/shared/error-details/strategies.js.map +1 -0
- package/dist/shared/error-details/swap.js +22 -0
- package/dist/shared/error-details/swap.js.map +1 -0
- package/dist/shared/error-details/withdraw.js +1 -1
- package/dist/shared/rate-limit.schemas.d.ts +1 -1
- package/dist/shared/rate-limit.schemas.js +1 -1
- package/dist/wired-services.d.ts.map +1 -1
- package/dist/wired-services.js +23 -19
- package/dist/wired-services.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import "../../gen/strategies/v1/strategies_pb.js";
|
|
2
|
+
//#region src/services/strategies/strategies.codecs.ts
|
|
3
|
+
const BacktestStatusCodec = { protoToOutput: {
|
|
4
|
+
[0]: "unspecified",
|
|
5
|
+
[1]: "queued",
|
|
6
|
+
[2]: "running",
|
|
7
|
+
[3]: "done",
|
|
8
|
+
[4]: "failed"
|
|
9
|
+
} };
|
|
10
|
+
const ScenarioOutcomeCodec = { protoToOutput: {
|
|
11
|
+
[0]: "unspecified",
|
|
12
|
+
[1]: "not_run",
|
|
13
|
+
[2]: "passed",
|
|
14
|
+
[3]: "failed"
|
|
15
|
+
} };
|
|
16
|
+
const DeployStateCodec = { protoToOutput: {
|
|
17
|
+
[0]: "unspecified",
|
|
18
|
+
[1]: "proposed",
|
|
19
|
+
[2]: "validating",
|
|
20
|
+
[3]: "creating_subaccount",
|
|
21
|
+
[4]: "funding",
|
|
22
|
+
[5]: "deploying",
|
|
23
|
+
[6]: "live",
|
|
24
|
+
[7]: "failed",
|
|
25
|
+
[8]: "expired"
|
|
26
|
+
} };
|
|
27
|
+
const BotStatusCodec = { protoToOutput: {
|
|
28
|
+
[0]: "unspecified",
|
|
29
|
+
[1]: "deploying",
|
|
30
|
+
[2]: "running",
|
|
31
|
+
[3]: "stopping",
|
|
32
|
+
[4]: "stopped",
|
|
33
|
+
[5]: "paused",
|
|
34
|
+
[6]: "quarantined"
|
|
35
|
+
} };
|
|
36
|
+
const BotLogKindCodec = { protoToOutput: {
|
|
37
|
+
[0]: "unspecified",
|
|
38
|
+
[1]: "log",
|
|
39
|
+
[2]: "decision",
|
|
40
|
+
[3]: "error"
|
|
41
|
+
} };
|
|
42
|
+
const StrategyOrderSideCodec = { protoToOutput: {
|
|
43
|
+
[0]: "unspecified",
|
|
44
|
+
[1]: "buy",
|
|
45
|
+
[2]: "sell"
|
|
46
|
+
} };
|
|
47
|
+
//#endregion
|
|
48
|
+
export { BacktestStatusCodec, BotLogKindCodec, BotStatusCodec, DeployStateCodec, ScenarioOutcomeCodec, StrategyOrderSideCodec };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=strategies.codecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategies.codecs.js","names":[],"sources":["../../../src/services/strategies/strategies.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/strategies/v1/strategies_pb.js\";\nimport type { ProtoToOutput } from \"../../utils/types.js\";\n\nexport const STRATEGY_BACKTEST_STATUS_VALUES = [\"queued\", \"running\", \"done\", \"failed\"] as const;\nexport type StrategyBacktestStatus = (typeof STRATEGY_BACKTEST_STATUS_VALUES)[number];\n\nexport const BacktestStatusCodec = {\n protoToOutput: {\n [Proto.Backtest_Status.STATUS_UNSPECIFIED]: \"unspecified\",\n [Proto.Backtest_Status.QUEUED]: \"queued\",\n [Proto.Backtest_Status.RUNNING]: \"running\",\n [Proto.Backtest_Status.DONE]: \"done\",\n [Proto.Backtest_Status.FAILED]: \"failed\",\n } satisfies ProtoToOutput<Proto.Backtest_Status, StrategyBacktestStatus>,\n} as const;\n\nexport const STRATEGY_SCENARIO_OUTCOME_VALUES = [\"not_run\", \"passed\", \"failed\"] as const;\nexport type StrategyScenarioOutcome = (typeof STRATEGY_SCENARIO_OUTCOME_VALUES)[number];\n\nexport const ScenarioOutcomeCodec = {\n protoToOutput: {\n [Proto.ScenarioSummary_Outcome.OUTCOME_UNSPECIFIED]: \"unspecified\",\n [Proto.ScenarioSummary_Outcome.NOT_RUN]: \"not_run\",\n [Proto.ScenarioSummary_Outcome.PASSED]: \"passed\",\n [Proto.ScenarioSummary_Outcome.FAILED]: \"failed\",\n } satisfies ProtoToOutput<Proto.ScenarioSummary_Outcome, StrategyScenarioOutcome>,\n} as const;\n\nexport const STRATEGY_DEPLOY_STATE_VALUES = [\n \"proposed\",\n \"validating\",\n \"creating_subaccount\",\n \"funding\",\n \"deploying\",\n \"live\",\n \"failed\",\n \"expired\",\n] as const;\n/** `live`, `failed` and `expired` are final. */\nexport type StrategyDeployState = (typeof STRATEGY_DEPLOY_STATE_VALUES)[number];\n\nexport const DeployStateCodec = {\n protoToOutput: {\n [Proto.DeployStatus_State.STATE_UNSPECIFIED]: \"unspecified\",\n [Proto.DeployStatus_State.PROPOSED]: \"proposed\",\n [Proto.DeployStatus_State.VALIDATING]: \"validating\",\n [Proto.DeployStatus_State.CREATING_SUBACCOUNT]: \"creating_subaccount\",\n [Proto.DeployStatus_State.FUNDING]: \"funding\",\n [Proto.DeployStatus_State.DEPLOYING]: \"deploying\",\n [Proto.DeployStatus_State.LIVE]: \"live\",\n [Proto.DeployStatus_State.FAILED]: \"failed\",\n [Proto.DeployStatus_State.EXPIRED]: \"expired\",\n } satisfies ProtoToOutput<Proto.DeployStatus_State, StrategyDeployState>,\n} as const;\n\nexport const STRATEGY_BOT_STATUS_VALUES = [\n \"deploying\",\n \"running\",\n \"stopping\",\n \"stopped\",\n \"paused\",\n \"quarantined\",\n] as const;\nexport type StrategyBotStatus = (typeof STRATEGY_BOT_STATUS_VALUES)[number];\n\nexport const BotStatusCodec = {\n protoToOutput: {\n [Proto.Bot_Status.STATUS_UNSPECIFIED]: \"unspecified\",\n [Proto.Bot_Status.DEPLOYING]: \"deploying\",\n [Proto.Bot_Status.RUNNING]: \"running\",\n [Proto.Bot_Status.STOPPING]: \"stopping\",\n [Proto.Bot_Status.STOPPED]: \"stopped\",\n [Proto.Bot_Status.PAUSED]: \"paused\",\n [Proto.Bot_Status.QUARANTINED]: \"quarantined\",\n } satisfies ProtoToOutput<Proto.Bot_Status, StrategyBotStatus>,\n} as const;\n\nexport const STRATEGY_BOT_LOG_KIND_VALUES = [\"log\", \"decision\", \"error\"] as const;\nexport type StrategyBotLogKind = (typeof STRATEGY_BOT_LOG_KIND_VALUES)[number];\n\nexport const BotLogKindCodec = {\n protoToOutput: {\n [Proto.BotLogEntry_Kind.KIND_UNSPECIFIED]: \"unspecified\",\n [Proto.BotLogEntry_Kind.LOG]: \"log\",\n [Proto.BotLogEntry_Kind.DECISION]: \"decision\",\n [Proto.BotLogEntry_Kind.ERROR]: \"error\",\n } satisfies ProtoToOutput<Proto.BotLogEntry_Kind, StrategyBotLogKind>,\n} as const;\n\nexport const StrategyOrderSideCodec = {\n protoToOutput: {\n [Proto.OrderSide.SIDE_UNSPECIFIED]: \"unspecified\",\n [Proto.OrderSide.BUY]: \"buy\",\n [Proto.OrderSide.SELL]: \"sell\",\n } satisfies ProtoToOutput<Proto.OrderSide, \"buy\" | \"sell\">,\n} as const;\n"],"mappings":";;AAMA,MAAa,sBAAsB,EAC/B,eAAe;EACiC,IAAA;EACZ,IAAA;EACC,IAAA;EACH,IAAA;EACE,IAAA;AACpC,EACJ;AAKA,MAAa,uBAAuB,EAChC,eAAe;EAC0C,IAAA;EACZ,IAAA;EACD,IAAA;EACA,IAAA;AAC5C,EACJ;AAeA,MAAa,mBAAmB,EAC5B,eAAe;EACmC,IAAA;EACT,IAAA;EACE,IAAA;EACS,IAAA;EACZ,IAAA;EACE,IAAA;EACL,IAAA;EACE,IAAA;EACC,IAAA;AACxC,EACJ;AAYA,MAAa,iBAAiB,EAC1B,eAAe;EAC4B,IAAA;EACT,IAAA;EACF,IAAA;EACC,IAAA;EACD,IAAA;EACD,IAAA;EACK,IAAA;AACpC,EACJ;AAKA,MAAa,kBAAkB,EAC3B,eAAe;EACgC,IAAA;EACb,IAAA;EACK,IAAA;EACH,IAAA;AACpC,EACJ;AAEA,MAAa,yBAAyB,EAClC,eAAe;EACyB,IAAA;EACb,IAAA;EACC,IAAA;AAC5B,EACJ"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { AuthApiTransports } from "../../shared/transports.js";
|
|
2
|
+
import { PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
3
|
+
import { ExplainStrategyResult, GetStrategyReferenceInput, ListBotLogsInput, ListBotsInput, ListStrategyBotLogsResult, ListStrategyBotsResult, ProposeDeployInput, ProposeStrategyDeployResult, RunStrategyScenariosResult, StartBacktestInput, StartStrategyBacktestResult, StrategyBacktest, StrategyBacktestInput, StrategyBotDetails, StrategyBotInput, StrategyDeployProposalInput, StrategyDeployStatus, StrategyReference, StrategyTemplate, StrategyVersionInput, ValidateStrategyInput, ValidateStrategyResult } from "./strategies.schemas.js";
|
|
4
|
+
//#region src/services/strategies/strategies.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Writes, tests and proposes trading bots of the caller's main account: validate a strategy into
|
|
7
|
+
* an immutable version, run its behaviour examples, backtest it, then record a deploy proposal
|
|
8
|
+
* the user deploys on the website with MFA and a wallet signature. Nothing here deploys a bot,
|
|
9
|
+
* creates a subaccount or moves funds. API keys need `read-strategies`, `draft-strategies` or
|
|
10
|
+
* `propose-strategy-deploy`, and a key scoped to a subaccount is refused (`PermissionError`).
|
|
11
|
+
* Errors carry a `strategies` detail; a `ServiceUnavailableError` is safe to retry unchanged.
|
|
12
|
+
*/
|
|
13
|
+
declare class StrategiesService {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(transports: AuthApiTransports);
|
|
16
|
+
/**
|
|
17
|
+
* What bot code is written against for one runtime version: the bot API reference and skill
|
|
18
|
+
* pack, then the manifest's JSON Schema, the allowed indicators and the limits once the runtime
|
|
19
|
+
* catalog is available. An unknown runtime version throws `ValidationError`
|
|
20
|
+
* (`RUNTIME_VERSION_UNSUPPORTED`).
|
|
21
|
+
*/
|
|
22
|
+
getReference(input?: GetStrategyReferenceInput, options?: PolyesterRequestOptions): Promise<StrategyReference>;
|
|
23
|
+
/** Lists the bot templates: starting points with a manifest and code. */
|
|
24
|
+
listTemplates(options?: PolyesterRequestOptions): Promise<StrategyTemplate[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Checks a bot and stores it as an immutable version. A bot with mistakes is no error: it
|
|
27
|
+
* returns `valid: false` with its `errors`. Needs `draft-strategies`.
|
|
28
|
+
*/
|
|
29
|
+
validate(input: ValidateStrategyInput, options?: PolyesterRequestOptions): Promise<ValidateStrategyResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Runs a version's behaviour examples against its code; a version always gets the same
|
|
32
|
+
* result. Too many runs throw `RateLimitError` (`SCENARIO_RUN_LIMIT_REACHED`). Needs
|
|
33
|
+
* `draft-strategies`.
|
|
34
|
+
*/
|
|
35
|
+
runScenarios(input: StrategyVersionInput, options?: PolyesterRequestOptions): Promise<RunStrategyScenariosResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Starts a backtest of a version; poll `getBacktest` until it is `done` or `failed`. The same
|
|
38
|
+
* version, window, settings and balances return the existing backtest. The daily limit throws
|
|
39
|
+
* `RateLimitError` (`BACKTEST_LIMIT_REACHED`); reusing `idempotencyKey` for another request
|
|
40
|
+
* throws `AlreadyExistsError` (`IDEMPOTENCY_CONFLICT`). Needs `draft-strategies`.
|
|
41
|
+
*/
|
|
42
|
+
startBacktest(input: StartBacktestInput, options?: PolyesterRequestOptions): Promise<StartStrategyBacktestResult>;
|
|
43
|
+
/** Reads one backtest, with its report once `done`. Needs `read-strategies`. */
|
|
44
|
+
getBacktest(input: StrategyBacktestInput, options?: PolyesterRequestOptions): Promise<StrategyBacktest>;
|
|
45
|
+
/**
|
|
46
|
+
* The review summary of a version: what a user approves when deploying it. Needs
|
|
47
|
+
* `read-strategies`.
|
|
48
|
+
*/
|
|
49
|
+
explain(input: StrategyVersionInput, options?: PolyesterRequestOptions): Promise<ExplainStrategyResult>;
|
|
50
|
+
/**
|
|
51
|
+
* Records an immutable deploy proposal and returns the `deployUrl` where the user deploys it
|
|
52
|
+
* with MFA and a wallet signature; it never deploys or moves funds. Refusals throw
|
|
53
|
+
* `PreconditionFailedError` with the reason in the detail, for example `SCENARIOS_FAILING`,
|
|
54
|
+
* `BACKTEST_MISSING`, `INSUFFICIENT_FUNDS` (with `shortfall`) or `BOT_CAP_REACHED` (with
|
|
55
|
+
* `botCap`). Needs `propose-strategy-deploy`.
|
|
56
|
+
*/
|
|
57
|
+
proposeDeploy(input: ProposeDeployInput, options?: PolyesterRequestOptions): Promise<ProposeStrategyDeployResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Reads where a deploy proposal is; poll it until `live`, `failed` or `expired`. Needs
|
|
60
|
+
* `read-strategies`.
|
|
61
|
+
*/
|
|
62
|
+
getDeployStatus(input: StrategyDeployProposalInput, options?: PolyesterRequestOptions): Promise<StrategyDeployStatus>;
|
|
63
|
+
/** Lists the caller's bots, newest first. Needs `read-strategies`. */
|
|
64
|
+
listBots(input?: ListBotsInput, options?: PolyesterRequestOptions): Promise<ListStrategyBotsResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Reads one bot: its money rules and settings, its subaccount's balances and open orders, and
|
|
67
|
+
* its recent decisions and errors. Needs `read-strategies`.
|
|
68
|
+
*/
|
|
69
|
+
getBot(input: StrategyBotInput, options?: PolyesterRequestOptions): Promise<StrategyBotDetails>;
|
|
70
|
+
/** Reads a bot's log lines, decisions and errors, oldest first. Needs `read-strategies`. */
|
|
71
|
+
listBotLogs(input: ListBotLogsInput, options?: PolyesterRequestOptions): Promise<ListStrategyBotLogsResult>;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { StrategiesService };
|
|
75
|
+
//# sourceMappingURL=strategies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategies.d.ts","names":[],"sources":["../../../src/services/strategies/strategies.ts"],"mappings":";;;;;;;;;;;;cAgEa;;EAGG,YAAA,YAAY;;;;;;;EAUlB,aACF,QAAO,2BACP,UAAU,0BACX,QAAQ;;EAOL,cAAc,UAAU,0BAA0B,QAAQ;;;;;EAS1D,SACF,OAAO,uBACP,UAAU,0BACX,QAAQ;;;;;;EAWL,aACF,OAAO,sBACP,UAAU,0BACX,QAAQ;;;;;;;EAYL,cACF,OAAO,oBACP,UAAU,0BACX,QAAQ;;EAUL,YACF,OAAO,uBACP,UAAU,0BACX,QAAQ;;;;;EAWL,QACF,OAAO,sBACP,UAAU,0BACX,QAAQ;;;;;;;;EAaL,cACF,OAAO,oBACP,UAAU,0BACX,QAAQ;;;;;EAUL,gBACF,OAAO,6BACP,UAAU,0BACX,QAAQ;;EAQL,SACF,QAAO,eACP,UAAU,0BACX,QAAQ;;;;;EAaL,OACF,OAAO,kBACP,UAAU,0BACX,QAAQ;;EAOL,YACF,OAAO,kBACP,UAAU,0BACX,QAAQ"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { StrategiesService as StrategiesService$1 } from "../../gen/strategies/v1/strategies_pb.js";
|
|
2
|
+
import { parse } from "../../shared/validation.js";
|
|
3
|
+
import { removeUndefined } from "../../utils/remove-undefined.js";
|
|
4
|
+
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
5
|
+
import { BacktestIdInputSchema, BotIdInputSchema, DeployProposalInputSchema, GetStrategyReferenceInputSchema, ListBotLogsInputSchema, ListBotsInputSchema, ProposeDeployInputSchema, StartBacktestInputSchema, StrategyVersionInputSchema, ValidateStrategyInputSchema, formatBacktest, formatBot, formatBotDetails, formatBotLogEntry, formatDeployStatus, formatExplainStrategyResult, formatProposeDeployResult, formatRunScenariosResult, formatStartBacktestResult, formatStrategyReference, formatStrategyTemplate, formatValidateStrategyResult } from "./strategies.schemas.js";
|
|
6
|
+
import { createClient } from "@connectrpc/connect";
|
|
7
|
+
//#region src/services/strategies/strategies.ts
|
|
8
|
+
/**
|
|
9
|
+
* Writes, tests and proposes trading bots of the caller's main account: validate a strategy into
|
|
10
|
+
* an immutable version, run its behaviour examples, backtest it, then record a deploy proposal
|
|
11
|
+
* the user deploys on the website with MFA and a wallet signature. Nothing here deploys a bot,
|
|
12
|
+
* creates a subaccount or moves funds. API keys need `read-strategies`, `draft-strategies` or
|
|
13
|
+
* `propose-strategy-deploy`, and a key scoped to a subaccount is refused (`PermissionError`).
|
|
14
|
+
* Errors carry a `strategies` detail; a `ServiceUnavailableError` is safe to retry unchanged.
|
|
15
|
+
*/
|
|
16
|
+
var StrategiesService = class {
|
|
17
|
+
#client;
|
|
18
|
+
constructor(transports) {
|
|
19
|
+
this.#client = createClient(StrategiesService$1, transports.authApi);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* What bot code is written against for one runtime version: the bot API reference and skill
|
|
23
|
+
* pack, then the manifest's JSON Schema, the allowed indicators and the limits once the runtime
|
|
24
|
+
* catalog is available. An unknown runtime version throws `ValidationError`
|
|
25
|
+
* (`RUNTIME_VERSION_UNSUPPORTED`).
|
|
26
|
+
*/
|
|
27
|
+
async getReference(input = {}, options) {
|
|
28
|
+
const request = parse(GetStrategyReferenceInputSchema, input);
|
|
29
|
+
const res = await this.#client.getStrategyReference(request, toConnectCallOptions(options));
|
|
30
|
+
return formatStrategyReference(res);
|
|
31
|
+
}
|
|
32
|
+
/** Lists the bot templates: starting points with a manifest and code. */
|
|
33
|
+
async listTemplates(options) {
|
|
34
|
+
return (await this.#client.listStrategyTemplates({}, toConnectCallOptions(options))).templates.map(formatStrategyTemplate);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Checks a bot and stores it as an immutable version. A bot with mistakes is no error: it
|
|
38
|
+
* returns `valid: false` with its `errors`. Needs `draft-strategies`.
|
|
39
|
+
*/
|
|
40
|
+
async validate(input, options) {
|
|
41
|
+
const request = parse(ValidateStrategyInputSchema, input);
|
|
42
|
+
const res = await this.#client.validateStrategy(request, toConnectCallOptions(options));
|
|
43
|
+
return formatValidateStrategyResult(res);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Runs a version's behaviour examples against its code; a version always gets the same
|
|
47
|
+
* result. Too many runs throw `RateLimitError` (`SCENARIO_RUN_LIMIT_REACHED`). Needs
|
|
48
|
+
* `draft-strategies`.
|
|
49
|
+
*/
|
|
50
|
+
async runScenarios(input, options) {
|
|
51
|
+
const request = parse(StrategyVersionInputSchema, input);
|
|
52
|
+
const res = await this.#client.runScenarios(request, toConnectCallOptions(options));
|
|
53
|
+
return formatRunScenariosResult(res);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Starts a backtest of a version; poll `getBacktest` until it is `done` or `failed`. The same
|
|
57
|
+
* version, window, settings and balances return the existing backtest. The daily limit throws
|
|
58
|
+
* `RateLimitError` (`BACKTEST_LIMIT_REACHED`); reusing `idempotencyKey` for another request
|
|
59
|
+
* throws `AlreadyExistsError` (`IDEMPOTENCY_CONFLICT`). Needs `draft-strategies`.
|
|
60
|
+
*/
|
|
61
|
+
async startBacktest(input, options) {
|
|
62
|
+
const request = parse(StartBacktestInputSchema, input);
|
|
63
|
+
const res = await this.#client.startBacktest(removeUndefined(request), toConnectCallOptions(options));
|
|
64
|
+
return formatStartBacktestResult(res);
|
|
65
|
+
}
|
|
66
|
+
/** Reads one backtest, with its report once `done`. Needs `read-strategies`. */
|
|
67
|
+
async getBacktest(input, options) {
|
|
68
|
+
const request = parse(BacktestIdInputSchema, input);
|
|
69
|
+
const res = await this.#client.getBacktest(request, toConnectCallOptions(options));
|
|
70
|
+
if (!res.backtest) throw new Error("GetBacktest response is missing its backtest");
|
|
71
|
+
return formatBacktest(res.backtest);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The review summary of a version: what a user approves when deploying it. Needs
|
|
75
|
+
* `read-strategies`.
|
|
76
|
+
*/
|
|
77
|
+
async explain(input, options) {
|
|
78
|
+
const request = parse(StrategyVersionInputSchema, input);
|
|
79
|
+
const res = await this.#client.explainStrategy(request, toConnectCallOptions(options));
|
|
80
|
+
return formatExplainStrategyResult(res);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Records an immutable deploy proposal and returns the `deployUrl` where the user deploys it
|
|
84
|
+
* with MFA and a wallet signature; it never deploys or moves funds. Refusals throw
|
|
85
|
+
* `PreconditionFailedError` with the reason in the detail, for example `SCENARIOS_FAILING`,
|
|
86
|
+
* `BACKTEST_MISSING`, `INSUFFICIENT_FUNDS` (with `shortfall`) or `BOT_CAP_REACHED` (with
|
|
87
|
+
* `botCap`). Needs `propose-strategy-deploy`.
|
|
88
|
+
*/
|
|
89
|
+
async proposeDeploy(input, options) {
|
|
90
|
+
const request = parse(ProposeDeployInputSchema, input);
|
|
91
|
+
const res = await this.#client.proposeDeploy(request, toConnectCallOptions(options));
|
|
92
|
+
return formatProposeDeployResult(res);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reads where a deploy proposal is; poll it until `live`, `failed` or `expired`. Needs
|
|
96
|
+
* `read-strategies`.
|
|
97
|
+
*/
|
|
98
|
+
async getDeployStatus(input, options) {
|
|
99
|
+
const request = parse(DeployProposalInputSchema, input);
|
|
100
|
+
const res = await this.#client.getDeployStatus(request, toConnectCallOptions(options));
|
|
101
|
+
if (!res.status) throw new Error("GetDeployStatus response is missing its status");
|
|
102
|
+
return formatDeployStatus(res.status);
|
|
103
|
+
}
|
|
104
|
+
/** Lists the caller's bots, newest first. Needs `read-strategies`. */
|
|
105
|
+
async listBots(input = {}, options) {
|
|
106
|
+
const request = parse(ListBotsInputSchema, input);
|
|
107
|
+
const res = await this.#client.listBots(removeUndefined(request), toConnectCallOptions(options));
|
|
108
|
+
return {
|
|
109
|
+
bots: res.bots.map(formatBot),
|
|
110
|
+
nextPageToken: res.nextPageToken
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Reads one bot: its money rules and settings, its subaccount's balances and open orders, and
|
|
115
|
+
* its recent decisions and errors. Needs `read-strategies`.
|
|
116
|
+
*/
|
|
117
|
+
async getBot(input, options) {
|
|
118
|
+
const request = parse(BotIdInputSchema, input);
|
|
119
|
+
const res = await this.#client.getBot(request, toConnectCallOptions(options));
|
|
120
|
+
return formatBotDetails(res);
|
|
121
|
+
}
|
|
122
|
+
/** Reads a bot's log lines, decisions and errors, oldest first. Needs `read-strategies`. */
|
|
123
|
+
async listBotLogs(input, options) {
|
|
124
|
+
const request = parse(ListBotLogsInputSchema, input);
|
|
125
|
+
const res = await this.#client.listBotLogs(removeUndefined(request), toConnectCallOptions(options));
|
|
126
|
+
return {
|
|
127
|
+
entries: res.entries.map(formatBotLogEntry),
|
|
128
|
+
nextPageToken: res.nextPageToken
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
export { StrategiesService };
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=strategies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategies.js","names":["#client","Proto.StrategiesService"],"sources":["../../../src/services/strategies/strategies.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/strategies/v1/strategies_pb.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n BacktestIdInputSchema,\n BotIdInputSchema,\n DeployProposalInputSchema,\n GetStrategyReferenceInputSchema,\n ListBotLogsInputSchema,\n ListBotsInputSchema,\n ProposeDeployInputSchema,\n StartBacktestInputSchema,\n StrategyVersionInputSchema,\n ValidateStrategyInputSchema,\n formatBacktest,\n formatBot,\n formatBotDetails,\n formatBotLogEntry,\n formatDeployStatus,\n formatExplainStrategyResult,\n formatProposeDeployResult,\n formatRunScenariosResult,\n formatStartBacktestResult,\n formatStrategyReference,\n formatStrategyTemplate,\n formatValidateStrategyResult,\n type ExplainStrategyResult,\n type GetStrategyReferenceInput,\n type ListBotLogsInput,\n type ListBotsInput,\n type ListStrategyBotLogsResult,\n type ListStrategyBotsResult,\n type ProposeDeployInput,\n type ProposeStrategyDeployResult,\n type RunStrategyScenariosResult,\n type StartBacktestInput,\n type StartStrategyBacktestResult,\n type StrategyBacktest,\n type StrategyBacktestInput,\n type StrategyBotDetails,\n type StrategyBotInput,\n type StrategyDeployProposalInput,\n type StrategyDeployStatus,\n type StrategyReference,\n type StrategyTemplate,\n type StrategyVersionInput,\n type ValidateStrategyInput,\n type ValidateStrategyResult,\n} from \"./strategies.schemas.js\";\n\n/**\n * Writes, tests and proposes trading bots of the caller's main account: validate a strategy into\n * an immutable version, run its behaviour examples, backtest it, then record a deploy proposal\n * the user deploys on the website with MFA and a wallet signature. Nothing here deploys a bot,\n * creates a subaccount or moves funds. API keys need `read-strategies`, `draft-strategies` or\n * `propose-strategy-deploy`, and a key scoped to a subaccount is refused (`PermissionError`).\n * Errors carry a `strategies` detail; a `ServiceUnavailableError` is safe to retry unchanged.\n */\nexport class StrategiesService {\n #client: Client<typeof Proto.StrategiesService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.StrategiesService, transports.authApi);\n }\n\n /**\n * What bot code is written against for one runtime version: the bot API reference and skill\n * pack, then the manifest's JSON Schema, the allowed indicators and the limits once the runtime\n * catalog is available. An unknown runtime version throws `ValidationError`\n * (`RUNTIME_VERSION_UNSUPPORTED`).\n */\n async getReference(\n input: GetStrategyReferenceInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<StrategyReference> {\n const request = parse(GetStrategyReferenceInputSchema, input);\n const res = await this.#client.getStrategyReference(request, toConnectCallOptions(options));\n return formatStrategyReference(res);\n }\n\n /** Lists the bot templates: starting points with a manifest and code. */\n async listTemplates(options?: PolyesterRequestOptions): Promise<StrategyTemplate[]> {\n const res = await this.#client.listStrategyTemplates({}, toConnectCallOptions(options));\n return res.templates.map(formatStrategyTemplate);\n }\n\n /**\n * Checks a bot and stores it as an immutable version. A bot with mistakes is no error: it\n * returns `valid: false` with its `errors`. Needs `draft-strategies`.\n */\n async validate(\n input: ValidateStrategyInput,\n options?: PolyesterRequestOptions,\n ): Promise<ValidateStrategyResult> {\n const request = parse(ValidateStrategyInputSchema, input);\n const res = await this.#client.validateStrategy(request, toConnectCallOptions(options));\n return formatValidateStrategyResult(res);\n }\n\n /**\n * Runs a version's behaviour examples against its code; a version always gets the same\n * result. Too many runs throw `RateLimitError` (`SCENARIO_RUN_LIMIT_REACHED`). Needs\n * `draft-strategies`.\n */\n async runScenarios(\n input: StrategyVersionInput,\n options?: PolyesterRequestOptions,\n ): Promise<RunStrategyScenariosResult> {\n const request = parse(StrategyVersionInputSchema, input);\n const res = await this.#client.runScenarios(request, toConnectCallOptions(options));\n return formatRunScenariosResult(res);\n }\n\n /**\n * Starts a backtest of a version; poll `getBacktest` until it is `done` or `failed`. The same\n * version, window, settings and balances return the existing backtest. The daily limit throws\n * `RateLimitError` (`BACKTEST_LIMIT_REACHED`); reusing `idempotencyKey` for another request\n * throws `AlreadyExistsError` (`IDEMPOTENCY_CONFLICT`). Needs `draft-strategies`.\n */\n async startBacktest(\n input: StartBacktestInput,\n options?: PolyesterRequestOptions,\n ): Promise<StartStrategyBacktestResult> {\n const request = parse(StartBacktestInputSchema, input);\n const res = await this.#client.startBacktest(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return formatStartBacktestResult(res);\n }\n\n /** Reads one backtest, with its report once `done`. Needs `read-strategies`. */\n async getBacktest(\n input: StrategyBacktestInput,\n options?: PolyesterRequestOptions,\n ): Promise<StrategyBacktest> {\n const request = parse(BacktestIdInputSchema, input);\n const res = await this.#client.getBacktest(request, toConnectCallOptions(options));\n if (!res.backtest) throw new Error(\"GetBacktest response is missing its backtest\");\n return formatBacktest(res.backtest);\n }\n\n /**\n * The review summary of a version: what a user approves when deploying it. Needs\n * `read-strategies`.\n */\n async explain(\n input: StrategyVersionInput,\n options?: PolyesterRequestOptions,\n ): Promise<ExplainStrategyResult> {\n const request = parse(StrategyVersionInputSchema, input);\n const res = await this.#client.explainStrategy(request, toConnectCallOptions(options));\n return formatExplainStrategyResult(res);\n }\n\n /**\n * Records an immutable deploy proposal and returns the `deployUrl` where the user deploys it\n * with MFA and a wallet signature; it never deploys or moves funds. Refusals throw\n * `PreconditionFailedError` with the reason in the detail, for example `SCENARIOS_FAILING`,\n * `BACKTEST_MISSING`, `INSUFFICIENT_FUNDS` (with `shortfall`) or `BOT_CAP_REACHED` (with\n * `botCap`). Needs `propose-strategy-deploy`.\n */\n async proposeDeploy(\n input: ProposeDeployInput,\n options?: PolyesterRequestOptions,\n ): Promise<ProposeStrategyDeployResult> {\n const request = parse(ProposeDeployInputSchema, input);\n const res = await this.#client.proposeDeploy(request, toConnectCallOptions(options));\n return formatProposeDeployResult(res);\n }\n\n /**\n * Reads where a deploy proposal is; poll it until `live`, `failed` or `expired`. Needs\n * `read-strategies`.\n */\n async getDeployStatus(\n input: StrategyDeployProposalInput,\n options?: PolyesterRequestOptions,\n ): Promise<StrategyDeployStatus> {\n const request = parse(DeployProposalInputSchema, input);\n const res = await this.#client.getDeployStatus(request, toConnectCallOptions(options));\n if (!res.status) throw new Error(\"GetDeployStatus response is missing its status\");\n return formatDeployStatus(res.status);\n }\n\n /** Lists the caller's bots, newest first. Needs `read-strategies`. */\n async listBots(\n input: ListBotsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListStrategyBotsResult> {\n const request = parse(ListBotsInputSchema, input);\n const res = await this.#client.listBots(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return { bots: res.bots.map(formatBot), nextPageToken: res.nextPageToken };\n }\n\n /**\n * Reads one bot: its money rules and settings, its subaccount's balances and open orders, and\n * its recent decisions and errors. Needs `read-strategies`.\n */\n async getBot(\n input: StrategyBotInput,\n options?: PolyesterRequestOptions,\n ): Promise<StrategyBotDetails> {\n const request = parse(BotIdInputSchema, input);\n const res = await this.#client.getBot(request, toConnectCallOptions(options));\n return formatBotDetails(res);\n }\n\n /** Reads a bot's log lines, decisions and errors, oldest first. Needs `read-strategies`. */\n async listBotLogs(\n input: ListBotLogsInput,\n options?: PolyesterRequestOptions,\n ): Promise<ListStrategyBotLogsResult> {\n const request = parse(ListBotLogsInputSchema, input);\n const res = await this.#client.listBotLogs(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return { entries: res.entries.map(formatBotLogEntry), nextPageToken: res.nextPageToken };\n }\n}\n"],"mappings":"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"}
|