@woodger/t-invest-node-sdk 0.5.2 → 0.5.3
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 +19 -0
- package/{THIRD_PARTY_NOTICES.md → LICENSE-APACHE-2.0} +1 -106
- package/NOTICE +98 -0
- package/dist/application/services/unary-limiter.js +9 -9
- package/dist/bootstrap/args/sdk-options.d.ts +1 -2
- package/dist/bootstrap/cli/help-catalog.d.ts +733 -0
- package/dist/bootstrap/cli/help-catalog.js +1649 -0
- package/dist/bootstrap/cli/help.d.ts +2 -730
- package/dist/bootstrap/cli/help.js +5 -1647
- package/dist/bootstrap/cli/registry.d.ts +6 -6
- package/dist/bootstrap/commands/accounts/cli.d.ts +2 -3
- package/dist/bootstrap/commands/accounts/cli.js +5 -10
- package/dist/bootstrap/commands/accrued-interests/cli.d.ts +2 -3
- package/dist/bootstrap/commands/accrued-interests/cli.js +5 -10
- package/dist/bootstrap/commands/asset/cli.d.ts +2 -3
- package/dist/bootstrap/commands/asset/cli.js +5 -10
- package/dist/bootstrap/commands/assets/cli.d.ts +2 -3
- package/dist/bootstrap/commands/assets/cli.js +5 -10
- package/dist/bootstrap/commands/bond/cli.d.ts +2 -3
- package/dist/bootstrap/commands/bond/cli.js +5 -10
- package/dist/bootstrap/commands/bond-coupons/cli.d.ts +2 -3
- package/dist/bootstrap/commands/bond-coupons/cli.js +5 -10
- package/dist/bootstrap/commands/bonds/cli.d.ts +2 -3
- package/dist/bootstrap/commands/bonds/cli.js +5 -10
- package/dist/bootstrap/commands/brand/cli.d.ts +2 -3
- package/dist/bootstrap/commands/brand/cli.js +5 -10
- package/dist/bootstrap/commands/brands/cli.d.ts +2 -3
- package/dist/bootstrap/commands/brands/cli.js +5 -10
- package/dist/bootstrap/commands/broker-report/cli.d.ts +2 -3
- package/dist/bootstrap/commands/broker-report/cli.js +5 -10
- package/dist/bootstrap/commands/cancel-order/cli.d.ts +3 -39
- package/dist/bootstrap/commands/cancel-order/cli.js +8 -19
- package/dist/bootstrap/commands/cancel-order/request.mapper.d.ts +7 -0
- package/dist/bootstrap/commands/cancel-order/request.mapper.js +9 -0
- package/dist/bootstrap/commands/cancel-stop-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/cancel-stop-order/cli.js +6 -11
- package/dist/bootstrap/commands/candles/cli.d.ts +3 -4
- package/dist/bootstrap/commands/candles/cli.js +6 -11
- package/dist/bootstrap/commands/close-prices/cli.d.ts +3 -4
- package/dist/bootstrap/commands/close-prices/cli.js +6 -11
- package/dist/bootstrap/commands/countries/cli.d.ts +2 -3
- package/dist/bootstrap/commands/countries/cli.js +5 -10
- package/dist/bootstrap/commands/currencies/cli.d.ts +2 -3
- package/dist/bootstrap/commands/currencies/cli.js +5 -10
- package/dist/bootstrap/commands/currency/cli.d.ts +2 -3
- package/dist/bootstrap/commands/currency/cli.js +5 -10
- package/dist/bootstrap/commands/dividends/cli.d.ts +2 -3
- package/dist/bootstrap/commands/dividends/cli.js +5 -10
- package/dist/bootstrap/commands/dividends-foreign-issuer/cli.d.ts +2 -3
- package/dist/bootstrap/commands/dividends-foreign-issuer/cli.js +5 -10
- package/dist/bootstrap/commands/edit-favorites/cli.d.ts +2 -3
- package/dist/bootstrap/commands/edit-favorites/cli.js +5 -10
- package/dist/bootstrap/commands/etf/cli.d.ts +2 -3
- package/dist/bootstrap/commands/etf/cli.js +5 -10
- package/dist/bootstrap/commands/etfs/cli.d.ts +2 -3
- package/dist/bootstrap/commands/etfs/cli.js +5 -10
- package/dist/bootstrap/commands/favorites/cli.d.ts +2 -3
- package/dist/bootstrap/commands/favorites/cli.js +5 -10
- package/dist/bootstrap/commands/find-instrument/cli.d.ts +2 -3
- package/dist/bootstrap/commands/find-instrument/cli.js +5 -10
- package/dist/bootstrap/commands/future/cli.d.ts +2 -3
- package/dist/bootstrap/commands/future/cli.js +5 -10
- package/dist/bootstrap/commands/futures/cli.d.ts +2 -3
- package/dist/bootstrap/commands/futures/cli.js +5 -10
- package/dist/bootstrap/commands/futures-margin/cli.d.ts +2 -3
- package/dist/bootstrap/commands/futures-margin/cli.js +5 -10
- package/dist/bootstrap/commands/instrument/cli.d.ts +2 -3
- package/dist/bootstrap/commands/instrument/cli.js +5 -10
- package/dist/bootstrap/commands/last-prices/cli.d.ts +3 -4
- package/dist/bootstrap/commands/last-prices/cli.js +6 -11
- package/dist/bootstrap/commands/last-trades/cli.d.ts +3 -4
- package/dist/bootstrap/commands/last-trades/cli.js +6 -11
- package/dist/bootstrap/commands/margin-attributes/cli.d.ts +2 -3
- package/dist/bootstrap/commands/margin-attributes/cli.js +5 -10
- package/dist/bootstrap/commands/operations/cli.d.ts +5 -53
- package/dist/bootstrap/commands/operations/cli.js +9 -36
- package/dist/bootstrap/commands/operations/request.mapper.d.ts +23 -0
- package/dist/bootstrap/commands/operations/request.mapper.js +33 -0
- package/dist/bootstrap/commands/operations-by-cursor/cli.d.ts +5 -69
- package/dist/bootstrap/commands/operations-by-cursor/cli.js +9 -74
- package/dist/bootstrap/commands/operations-by-cursor/request.mapper.d.ts +28 -0
- package/dist/bootstrap/commands/operations-by-cursor/request.mapper.js +70 -0
- package/dist/bootstrap/commands/option/cli.d.ts +2 -3
- package/dist/bootstrap/commands/option/cli.js +5 -10
- package/dist/bootstrap/commands/options-by/cli.d.ts +2 -3
- package/dist/bootstrap/commands/options-by/cli.js +5 -10
- package/dist/bootstrap/commands/order-book/cli.d.ts +3 -4
- package/dist/bootstrap/commands/order-book/cli.js +6 -11
- package/dist/bootstrap/commands/order-state/cli.d.ts +3 -36
- package/dist/bootstrap/commands/order-state/cli.js +8 -21
- package/dist/bootstrap/commands/order-state/request.mapper.d.ts +13 -0
- package/dist/bootstrap/commands/order-state/request.mapper.js +17 -0
- package/dist/bootstrap/commands/orders/cli.d.ts +3 -32
- package/dist/bootstrap/commands/orders/cli.js +8 -18
- package/dist/bootstrap/commands/orders/request.mapper.d.ts +6 -0
- package/dist/bootstrap/commands/orders/request.mapper.js +8 -0
- package/dist/bootstrap/commands/portfolio/cli.d.ts +6 -40
- package/dist/bootstrap/commands/portfolio/cli.js +9 -26
- package/dist/bootstrap/commands/portfolio/request.mapper.d.ts +18 -0
- package/dist/bootstrap/commands/portfolio/request.mapper.js +21 -0
- package/dist/bootstrap/commands/positions/cli.d.ts +3 -32
- package/dist/bootstrap/commands/positions/cli.js +8 -18
- package/dist/bootstrap/commands/positions/request.mapper.d.ts +6 -0
- package/dist/bootstrap/commands/positions/request.mapper.js +8 -0
- package/dist/bootstrap/commands/post-order/cli.d.ts +8 -68
- package/dist/bootstrap/commands/post-order/cli.js +9 -39
- package/dist/bootstrap/commands/post-order/request.mapper.d.ts +27 -0
- package/dist/bootstrap/commands/post-order/request.mapper.js +35 -0
- package/dist/bootstrap/commands/post-stop-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/post-stop-order/cli.js +6 -11
- package/dist/bootstrap/commands/replace-order/cli.d.ts +5 -61
- package/dist/bootstrap/commands/replace-order/cli.js +9 -30
- package/dist/bootstrap/commands/replace-order/request.mapper.d.ts +22 -0
- package/dist/bootstrap/commands/replace-order/request.mapper.js +26 -0
- package/dist/bootstrap/commands/sandbox-accounts/cli.d.ts +2 -3
- package/dist/bootstrap/commands/sandbox-accounts/cli.js +5 -10
- package/dist/bootstrap/commands/sandbox-cancel-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-cancel-order/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-close-account/cli.d.ts +2 -3
- package/dist/bootstrap/commands/sandbox-close-account/cli.js +5 -10
- package/dist/bootstrap/commands/sandbox-open-account/cli.d.ts +2 -3
- package/dist/bootstrap/commands/sandbox-open-account/cli.js +5 -10
- package/dist/bootstrap/commands/sandbox-operations/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-operations/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-operations-by-cursor/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-order-state/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-order-state/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-orders/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-orders/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-pay-in/cli.d.ts +2 -3
- package/dist/bootstrap/commands/sandbox-pay-in/cli.js +5 -10
- package/dist/bootstrap/commands/sandbox-portfolio/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-portfolio/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-positions/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-positions/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-post-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-post-order/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-replace-order/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-replace-order/cli.js +8 -13
- package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.d.ts +3 -4
- package/dist/bootstrap/commands/sandbox-withdraw-limits/cli.js +8 -13
- package/dist/bootstrap/commands/sdk-command-lifecycle.d.ts +15 -0
- package/dist/bootstrap/commands/sdk-command-lifecycle.js +21 -0
- package/dist/bootstrap/commands/share/cli.d.ts +2 -3
- package/dist/bootstrap/commands/share/cli.js +5 -10
- package/dist/bootstrap/commands/shares/cli.d.ts +2 -3
- package/dist/bootstrap/commands/shares/cli.js +5 -10
- package/dist/bootstrap/commands/stop-orders/cli.d.ts +3 -4
- package/dist/bootstrap/commands/stop-orders/cli.js +6 -11
- package/dist/bootstrap/commands/stream-run/cli.d.ts +2 -24
- package/dist/bootstrap/commands/stream-run/cli.js +7 -142
- package/dist/bootstrap/commands/stream-run/config.d.ts +7 -15
- package/dist/bootstrap/commands/stream-run/config.js +1 -101
- package/dist/bootstrap/commands/stream-run/request.mapper.d.ts +14 -0
- package/dist/bootstrap/commands/stream-run/request.mapper.js +111 -0
- package/dist/bootstrap/commands/stream-run/stream-session.d.ts +37 -0
- package/dist/bootstrap/commands/stream-run/stream-session.js +152 -0
- package/dist/bootstrap/commands/trading-schedules/cli.d.ts +2 -3
- package/dist/bootstrap/commands/trading-schedules/cli.js +5 -10
- package/dist/bootstrap/commands/trading-status/cli.d.ts +3 -4
- package/dist/bootstrap/commands/trading-status/cli.js +6 -11
- package/dist/bootstrap/commands/trading-statuses/cli.d.ts +3 -4
- package/dist/bootstrap/commands/trading-statuses/cli.js +6 -11
- package/dist/bootstrap/commands/user-info/cli.d.ts +2 -3
- package/dist/bootstrap/commands/user-info/cli.js +5 -10
- package/dist/bootstrap/commands/user-tariff/cli.d.ts +2 -3
- package/dist/bootstrap/commands/user-tariff/cli.js +5 -10
- package/dist/bootstrap/commands/withdraw-limits/cli.d.ts +3 -32
- package/dist/bootstrap/commands/withdraw-limits/cli.js +8 -18
- package/dist/bootstrap/commands/withdraw-limits/request.mapper.d.ts +6 -0
- package/dist/bootstrap/commands/withdraw-limits/request.mapper.js +8 -0
- package/dist/bootstrap/index.js +2 -2
- package/dist/bootstrap/proto/compile-proto.d.ts +1 -1
- package/dist/bootstrap/proto/compile-proto.js +28 -35
- package/dist/bootstrap/t-invest-node-sdk.d.ts +9 -9
- package/dist/bootstrap/t-invest-node-sdk.js +33 -18
- package/dist/bootstrap/unary-limit-config.js +4 -4
- package/dist/generated/common.js +1 -1
- package/dist/generated/google/api/field_behavior.js +1 -1
- package/dist/generated/google/protobuf/descriptor.js +1 -1
- package/dist/generated/google/protobuf/timestamp.js +1 -1
- package/dist/generated/instruments.js +1 -1
- package/dist/generated/marketdata.js +1 -1
- package/dist/generated/operations.js +1 -1
- package/dist/generated/orders.js +1 -1
- package/dist/generated/sandbox.js +1 -1
- package/dist/generated/signals.js +1 -1
- package/dist/generated/stoporders.js +1 -1
- package/dist/generated/users.js +1 -1
- package/dist/infrastructure/interceptor/warning-interceptor.d.ts +1 -1
- package/dist/infrastructure/interceptor/warning-interceptor.js +2 -2
- package/dist/infrastructure/transport/grpc/sdk-call-error.d.ts +12 -0
- package/dist/infrastructure/transport/grpc/sdk-call-error.js +180 -0
- package/dist/infrastructure/transport/grpc/sdk-client.d.ts +1 -1
- package/dist/infrastructure/transport/grpc/sdk-client.js +2 -2
- package/dist/infrastructure/transport/grpc/sdk-middleware.d.ts +1 -1
- package/dist/infrastructure/transport/grpc/sdk-middleware.js +8 -174
- package/dist/infrastructure/transport/grpc/unary-limit-resolver.d.ts +3 -1
- package/dist/infrastructure/transport/grpc/unary-limit-resolver.js +19 -18
- package/docs/architecture.md +44 -41
- package/docs/bundled-ca.md +12 -12
- package/docs/clean-architecture/adapters.md +15 -15
- package/docs/clean-architecture/api-commands.md +63 -52
- package/docs/clean-architecture/application.md +13 -13
- package/docs/clean-architecture/cli-output-boundaries.md +23 -23
- package/docs/clean-architecture/dto.md +9 -9
- package/docs/clean-architecture/index.md +13 -12
- package/docs/cli-stream-configuration.md +9 -9
- package/docs/cli-stream-reference.md +11 -11
- package/docs/guides/custom-unary-limiter.md +30 -30
- package/docs/guides/errors-and-lifecycle.md +10 -10
- package/docs/guides/getting-started.md +9 -9
- package/docs/guides/index.md +3 -3
- package/docs/guides/streams-and-cancellation.md +6 -6
- package/docs/guides/testing-with-service-definitions.md +4 -4
- package/docs/guides/unary-calls.md +8 -8
- package/docs/index.md +9 -9
- package/docs/limits-policy.md +10 -10
- package/docs/roadmap.md +12 -12
- package/docs/tls-policy.md +7 -7
- package/package.json +2 -1
- package/readme.md +42 -41
- package/dist/infrastructure/interceptor/index.d.ts +0 -1
- package/dist/infrastructure/interceptor/index.js +0 -17
- /package/dist/infrastructure/transport/grpc/{unary-limits.d.ts → unary-method-path.d.ts} +0 -0
- /package/dist/infrastructure/transport/grpc/{unary-limits.js → unary-method-path.js} +0 -0
|
@@ -4,21 +4,20 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Здесь допустимы:
|
|
6
6
|
* - объявление command path и option schema;
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
7
|
+
* - делегирование request mapping в command-owned mapper;
|
|
8
|
+
* - выполнение короткого SDK lifecycle через общий bootstrap helper;
|
|
9
9
|
*
|
|
10
10
|
* Здесь не должно быть ручного table/json rendering или application report contracts.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.ordersCommand = void 0;
|
|
14
14
|
exports.createOrdersCommand = createOrdersCommand;
|
|
15
|
-
exports.createOrdersRequest = createOrdersRequest;
|
|
16
15
|
const contract_1 = require("../../cli/contract");
|
|
17
|
-
const
|
|
16
|
+
const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
|
|
18
17
|
const command_options_1 = require("../../args/command-options");
|
|
19
18
|
const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
|
|
20
19
|
const reporter_1 = require("./reporter");
|
|
21
|
-
|
|
20
|
+
const request_mapper_1 = require("./request.mapper");
|
|
22
21
|
const ordersCommandPath = ['order', 'list'];
|
|
23
22
|
const defaultOrdersSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
|
|
24
23
|
const ordersRequestOptionsSchema = {
|
|
@@ -46,19 +45,10 @@ function createOrdersCommand(createSdk = defaultOrdersSdkFactory) {
|
|
|
46
45
|
}
|
|
47
46
|
exports.ordersCommand = createOrdersCommand();
|
|
48
47
|
async function runOrdersCommand(options, createSdk) {
|
|
49
|
-
const request = createOrdersRequest(options);
|
|
48
|
+
const request = (0, request_mapper_1.createOrdersRequest)(options);
|
|
50
49
|
const { format } = options;
|
|
51
|
-
|
|
52
|
-
try {
|
|
50
|
+
return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
|
|
53
51
|
const response = await sdk.orders.getOrders(request);
|
|
54
52
|
return (0, reporter_1.formatOrders)(response, format);
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
sdk.close();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function createOrdersRequest(options) {
|
|
61
|
-
return {
|
|
62
|
-
accountId: options['account-id']
|
|
63
|
-
};
|
|
53
|
+
});
|
|
64
54
|
}
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Здесь допустимы:
|
|
5
5
|
* - объявление command path и option schema;
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
6
|
+
* - делегирование request mapping в command-owned mapper;
|
|
7
|
+
* - выполнение короткого SDK lifecycle через общий bootstrap helper;
|
|
8
8
|
*
|
|
9
9
|
* Здесь не должно быть ручного table/json rendering или application report contracts.
|
|
10
10
|
*/
|
|
11
11
|
import type { TInvestOptions } from '../../../application/dto/t-invest-options';
|
|
12
|
-
import {
|
|
13
|
-
import type { InferOptions } from 'icore';
|
|
14
|
-
import type { CommandRequestOptions } from '../../args/command-options';
|
|
15
|
-
import { formatPortfolio } from './reporter';
|
|
12
|
+
import type { PortfolioRequest, PortfolioResponse } from '../../../generated/operations';
|
|
16
13
|
type PortfolioSdk = {
|
|
17
14
|
operations: {
|
|
18
15
|
getPortfolio(request: PortfolioRequest): Promise<PortfolioResponse>;
|
|
@@ -20,36 +17,6 @@ type PortfolioSdk = {
|
|
|
20
17
|
close(): void;
|
|
21
18
|
};
|
|
22
19
|
type PortfolioSdkFactory = (options: TInvestOptions) => PortfolioSdk;
|
|
23
|
-
declare const portfolioOptionsSchema: {
|
|
24
|
-
readonly token: {
|
|
25
|
-
readonly type: 'string';
|
|
26
|
-
};
|
|
27
|
-
readonly endpoint: {
|
|
28
|
-
readonly type: 'string';
|
|
29
|
-
};
|
|
30
|
-
readonly 'app-name': {
|
|
31
|
-
readonly type: 'string';
|
|
32
|
-
};
|
|
33
|
-
readonly insecure: {
|
|
34
|
-
readonly type: 'boolean';
|
|
35
|
-
};
|
|
36
|
-
readonly 'account-id': {
|
|
37
|
-
readonly type: 'string';
|
|
38
|
-
readonly required: true;
|
|
39
|
-
};
|
|
40
|
-
readonly currency: {
|
|
41
|
-
readonly type: 'string';
|
|
42
|
-
readonly choices: ("eur" | "rub" | "usd")[];
|
|
43
|
-
readonly default: 'rub';
|
|
44
|
-
};
|
|
45
|
-
readonly format: {
|
|
46
|
-
readonly type: 'string';
|
|
47
|
-
readonly choices: readonly ["json", "table"];
|
|
48
|
-
readonly default: 'table';
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
type PortfolioOptions = InferOptions<typeof portfolioOptionsSchema>;
|
|
52
|
-
type PortfolioRequestOptions = CommandRequestOptions<PortfolioOptions, 'account-id' | 'currency'>;
|
|
53
20
|
export declare function createPortfolioCommand(createSdk?: PortfolioSdkFactory): Omit<import("icore").CommandDefinition<{
|
|
54
21
|
readonly token: {
|
|
55
22
|
readonly type: 'string';
|
|
@@ -69,7 +36,7 @@ export declare function createPortfolioCommand(createSdk?: PortfolioSdkFactory):
|
|
|
69
36
|
};
|
|
70
37
|
readonly currency: {
|
|
71
38
|
readonly type: 'string';
|
|
72
|
-
readonly choices:
|
|
39
|
+
readonly choices: readonly ["rub", "usd", "eur"];
|
|
73
40
|
readonly default: 'rub';
|
|
74
41
|
};
|
|
75
42
|
readonly format: {
|
|
@@ -99,7 +66,7 @@ export declare const portfolioCommand: Omit<import("icore").CommandDefinition<{
|
|
|
99
66
|
};
|
|
100
67
|
readonly currency: {
|
|
101
68
|
readonly type: 'string';
|
|
102
|
-
readonly choices:
|
|
69
|
+
readonly choices: readonly ["rub", "usd", "eur"];
|
|
103
70
|
readonly default: 'rub';
|
|
104
71
|
};
|
|
105
72
|
readonly format: {
|
|
@@ -110,5 +77,4 @@ export declare const portfolioCommand: Omit<import("icore").CommandDefinition<{
|
|
|
110
77
|
}, undefined, string, readonly ["operation", "portfolio"], undefined, void, readonly []>, "metadata"> & {
|
|
111
78
|
metadata?: undefined;
|
|
112
79
|
};
|
|
113
|
-
export {
|
|
114
|
-
export declare function createPortfolioRequest(options: PortfolioRequestOptions): PortfolioRequest;
|
|
80
|
+
export {};
|
|
@@ -4,30 +4,23 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Здесь допустимы:
|
|
6
6
|
* - объявление command path и option schema;
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
7
|
+
* - делегирование request mapping в command-owned mapper;
|
|
8
|
+
* - выполнение короткого SDK lifecycle через общий bootstrap helper;
|
|
9
9
|
*
|
|
10
10
|
* Здесь не должно быть ручного table/json rendering или application report contracts.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.portfolioCommand = void 0;
|
|
14
14
|
exports.createPortfolioCommand = createPortfolioCommand;
|
|
15
|
-
exports.createPortfolioRequest = createPortfolioRequest;
|
|
16
|
-
const operations_1 = require("../../../generated/operations");
|
|
17
15
|
const contract_1 = require("../../cli/contract");
|
|
18
|
-
const
|
|
16
|
+
const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
|
|
19
17
|
const command_options_1 = require("../../args/command-options");
|
|
20
18
|
const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
|
|
21
19
|
const reporter_1 = require("./reporter");
|
|
22
|
-
|
|
20
|
+
const request_mapper_1 = require("./request.mapper");
|
|
23
21
|
const portfolioCommandPath = ['operation', 'portfolio'];
|
|
24
22
|
const defaultPortfolioSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
|
|
25
|
-
const
|
|
26
|
-
rub: operations_1.PortfolioRequest_CurrencyRequest.RUB,
|
|
27
|
-
usd: operations_1.PortfolioRequest_CurrencyRequest.USD,
|
|
28
|
-
eur: operations_1.PortfolioRequest_CurrencyRequest.EUR
|
|
29
|
-
};
|
|
30
|
-
const portfolioCurrencyNames = Object.keys(portfolioCurrencies);
|
|
23
|
+
const portfolioCurrencyNames = ['rub', 'usd', 'eur'];
|
|
31
24
|
const portfolioRequestOptionsSchema = {
|
|
32
25
|
'account-id': {
|
|
33
26
|
type: 'string',
|
|
@@ -58,20 +51,10 @@ function createPortfolioCommand(createSdk = defaultPortfolioSdkFactory) {
|
|
|
58
51
|
}
|
|
59
52
|
exports.portfolioCommand = createPortfolioCommand();
|
|
60
53
|
async function runPortfolioCommand(options, createSdk) {
|
|
61
|
-
const request = createPortfolioRequest(options);
|
|
54
|
+
const request = (0, request_mapper_1.createPortfolioRequest)(options);
|
|
62
55
|
const { format } = options;
|
|
63
|
-
|
|
64
|
-
try {
|
|
56
|
+
return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
|
|
65
57
|
const response = await sdk.operations.getPortfolio(request);
|
|
66
58
|
return (0, reporter_1.formatPortfolio)(response, format);
|
|
67
|
-
}
|
|
68
|
-
finally {
|
|
69
|
-
sdk.close();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function createPortfolioRequest(options) {
|
|
73
|
-
return {
|
|
74
|
-
accountId: options['account-id'],
|
|
75
|
-
currency: portfolioCurrencies[options.currency]
|
|
76
|
-
};
|
|
59
|
+
});
|
|
77
60
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Модуль хранит request mapping, общий для production и Sandbox portfolio.
|
|
3
|
+
*
|
|
4
|
+
* Здесь допустимы generated enum mapping и преобразование typed command options.
|
|
5
|
+
* Здесь не должно быть command schema, SDK calls или rendering.
|
|
6
|
+
*/
|
|
7
|
+
import { PortfolioRequest_CurrencyRequest as PortfolioCurrency, type PortfolioRequest } from '../../../generated/operations';
|
|
8
|
+
declare const portfolioCurrencies: {
|
|
9
|
+
readonly rub: PortfolioCurrency.RUB;
|
|
10
|
+
readonly usd: PortfolioCurrency.USD;
|
|
11
|
+
readonly eur: PortfolioCurrency.EUR;
|
|
12
|
+
};
|
|
13
|
+
interface PortfolioRequestOptions {
|
|
14
|
+
readonly 'account-id': string;
|
|
15
|
+
readonly currency: keyof typeof portfolioCurrencies;
|
|
16
|
+
}
|
|
17
|
+
export declare function createPortfolioRequest(options: PortfolioRequestOptions): PortfolioRequest;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Модуль хранит request mapping, общий для production и Sandbox portfolio.
|
|
4
|
+
*
|
|
5
|
+
* Здесь допустимы generated enum mapping и преобразование typed command options.
|
|
6
|
+
* Здесь не должно быть command schema, SDK calls или rendering.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createPortfolioRequest = createPortfolioRequest;
|
|
10
|
+
const operations_1 = require("../../../generated/operations");
|
|
11
|
+
const portfolioCurrencies = {
|
|
12
|
+
rub: operations_1.PortfolioRequest_CurrencyRequest.RUB,
|
|
13
|
+
usd: operations_1.PortfolioRequest_CurrencyRequest.USD,
|
|
14
|
+
eur: operations_1.PortfolioRequest_CurrencyRequest.EUR
|
|
15
|
+
};
|
|
16
|
+
function createPortfolioRequest(options) {
|
|
17
|
+
return {
|
|
18
|
+
accountId: options['account-id'],
|
|
19
|
+
currency: portfolioCurrencies[options.currency]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Здесь допустимы:
|
|
5
5
|
* - объявление command path и option schema;
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
6
|
+
* - делегирование request mapping в command-owned mapper;
|
|
7
|
+
* - выполнение короткого SDK lifecycle через общий bootstrap helper;
|
|
8
8
|
*
|
|
9
9
|
* Здесь не должно быть ручного table/json rendering или application report contracts.
|
|
10
10
|
*/
|
|
11
11
|
import type { TInvestOptions } from '../../../application/dto/t-invest-options';
|
|
12
12
|
import type { PositionsRequest, PositionsResponse } from '../../../generated/operations';
|
|
13
|
-
import type { InferOptions } from 'icore';
|
|
14
|
-
import type { CommandRequestOptions } from '../../args/command-options';
|
|
15
|
-
import { formatPositions } from './reporter';
|
|
16
13
|
type PositionsSdk = {
|
|
17
14
|
operations: {
|
|
18
15
|
getPositions(request: PositionsRequest): Promise<PositionsResponse>;
|
|
@@ -20,31 +17,6 @@ type PositionsSdk = {
|
|
|
20
17
|
close(): void;
|
|
21
18
|
};
|
|
22
19
|
type PositionsSdkFactory = (options: TInvestOptions) => PositionsSdk;
|
|
23
|
-
declare const positionsOptionsSchema: {
|
|
24
|
-
readonly token: {
|
|
25
|
-
readonly type: 'string';
|
|
26
|
-
};
|
|
27
|
-
readonly endpoint: {
|
|
28
|
-
readonly type: 'string';
|
|
29
|
-
};
|
|
30
|
-
readonly 'app-name': {
|
|
31
|
-
readonly type: 'string';
|
|
32
|
-
};
|
|
33
|
-
readonly insecure: {
|
|
34
|
-
readonly type: 'boolean';
|
|
35
|
-
};
|
|
36
|
-
readonly 'account-id': {
|
|
37
|
-
readonly type: 'string';
|
|
38
|
-
readonly required: true;
|
|
39
|
-
};
|
|
40
|
-
readonly format: {
|
|
41
|
-
readonly type: 'string';
|
|
42
|
-
readonly choices: readonly ["json", "table"];
|
|
43
|
-
readonly default: 'table';
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
type PositionsOptions = InferOptions<typeof positionsOptionsSchema>;
|
|
47
|
-
type PositionsRequestOptions = CommandRequestOptions<PositionsOptions, 'account-id'>;
|
|
48
20
|
export declare function createPositionsCommand(createSdk?: PositionsSdkFactory): Omit<import("icore").CommandDefinition<{
|
|
49
21
|
readonly token: {
|
|
50
22
|
readonly type: 'string';
|
|
@@ -95,5 +67,4 @@ export declare const positionsCommand: Omit<import("icore").CommandDefinition<{
|
|
|
95
67
|
}, undefined, string, readonly ["operation", "positions"], undefined, void, readonly []>, "metadata"> & {
|
|
96
68
|
metadata?: undefined;
|
|
97
69
|
};
|
|
98
|
-
export {
|
|
99
|
-
export declare function createPositionsRequest(options: PositionsRequestOptions): PositionsRequest;
|
|
70
|
+
export {};
|
|
@@ -4,21 +4,20 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Здесь допустимы:
|
|
6
6
|
* - объявление command path и option schema;
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
7
|
+
* - делегирование request mapping в command-owned mapper;
|
|
8
|
+
* - выполнение короткого SDK lifecycle через общий bootstrap helper;
|
|
9
9
|
*
|
|
10
10
|
* Здесь не должно быть ручного table/json rendering или application report contracts.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.positionsCommand = void 0;
|
|
14
14
|
exports.createPositionsCommand = createPositionsCommand;
|
|
15
|
-
exports.createPositionsRequest = createPositionsRequest;
|
|
16
15
|
const contract_1 = require("../../cli/contract");
|
|
17
|
-
const
|
|
16
|
+
const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
|
|
18
17
|
const command_options_1 = require("../../args/command-options");
|
|
19
18
|
const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
|
|
20
19
|
const reporter_1 = require("./reporter");
|
|
21
|
-
|
|
20
|
+
const request_mapper_1 = require("./request.mapper");
|
|
22
21
|
const positionsCommandPath = ['operation', 'positions'];
|
|
23
22
|
const defaultPositionsSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
|
|
24
23
|
const positionsRequestOptionsSchema = {
|
|
@@ -46,19 +45,10 @@ function createPositionsCommand(createSdk = defaultPositionsSdkFactory) {
|
|
|
46
45
|
}
|
|
47
46
|
exports.positionsCommand = createPositionsCommand();
|
|
48
47
|
async function runPositionsCommand(options, createSdk) {
|
|
49
|
-
const request = createPositionsRequest(options);
|
|
48
|
+
const request = (0, request_mapper_1.createPositionsRequest)(options);
|
|
50
49
|
const { format } = options;
|
|
51
|
-
|
|
52
|
-
try {
|
|
50
|
+
return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
|
|
53
51
|
const response = await sdk.operations.getPositions(request);
|
|
54
52
|
return (0, reporter_1.formatPositions)(response, format);
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
sdk.close();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function createPositionsRequest(options) {
|
|
61
|
-
return {
|
|
62
|
-
accountId: options['account-id']
|
|
63
|
-
};
|
|
53
|
+
});
|
|
64
54
|
}
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Здесь допустимы:
|
|
5
5
|
* - объявление command path и option schema;
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
6
|
+
* - делегирование request mapping в command-owned mapper;
|
|
7
|
+
* - выполнение короткого SDK lifecycle через общий bootstrap helper;
|
|
8
8
|
*
|
|
9
9
|
* Здесь не должно быть ручного table/json rendering или application report contracts.
|
|
10
10
|
*/
|
|
11
11
|
import type { TInvestOptions } from '../../../application/dto/t-invest-options';
|
|
12
|
-
import { PostOrderRequest, type PostOrderResponse } from '../../../generated/orders';
|
|
13
|
-
import type { InferOptions } from 'icore';
|
|
14
|
-
import type { CommandRequestOptions } from '../../args/command-options';
|
|
15
|
-
import { formatPostOrder } from './reporter';
|
|
12
|
+
import { type PostOrderRequest, type PostOrderResponse } from '../../../generated/orders';
|
|
16
13
|
type PostOrderSdk = {
|
|
17
14
|
orders: {
|
|
18
15
|
postOrder(request: PostOrderRequest): Promise<PostOrderResponse>;
|
|
@@ -20,62 +17,6 @@ type PostOrderSdk = {
|
|
|
20
17
|
close(): void;
|
|
21
18
|
};
|
|
22
19
|
type PostOrderSdkFactory = (options: TInvestOptions) => PostOrderSdk;
|
|
23
|
-
declare const postOrderOptionsSchema: {
|
|
24
|
-
readonly token: {
|
|
25
|
-
readonly type: 'string';
|
|
26
|
-
};
|
|
27
|
-
readonly endpoint: {
|
|
28
|
-
readonly type: 'string';
|
|
29
|
-
};
|
|
30
|
-
readonly 'app-name': {
|
|
31
|
-
readonly type: 'string';
|
|
32
|
-
};
|
|
33
|
-
readonly insecure: {
|
|
34
|
-
readonly type: 'boolean';
|
|
35
|
-
};
|
|
36
|
-
readonly confirm: {
|
|
37
|
-
readonly type: 'boolean';
|
|
38
|
-
};
|
|
39
|
-
readonly 'account-id': {
|
|
40
|
-
readonly type: 'string';
|
|
41
|
-
readonly required: true;
|
|
42
|
-
};
|
|
43
|
-
readonly 'instrument-id': {
|
|
44
|
-
readonly type: 'string';
|
|
45
|
-
readonly required: true;
|
|
46
|
-
};
|
|
47
|
-
readonly quantity: {
|
|
48
|
-
readonly type: 'number';
|
|
49
|
-
readonly integer: true;
|
|
50
|
-
readonly min: 1;
|
|
51
|
-
readonly max: number;
|
|
52
|
-
readonly required: true;
|
|
53
|
-
};
|
|
54
|
-
readonly price: {
|
|
55
|
-
readonly type: 'string';
|
|
56
|
-
};
|
|
57
|
-
readonly direction: {
|
|
58
|
-
readonly type: 'string';
|
|
59
|
-
readonly choices: ("buy" | "sell")[];
|
|
60
|
-
readonly required: true;
|
|
61
|
-
};
|
|
62
|
-
readonly 'order-type': {
|
|
63
|
-
readonly type: 'string';
|
|
64
|
-
readonly choices: ("bestprice" | "limit" | "market")[];
|
|
65
|
-
readonly required: true;
|
|
66
|
-
};
|
|
67
|
-
readonly 'order-id': {
|
|
68
|
-
readonly type: 'string';
|
|
69
|
-
readonly required: true;
|
|
70
|
-
};
|
|
71
|
-
readonly format: {
|
|
72
|
-
readonly type: 'string';
|
|
73
|
-
readonly choices: readonly ["json", "table"];
|
|
74
|
-
readonly default: 'table';
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
type PostOrderOptions = InferOptions<typeof postOrderOptionsSchema>;
|
|
78
|
-
type PostOrderRequestOptions = CommandRequestOptions<PostOrderOptions, 'account-id' | 'instrument-id' | 'quantity' | 'price' | 'direction' | 'order-type' | 'order-id'>;
|
|
79
20
|
export declare function createPostOrderCommand(createSdk?: PostOrderSdkFactory): Omit<import("icore").CommandDefinition<{
|
|
80
21
|
readonly token: {
|
|
81
22
|
readonly type: 'string';
|
|
@@ -112,12 +53,12 @@ export declare function createPostOrderCommand(createSdk?: PostOrderSdkFactory):
|
|
|
112
53
|
};
|
|
113
54
|
readonly direction: {
|
|
114
55
|
readonly type: 'string';
|
|
115
|
-
readonly choices:
|
|
56
|
+
readonly choices: readonly ["buy", "sell"];
|
|
116
57
|
readonly required: true;
|
|
117
58
|
};
|
|
118
59
|
readonly 'order-type': {
|
|
119
60
|
readonly type: 'string';
|
|
120
|
-
readonly choices:
|
|
61
|
+
readonly choices: readonly ["limit", "market", "bestprice"];
|
|
121
62
|
readonly required: true;
|
|
122
63
|
};
|
|
123
64
|
readonly 'order-id': {
|
|
@@ -168,12 +109,12 @@ export declare const postOrderCommand: Omit<import("icore").CommandDefinition<{
|
|
|
168
109
|
};
|
|
169
110
|
readonly direction: {
|
|
170
111
|
readonly type: 'string';
|
|
171
|
-
readonly choices:
|
|
112
|
+
readonly choices: readonly ["buy", "sell"];
|
|
172
113
|
readonly required: true;
|
|
173
114
|
};
|
|
174
115
|
readonly 'order-type': {
|
|
175
116
|
readonly type: 'string';
|
|
176
|
-
readonly choices:
|
|
117
|
+
readonly choices: readonly ["limit", "market", "bestprice"];
|
|
177
118
|
readonly required: true;
|
|
178
119
|
};
|
|
179
120
|
readonly 'order-id': {
|
|
@@ -188,5 +129,4 @@ export declare const postOrderCommand: Omit<import("icore").CommandDefinition<{
|
|
|
188
129
|
}, undefined, string, readonly ["order", "place"], undefined, void, readonly []>, "metadata"> & {
|
|
189
130
|
metadata?: undefined;
|
|
190
131
|
};
|
|
191
|
-
export {
|
|
192
|
-
export declare function createPostOrderRequest(options: PostOrderRequestOptions): PostOrderRequest;
|
|
132
|
+
export {};
|
|
@@ -4,37 +4,25 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Здесь допустимы:
|
|
6
6
|
* - объявление command path и option schema;
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
7
|
+
* - делегирование request mapping в command-owned mapper;
|
|
8
|
+
* - выполнение короткого SDK lifecycle через общий bootstrap helper;
|
|
9
9
|
*
|
|
10
10
|
* Здесь не должно быть ручного table/json rendering или application report contracts.
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.
|
|
13
|
+
exports.postOrderCommand = void 0;
|
|
14
14
|
exports.createPostOrderCommand = createPostOrderCommand;
|
|
15
|
-
exports.createPostOrderRequest = createPostOrderRequest;
|
|
16
|
-
const common_1 = require("../../../generated/common");
|
|
17
|
-
const orders_1 = require("../../../generated/orders");
|
|
18
15
|
const contract_1 = require("../../cli/contract");
|
|
19
|
-
const
|
|
16
|
+
const sdk_command_lifecycle_1 = require("../sdk-command-lifecycle");
|
|
20
17
|
const command_options_1 = require("../../args/command-options");
|
|
21
18
|
const t_invest_node_sdk_1 = require("../../t-invest-node-sdk");
|
|
22
19
|
const side_effect_args_1 = require("../../args/side-effect-args");
|
|
23
20
|
const reporter_1 = require("./reporter");
|
|
24
|
-
|
|
21
|
+
const request_mapper_1 = require("./request.mapper");
|
|
25
22
|
const postOrderCommandPath = ['order', 'place'];
|
|
26
23
|
const defaultPostOrderSdkFactory = (options) => new t_invest_node_sdk_1.TInvestNodeSDK(options);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
sell: orders_1.OrderDirection.ORDER_DIRECTION_SELL
|
|
30
|
-
};
|
|
31
|
-
const postOrderDirectionNames = Object.keys(postOrderDirections);
|
|
32
|
-
const postOrderTypes = {
|
|
33
|
-
limit: orders_1.OrderType.ORDER_TYPE_LIMIT,
|
|
34
|
-
market: orders_1.OrderType.ORDER_TYPE_MARKET,
|
|
35
|
-
bestprice: orders_1.OrderType.ORDER_TYPE_BESTPRICE
|
|
36
|
-
};
|
|
37
|
-
const postOrderTypeNames = Object.keys(postOrderTypes);
|
|
24
|
+
const postOrderDirectionNames = ['buy', 'sell'];
|
|
25
|
+
const postOrderTypeNames = ['limit', 'market', 'bestprice'];
|
|
38
26
|
const postOrderRequestOptionsSchema = {
|
|
39
27
|
'account-id': {
|
|
40
28
|
type: 'string',
|
|
@@ -86,28 +74,10 @@ function createPostOrderCommand(createSdk = defaultPostOrderSdkFactory) {
|
|
|
86
74
|
exports.postOrderCommand = createPostOrderCommand();
|
|
87
75
|
async function runPostOrderCommand(options, createSdk) {
|
|
88
76
|
(0, side_effect_args_1.assertSideEffectConfirmed)(options.confirm);
|
|
89
|
-
const request = createPostOrderRequest(options);
|
|
77
|
+
const request = (0, request_mapper_1.createPostOrderRequest)(options);
|
|
90
78
|
const { format } = options;
|
|
91
|
-
|
|
92
|
-
try {
|
|
79
|
+
return (0, sdk_command_lifecycle_1.runSdkCommand)(options, createSdk, async (sdk) => {
|
|
93
80
|
const response = await sdk.orders.postOrder(request);
|
|
94
81
|
return (0, reporter_1.formatPostOrder)(response, format);
|
|
95
|
-
}
|
|
96
|
-
finally {
|
|
97
|
-
sdk.close();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function createPostOrderRequest(options) {
|
|
101
|
-
return orders_1.PostOrderRequest.create({
|
|
102
|
-
quantity: options.quantity,
|
|
103
|
-
price: (0, side_effect_args_1.parseOptionalPositiveQuotationOption)(options.price, 'price'),
|
|
104
|
-
direction: postOrderDirections[options.direction],
|
|
105
|
-
accountId: options['account-id'],
|
|
106
|
-
orderType: postOrderTypes[options['order-type']],
|
|
107
|
-
orderId: options['order-id'],
|
|
108
|
-
instrumentId: options['instrument-id'],
|
|
109
|
-
timeInForce: orders_1.TimeInForceType.TIME_IN_FORCE_UNSPECIFIED,
|
|
110
|
-
priceType: common_1.PriceType.PRICE_TYPE_UNSPECIFIED,
|
|
111
|
-
confirmMarginTrade: false
|
|
112
82
|
});
|
|
113
83
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Модуль хранит request mapping, общий для production и Sandbox post order.
|
|
3
|
+
*
|
|
4
|
+
* Здесь допустимы generated defaults, enum mapping и разбор цены заявки.
|
|
5
|
+
* Здесь не должно быть command schema, SDK calls или rendering.
|
|
6
|
+
*/
|
|
7
|
+
import { OrderDirection, OrderType, PostOrderRequest } from '../../../generated/orders';
|
|
8
|
+
declare const postOrderDirections: {
|
|
9
|
+
readonly buy: OrderDirection.ORDER_DIRECTION_BUY;
|
|
10
|
+
readonly sell: OrderDirection.ORDER_DIRECTION_SELL;
|
|
11
|
+
};
|
|
12
|
+
declare const postOrderTypes: {
|
|
13
|
+
readonly limit: OrderType.ORDER_TYPE_LIMIT;
|
|
14
|
+
readonly market: OrderType.ORDER_TYPE_MARKET;
|
|
15
|
+
readonly bestprice: OrderType.ORDER_TYPE_BESTPRICE;
|
|
16
|
+
};
|
|
17
|
+
interface PostOrderRequestOptions {
|
|
18
|
+
readonly 'account-id': string;
|
|
19
|
+
readonly 'instrument-id': string;
|
|
20
|
+
readonly quantity: number;
|
|
21
|
+
readonly price?: string | undefined;
|
|
22
|
+
readonly direction: keyof typeof postOrderDirections;
|
|
23
|
+
readonly 'order-type': keyof typeof postOrderTypes;
|
|
24
|
+
readonly 'order-id': string;
|
|
25
|
+
}
|
|
26
|
+
export declare function createPostOrderRequest(options: PostOrderRequestOptions): PostOrderRequest;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Модуль хранит request mapping, общий для production и Sandbox post order.
|
|
4
|
+
*
|
|
5
|
+
* Здесь допустимы generated defaults, enum mapping и разбор цены заявки.
|
|
6
|
+
* Здесь не должно быть command schema, SDK calls или rendering.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createPostOrderRequest = createPostOrderRequest;
|
|
10
|
+
const common_1 = require("../../../generated/common");
|
|
11
|
+
const orders_1 = require("../../../generated/orders");
|
|
12
|
+
const side_effect_args_1 = require("../../args/side-effect-args");
|
|
13
|
+
const postOrderDirections = {
|
|
14
|
+
buy: orders_1.OrderDirection.ORDER_DIRECTION_BUY,
|
|
15
|
+
sell: orders_1.OrderDirection.ORDER_DIRECTION_SELL
|
|
16
|
+
};
|
|
17
|
+
const postOrderTypes = {
|
|
18
|
+
limit: orders_1.OrderType.ORDER_TYPE_LIMIT,
|
|
19
|
+
market: orders_1.OrderType.ORDER_TYPE_MARKET,
|
|
20
|
+
bestprice: orders_1.OrderType.ORDER_TYPE_BESTPRICE
|
|
21
|
+
};
|
|
22
|
+
function createPostOrderRequest(options) {
|
|
23
|
+
return orders_1.PostOrderRequest.create({
|
|
24
|
+
quantity: options.quantity,
|
|
25
|
+
price: (0, side_effect_args_1.parseOptionalPositiveQuotationOption)(options.price, 'price'),
|
|
26
|
+
direction: postOrderDirections[options.direction],
|
|
27
|
+
accountId: options['account-id'],
|
|
28
|
+
orderType: postOrderTypes[options['order-type']],
|
|
29
|
+
orderId: options['order-id'],
|
|
30
|
+
instrumentId: options['instrument-id'],
|
|
31
|
+
timeInForce: orders_1.TimeInForceType.TIME_IN_FORCE_UNSPECIFIED,
|
|
32
|
+
priceType: common_1.PriceType.PRICE_TYPE_UNSPECIFIED,
|
|
33
|
+
confirmMarginTrade: false
|
|
34
|
+
});
|
|
35
|
+
}
|