@pungoyal/kite-cli 0.1.0 → 0.2.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.
- package/README.md +81 -0
- package/dist/commands/alerts.d.ts +12 -0
- package/dist/commands/alerts.js +529 -0
- package/dist/commands/auth.js +104 -28
- package/dist/commands/config.js +56 -13
- package/dist/commands/profiles.d.ts +10 -0
- package/dist/commands/profiles.js +213 -0
- package/dist/commands/watch.js +1 -1
- package/dist/context.d.ts +6 -0
- package/dist/context.js +36 -18
- package/dist/core/api.d.ts +249 -42
- package/dist/core/api.js +100 -1
- package/dist/core/config.d.ts +77 -23
- package/dist/core/config.js +53 -21
- package/dist/core/credentials.d.ts +3 -2
- package/dist/core/credentials.js +13 -7
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.js +2 -2
- package/dist/core/paths.d.ts +9 -2
- package/dist/core/paths.js +12 -3
- package/dist/core/profiles.d.ts +78 -0
- package/dist/core/profiles.js +140 -0
- package/dist/core/schemas.d.ts +78 -5
- package/dist/core/schemas.js +55 -0
- package/dist/core/session.d.ts +3 -2
- package/dist/core/session.js +7 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/run.js +13 -1
- package/dist/safety.js +12 -1
- package/package.json +4 -3
package/dist/context.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { KiteApi } from './core/api.js';
|
|
2
2
|
import { KiteClient } from './core/client.js';
|
|
3
|
-
import { endpointsFor, loadConfig,
|
|
3
|
+
import { endpointsFor, loadConfig, SANDBOX_CREDENTIALS, } from './core/config.js';
|
|
4
4
|
import { getSecret } from './core/credentials.js';
|
|
5
5
|
import { AuthRequiredError, ExitCode, KiteCliError } from './core/errors.js';
|
|
6
6
|
import { InstrumentStore } from './core/instruments.js';
|
|
7
|
+
import { resolveProfile, resolveTradingConfig, storagePrefixFor } from './core/profiles.js';
|
|
7
8
|
import { RateLimiter } from './core/ratelimit.js';
|
|
8
9
|
import { registerSecret } from './core/redact.js';
|
|
9
10
|
import { isExpired, loadSessionMeta } from './core/session.js';
|
|
10
11
|
import { Io } from './output/io.js';
|
|
11
12
|
export async function createContext(options, signal, streams) {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
13
|
+
const loaded = await loadConfig();
|
|
14
|
+
const profile = resolveProfile({ profileFlag: options.profile, envFlag: options.env }, loaded);
|
|
15
|
+
const env = profile.env;
|
|
14
16
|
const endpoints = endpointsFor(env);
|
|
17
|
+
const credentialScope = storagePrefixFor(profile);
|
|
18
|
+
// The trading config actually in force: global settings overlaid with this
|
|
19
|
+
// profile's overrides (fail-closed — an omitted cap inherits the global one).
|
|
20
|
+
const config = { ...loaded, trading: resolveTradingConfig(loaded, profile) };
|
|
15
21
|
const io = new Io({
|
|
16
22
|
json: options.json ?? false,
|
|
17
23
|
color: options.color ?? config.output.color,
|
|
@@ -21,9 +27,17 @@ export async function createContext(options, signal, streams) {
|
|
|
21
27
|
// process streams regardless of what the caller asked for.
|
|
22
28
|
...(streams ? { streams } : {}),
|
|
23
29
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
// Fail closed on an ambiguous account. When the caller named a profile
|
|
31
|
+
// explicitly, an ambient KITE_ACCESS_TOKEN / KITE_API_SECRET meant for some
|
|
32
|
+
// other account must not silently stand in for it — that is the wrong-account
|
|
33
|
+
// footgun this feature exists to prevent. The CI escape hatch is preserved
|
|
34
|
+
// for the default / configured profile, which is not "explicit".
|
|
35
|
+
if (profile.explicit && (process.env['KITE_ACCESS_TOKEN'] || process.env['KITE_API_SECRET'])) {
|
|
36
|
+
throw new KiteCliError(`Profile "${profile.name}" was named explicitly, but KITE_ACCESS_TOKEN or KITE_API_SECRET is set in the environment and would override it.`, ExitCode.Usage, "Unset those variables to use the profile's own stored credentials, or drop --profile/KITE_PROFILE to use the environment ones.");
|
|
37
|
+
}
|
|
38
|
+
const apiKey = resolveApiKey(profile);
|
|
39
|
+
const session = await loadSessionMeta(profile.name);
|
|
40
|
+
const accessToken = await resolveAccessToken(env, session, apiKey, io, credentialScope);
|
|
27
41
|
const client = new KiteClient({
|
|
28
42
|
apiKey,
|
|
29
43
|
accessToken,
|
|
@@ -36,7 +50,10 @@ export async function createContext(options, signal, streams) {
|
|
|
36
50
|
const instruments = new InstrumentStore(api, env);
|
|
37
51
|
const requireSession = () => {
|
|
38
52
|
if (!client.hasSession()) {
|
|
39
|
-
|
|
53
|
+
if (profile.name !== 'default') {
|
|
54
|
+
throw new AuthRequiredError(`Not logged in to profile "${profile.name}".`, `Run \`kite --profile ${profile.name} login\`.`);
|
|
55
|
+
}
|
|
56
|
+
throw new AuthRequiredError(env === 'sandbox' ? 'No sandbox session.' : 'Not logged in.', env === 'sandbox' ? 'Run `kite login --env sandbox`.' : 'Run `kite login` to start a session.');
|
|
40
57
|
}
|
|
41
58
|
// A session file is absent when credentials came from the environment,
|
|
42
59
|
// which is the normal CI path — synthesise a minimal record.
|
|
@@ -45,6 +62,7 @@ export async function createContext(options, signal, streams) {
|
|
|
45
62
|
userId: 'unknown',
|
|
46
63
|
env,
|
|
47
64
|
apiKey,
|
|
65
|
+
profile: profile.name,
|
|
48
66
|
expiresAt: new Date(Date.now() + 3_600_000).toISOString(),
|
|
49
67
|
exchanges: [],
|
|
50
68
|
products: [],
|
|
@@ -55,7 +73,7 @@ export async function createContext(options, signal, streams) {
|
|
|
55
73
|
const requireApiSecret = async () => {
|
|
56
74
|
if (env === 'sandbox')
|
|
57
75
|
return SANDBOX_CREDENTIALS.apiSecret;
|
|
58
|
-
const found = await getSecret('api_secret', {
|
|
76
|
+
const found = await getSecret('api_secret', { scope: credentialScope });
|
|
59
77
|
if (!found) {
|
|
60
78
|
throw new KiteCliError('No API secret is stored.', ExitCode.Auth, 'Run `kite login` and paste your API secret when prompted, or set KITE_API_SECRET.');
|
|
61
79
|
}
|
|
@@ -65,6 +83,8 @@ export async function createContext(options, signal, streams) {
|
|
|
65
83
|
io,
|
|
66
84
|
config,
|
|
67
85
|
env,
|
|
86
|
+
profile,
|
|
87
|
+
credentialScope,
|
|
68
88
|
endpoints,
|
|
69
89
|
client,
|
|
70
90
|
api,
|
|
@@ -76,22 +96,20 @@ export async function createContext(options, signal, streams) {
|
|
|
76
96
|
requireApiSecret,
|
|
77
97
|
};
|
|
78
98
|
}
|
|
79
|
-
function resolveApiKey(
|
|
99
|
+
function resolveApiKey(profile) {
|
|
80
100
|
const fromEnv = process.env['KITE_API_KEY'];
|
|
81
101
|
if (fromEnv && fromEnv.trim() !== '')
|
|
82
102
|
return fromEnv;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// must remain usable before it exists.
|
|
89
|
-
return '';
|
|
103
|
+
// The profile already carries the right key: the sandbox constant, the
|
|
104
|
+
// default profile's config.apiKey, or a named profile's stored key. Empty is
|
|
105
|
+
// fine and non-fatal — `kite login` sets it up, and `kite config` must work
|
|
106
|
+
// before it exists.
|
|
107
|
+
return profile.apiKey;
|
|
90
108
|
}
|
|
91
|
-
async function resolveAccessToken(env, session, apiKey, io) {
|
|
109
|
+
async function resolveAccessToken(env, session, apiKey, io, scope) {
|
|
92
110
|
let found;
|
|
93
111
|
try {
|
|
94
|
-
found = await getSecret('access_token', {
|
|
112
|
+
found = await getSecret('access_token', { scope });
|
|
95
113
|
}
|
|
96
114
|
catch (err) {
|
|
97
115
|
// A corrupt or wrong-passphrase credential file must not brick the CLI.
|
package/dist/core/api.d.ts
CHANGED
|
@@ -61,15 +61,15 @@ export declare class KiteApi {
|
|
|
61
61
|
}): Promise<{
|
|
62
62
|
[x: string]: unknown;
|
|
63
63
|
user_id: string;
|
|
64
|
-
exchanges: string[];
|
|
65
|
-
products: string[];
|
|
66
|
-
order_types: string[];
|
|
67
|
-
access_token: string;
|
|
68
64
|
user_name?: string | undefined;
|
|
69
65
|
user_shortname?: string | undefined;
|
|
70
66
|
email?: string | undefined;
|
|
71
67
|
user_type?: string | undefined;
|
|
72
68
|
broker?: string | undefined;
|
|
69
|
+
exchanges: string[];
|
|
70
|
+
products: string[];
|
|
71
|
+
order_types: string[];
|
|
72
|
+
access_token: string;
|
|
73
73
|
public_token?: string | undefined;
|
|
74
74
|
refresh_token?: string | undefined;
|
|
75
75
|
login_time?: string | undefined;
|
|
@@ -78,14 +78,14 @@ export declare class KiteApi {
|
|
|
78
78
|
getProfile(signal?: AbortSignal): Promise<{
|
|
79
79
|
[x: string]: unknown;
|
|
80
80
|
user_id: string;
|
|
81
|
-
exchanges: string[];
|
|
82
|
-
products: string[];
|
|
83
|
-
order_types: string[];
|
|
84
81
|
user_name?: string | undefined;
|
|
85
82
|
user_shortname?: string | undefined;
|
|
86
83
|
email?: string | undefined;
|
|
87
84
|
user_type?: string | undefined;
|
|
88
85
|
broker?: string | undefined;
|
|
86
|
+
exchanges: string[];
|
|
87
|
+
products: string[];
|
|
88
|
+
order_types: string[];
|
|
89
89
|
}>;
|
|
90
90
|
getMargins(signal?: AbortSignal): Promise<{
|
|
91
91
|
[x: string]: unknown;
|
|
@@ -151,9 +151,9 @@ export declare class KiteApi {
|
|
|
151
151
|
getOrders(signal?: AbortSignal): Promise<{
|
|
152
152
|
[x: string]: unknown;
|
|
153
153
|
order_id: string;
|
|
154
|
-
status: string;
|
|
155
154
|
parent_order_id?: string | null | undefined;
|
|
156
155
|
exchange_order_id?: string | null | undefined;
|
|
156
|
+
status: string;
|
|
157
157
|
status_message?: string | null | undefined;
|
|
158
158
|
status_message_raw?: string | null | undefined;
|
|
159
159
|
order_timestamp?: string | null | undefined;
|
|
@@ -184,9 +184,9 @@ export declare class KiteApi {
|
|
|
184
184
|
getOrderHistory(orderId: string, signal?: AbortSignal): Promise<{
|
|
185
185
|
[x: string]: unknown;
|
|
186
186
|
order_id: string;
|
|
187
|
-
status: string;
|
|
188
187
|
parent_order_id?: string | null | undefined;
|
|
189
188
|
exchange_order_id?: string | null | undefined;
|
|
189
|
+
status: string;
|
|
190
190
|
status_message?: string | null | undefined;
|
|
191
191
|
status_message_raw?: string | null | undefined;
|
|
192
192
|
order_timestamp?: string | null | undefined;
|
|
@@ -252,10 +252,7 @@ export declare class KiteApi {
|
|
|
252
252
|
* the network level the caller must reconcile via `findOrderByTag`, because
|
|
253
253
|
* a timed-out request may still have been executed.
|
|
254
254
|
*/
|
|
255
|
-
placeOrder(params: PlaceOrderParams, signal?: AbortSignal): Promise<{
|
|
256
|
-
[x: string]: unknown;
|
|
257
|
-
order_id: string;
|
|
258
|
-
} | ({
|
|
255
|
+
placeOrder(params: PlaceOrderParams, signal?: AbortSignal): Promise<({
|
|
259
256
|
[x: string]: unknown;
|
|
260
257
|
order_id: string;
|
|
261
258
|
} | {
|
|
@@ -266,7 +263,10 @@ export declare class KiteApi {
|
|
|
266
263
|
error_type?: string | undefined;
|
|
267
264
|
message?: string | undefined;
|
|
268
265
|
};
|
|
269
|
-
})[]
|
|
266
|
+
})[] | {
|
|
267
|
+
[x: string]: unknown;
|
|
268
|
+
order_id: string;
|
|
269
|
+
}>;
|
|
270
270
|
modifyOrder(params: ModifyOrderParams, signal?: AbortSignal): Promise<{
|
|
271
271
|
[x: string]: unknown;
|
|
272
272
|
order_id: string;
|
|
@@ -290,9 +290,9 @@ export declare class KiteApi {
|
|
|
290
290
|
findOrderByTag(tag: string, signal?: AbortSignal): Promise<{
|
|
291
291
|
[x: string]: unknown;
|
|
292
292
|
order_id: string;
|
|
293
|
-
status: string;
|
|
294
293
|
parent_order_id?: string | null | undefined;
|
|
295
294
|
exchange_order_id?: string | null | undefined;
|
|
295
|
+
status: string;
|
|
296
296
|
status_message?: string | null | undefined;
|
|
297
297
|
status_message_raw?: string | null | undefined;
|
|
298
298
|
order_timestamp?: string | null | undefined;
|
|
@@ -322,7 +322,12 @@ export declare class KiteApi {
|
|
|
322
322
|
getGtts(signal?: AbortSignal): Promise<{
|
|
323
323
|
[x: string]: unknown;
|
|
324
324
|
id: number;
|
|
325
|
+
user_id?: string | undefined;
|
|
326
|
+
parent_trigger?: unknown;
|
|
325
327
|
type: string;
|
|
328
|
+
created_at?: string | undefined;
|
|
329
|
+
updated_at?: string | undefined;
|
|
330
|
+
expires_at?: string | undefined;
|
|
326
331
|
status: string;
|
|
327
332
|
condition: {
|
|
328
333
|
[x: string]: unknown;
|
|
@@ -343,16 +348,16 @@ export declare class KiteApi {
|
|
|
343
348
|
price?: number | undefined;
|
|
344
349
|
result?: unknown;
|
|
345
350
|
}[];
|
|
346
|
-
user_id?: string | undefined;
|
|
347
|
-
parent_trigger?: unknown;
|
|
348
|
-
created_at?: string | undefined;
|
|
349
|
-
updated_at?: string | undefined;
|
|
350
|
-
expires_at?: string | undefined;
|
|
351
351
|
}[]>;
|
|
352
352
|
getGtt(id: number, signal?: AbortSignal): Promise<{
|
|
353
353
|
[x: string]: unknown;
|
|
354
354
|
id: number;
|
|
355
|
+
user_id?: string | undefined;
|
|
356
|
+
parent_trigger?: unknown;
|
|
355
357
|
type: string;
|
|
358
|
+
created_at?: string | undefined;
|
|
359
|
+
updated_at?: string | undefined;
|
|
360
|
+
expires_at?: string | undefined;
|
|
356
361
|
status: string;
|
|
357
362
|
condition: {
|
|
358
363
|
[x: string]: unknown;
|
|
@@ -373,11 +378,6 @@ export declare class KiteApi {
|
|
|
373
378
|
price?: number | undefined;
|
|
374
379
|
result?: unknown;
|
|
375
380
|
}[];
|
|
376
|
-
user_id?: string | undefined;
|
|
377
|
-
parent_trigger?: unknown;
|
|
378
|
-
created_at?: string | undefined;
|
|
379
|
-
updated_at?: string | undefined;
|
|
380
|
-
expires_at?: string | undefined;
|
|
381
381
|
}>;
|
|
382
382
|
placeGtt(params: GttParams, signal?: AbortSignal): Promise<{
|
|
383
383
|
[x: string]: unknown;
|
|
@@ -391,10 +391,182 @@ export declare class KiteApi {
|
|
|
391
391
|
[x: string]: unknown;
|
|
392
392
|
trigger_id: number;
|
|
393
393
|
}>;
|
|
394
|
+
getAlerts(signal?: AbortSignal): Promise<{
|
|
395
|
+
[x: string]: unknown;
|
|
396
|
+
uuid: string;
|
|
397
|
+
user_id?: string | undefined;
|
|
398
|
+
type: string;
|
|
399
|
+
name?: string | undefined;
|
|
400
|
+
status: string;
|
|
401
|
+
disabled_reason?: string | undefined;
|
|
402
|
+
lhs_attribute?: string | undefined;
|
|
403
|
+
lhs_exchange?: string | undefined;
|
|
404
|
+
lhs_tradingsymbol?: string | undefined;
|
|
405
|
+
operator?: string | undefined;
|
|
406
|
+
rhs_type?: string | undefined;
|
|
407
|
+
rhs_attribute?: string | undefined;
|
|
408
|
+
rhs_exchange?: string | undefined;
|
|
409
|
+
rhs_tradingsymbol?: string | undefined;
|
|
410
|
+
rhs_constant?: number | undefined;
|
|
411
|
+
alert_count?: number | undefined;
|
|
412
|
+
basket?: {
|
|
413
|
+
[x: string]: unknown;
|
|
414
|
+
name?: string | undefined;
|
|
415
|
+
type?: string | undefined;
|
|
416
|
+
tags?: unknown[] | undefined;
|
|
417
|
+
items: {
|
|
418
|
+
[x: string]: unknown;
|
|
419
|
+
type?: string | undefined;
|
|
420
|
+
tradingsymbol?: string | undefined;
|
|
421
|
+
exchange?: string | undefined;
|
|
422
|
+
instrument_token?: number | undefined;
|
|
423
|
+
weight?: number | undefined;
|
|
424
|
+
params?: {
|
|
425
|
+
[x: string]: unknown;
|
|
426
|
+
} | undefined;
|
|
427
|
+
}[];
|
|
428
|
+
} | undefined;
|
|
429
|
+
created_at?: string | undefined;
|
|
430
|
+
updated_at?: string | undefined;
|
|
431
|
+
}[]>;
|
|
432
|
+
getAlert(uuid: string, signal?: AbortSignal): Promise<{
|
|
433
|
+
[x: string]: unknown;
|
|
434
|
+
uuid: string;
|
|
435
|
+
user_id?: string | undefined;
|
|
436
|
+
type: string;
|
|
437
|
+
name?: string | undefined;
|
|
438
|
+
status: string;
|
|
439
|
+
disabled_reason?: string | undefined;
|
|
440
|
+
lhs_attribute?: string | undefined;
|
|
441
|
+
lhs_exchange?: string | undefined;
|
|
442
|
+
lhs_tradingsymbol?: string | undefined;
|
|
443
|
+
operator?: string | undefined;
|
|
444
|
+
rhs_type?: string | undefined;
|
|
445
|
+
rhs_attribute?: string | undefined;
|
|
446
|
+
rhs_exchange?: string | undefined;
|
|
447
|
+
rhs_tradingsymbol?: string | undefined;
|
|
448
|
+
rhs_constant?: number | undefined;
|
|
449
|
+
alert_count?: number | undefined;
|
|
450
|
+
basket?: {
|
|
451
|
+
[x: string]: unknown;
|
|
452
|
+
name?: string | undefined;
|
|
453
|
+
type?: string | undefined;
|
|
454
|
+
tags?: unknown[] | undefined;
|
|
455
|
+
items: {
|
|
456
|
+
[x: string]: unknown;
|
|
457
|
+
type?: string | undefined;
|
|
458
|
+
tradingsymbol?: string | undefined;
|
|
459
|
+
exchange?: string | undefined;
|
|
460
|
+
instrument_token?: number | undefined;
|
|
461
|
+
weight?: number | undefined;
|
|
462
|
+
params?: {
|
|
463
|
+
[x: string]: unknown;
|
|
464
|
+
} | undefined;
|
|
465
|
+
}[];
|
|
466
|
+
} | undefined;
|
|
467
|
+
created_at?: string | undefined;
|
|
468
|
+
updated_at?: string | undefined;
|
|
469
|
+
}>;
|
|
470
|
+
getAlertHistory(uuid: string, signal?: AbortSignal): Promise<{
|
|
471
|
+
[x: string]: unknown;
|
|
472
|
+
uuid?: string | undefined;
|
|
473
|
+
type?: string | undefined;
|
|
474
|
+
condition?: string | undefined;
|
|
475
|
+
created_at?: string | undefined;
|
|
476
|
+
meta?: unknown;
|
|
477
|
+
order_meta?: unknown;
|
|
478
|
+
}[]>;
|
|
479
|
+
createAlert(params: AlertParams, signal?: AbortSignal): Promise<{
|
|
480
|
+
[x: string]: unknown;
|
|
481
|
+
uuid: string;
|
|
482
|
+
user_id?: string | undefined;
|
|
483
|
+
type: string;
|
|
484
|
+
name?: string | undefined;
|
|
485
|
+
status: string;
|
|
486
|
+
disabled_reason?: string | undefined;
|
|
487
|
+
lhs_attribute?: string | undefined;
|
|
488
|
+
lhs_exchange?: string | undefined;
|
|
489
|
+
lhs_tradingsymbol?: string | undefined;
|
|
490
|
+
operator?: string | undefined;
|
|
491
|
+
rhs_type?: string | undefined;
|
|
492
|
+
rhs_attribute?: string | undefined;
|
|
493
|
+
rhs_exchange?: string | undefined;
|
|
494
|
+
rhs_tradingsymbol?: string | undefined;
|
|
495
|
+
rhs_constant?: number | undefined;
|
|
496
|
+
alert_count?: number | undefined;
|
|
497
|
+
basket?: {
|
|
498
|
+
[x: string]: unknown;
|
|
499
|
+
name?: string | undefined;
|
|
500
|
+
type?: string | undefined;
|
|
501
|
+
tags?: unknown[] | undefined;
|
|
502
|
+
items: {
|
|
503
|
+
[x: string]: unknown;
|
|
504
|
+
type?: string | undefined;
|
|
505
|
+
tradingsymbol?: string | undefined;
|
|
506
|
+
exchange?: string | undefined;
|
|
507
|
+
instrument_token?: number | undefined;
|
|
508
|
+
weight?: number | undefined;
|
|
509
|
+
params?: {
|
|
510
|
+
[x: string]: unknown;
|
|
511
|
+
} | undefined;
|
|
512
|
+
}[];
|
|
513
|
+
} | undefined;
|
|
514
|
+
created_at?: string | undefined;
|
|
515
|
+
updated_at?: string | undefined;
|
|
516
|
+
}>;
|
|
517
|
+
modifyAlert(uuid: string, params: AlertParams, signal?: AbortSignal): Promise<{
|
|
518
|
+
[x: string]: unknown;
|
|
519
|
+
uuid: string;
|
|
520
|
+
user_id?: string | undefined;
|
|
521
|
+
type: string;
|
|
522
|
+
name?: string | undefined;
|
|
523
|
+
status: string;
|
|
524
|
+
disabled_reason?: string | undefined;
|
|
525
|
+
lhs_attribute?: string | undefined;
|
|
526
|
+
lhs_exchange?: string | undefined;
|
|
527
|
+
lhs_tradingsymbol?: string | undefined;
|
|
528
|
+
operator?: string | undefined;
|
|
529
|
+
rhs_type?: string | undefined;
|
|
530
|
+
rhs_attribute?: string | undefined;
|
|
531
|
+
rhs_exchange?: string | undefined;
|
|
532
|
+
rhs_tradingsymbol?: string | undefined;
|
|
533
|
+
rhs_constant?: number | undefined;
|
|
534
|
+
alert_count?: number | undefined;
|
|
535
|
+
basket?: {
|
|
536
|
+
[x: string]: unknown;
|
|
537
|
+
name?: string | undefined;
|
|
538
|
+
type?: string | undefined;
|
|
539
|
+
tags?: unknown[] | undefined;
|
|
540
|
+
items: {
|
|
541
|
+
[x: string]: unknown;
|
|
542
|
+
type?: string | undefined;
|
|
543
|
+
tradingsymbol?: string | undefined;
|
|
544
|
+
exchange?: string | undefined;
|
|
545
|
+
instrument_token?: number | undefined;
|
|
546
|
+
weight?: number | undefined;
|
|
547
|
+
params?: {
|
|
548
|
+
[x: string]: unknown;
|
|
549
|
+
} | undefined;
|
|
550
|
+
}[];
|
|
551
|
+
} | undefined;
|
|
552
|
+
created_at?: string | undefined;
|
|
553
|
+
updated_at?: string | undefined;
|
|
554
|
+
}>;
|
|
555
|
+
/**
|
|
556
|
+
* Delete one or more alerts.
|
|
557
|
+
*
|
|
558
|
+
* Kite takes the uuids as *repeated query parameters* (`?uuid=a&uuid=b`) on a
|
|
559
|
+
* DELETE, not a path segment or a form body — an easy thing to carry over
|
|
560
|
+
* wrongly from the GTT delete, which is path-keyed by a numeric id.
|
|
561
|
+
*/
|
|
562
|
+
deleteAlerts(uuids: string[], signal?: AbortSignal): Promise<unknown>;
|
|
394
563
|
getHoldings(signal?: AbortSignal): Promise<{
|
|
395
564
|
[x: string]: unknown;
|
|
396
565
|
tradingsymbol: string;
|
|
397
566
|
exchange: string;
|
|
567
|
+
instrument_token?: number | undefined;
|
|
568
|
+
isin?: string | undefined;
|
|
569
|
+
product?: string | undefined;
|
|
398
570
|
quantity: number;
|
|
399
571
|
t1_quantity: number;
|
|
400
572
|
realised_quantity: number;
|
|
@@ -407,9 +579,6 @@ export declare class KiteApi {
|
|
|
407
579
|
pnl: number;
|
|
408
580
|
day_change: number;
|
|
409
581
|
day_change_percentage: number;
|
|
410
|
-
instrument_token?: number | undefined;
|
|
411
|
-
isin?: string | undefined;
|
|
412
|
-
product?: string | undefined;
|
|
413
582
|
}[]>;
|
|
414
583
|
getPositions(signal?: AbortSignal): Promise<{
|
|
415
584
|
[x: string]: unknown;
|
|
@@ -417,6 +586,8 @@ export declare class KiteApi {
|
|
|
417
586
|
[x: string]: unknown;
|
|
418
587
|
tradingsymbol: string;
|
|
419
588
|
exchange: string;
|
|
589
|
+
instrument_token?: number | undefined;
|
|
590
|
+
product?: string | undefined;
|
|
420
591
|
quantity: number;
|
|
421
592
|
overnight_quantity: number;
|
|
422
593
|
multiplier: number;
|
|
@@ -436,13 +607,13 @@ export declare class KiteApi {
|
|
|
436
607
|
sell_value: number;
|
|
437
608
|
day_buy_quantity: number;
|
|
438
609
|
day_sell_quantity: number;
|
|
439
|
-
instrument_token?: number | undefined;
|
|
440
|
-
product?: string | undefined;
|
|
441
610
|
}[];
|
|
442
611
|
day: {
|
|
443
612
|
[x: string]: unknown;
|
|
444
613
|
tradingsymbol: string;
|
|
445
614
|
exchange: string;
|
|
615
|
+
instrument_token?: number | undefined;
|
|
616
|
+
product?: string | undefined;
|
|
446
617
|
quantity: number;
|
|
447
618
|
overnight_quantity: number;
|
|
448
619
|
multiplier: number;
|
|
@@ -462,8 +633,6 @@ export declare class KiteApi {
|
|
|
462
633
|
sell_value: number;
|
|
463
634
|
day_buy_quantity: number;
|
|
464
635
|
day_sell_quantity: number;
|
|
465
|
-
instrument_token?: number | undefined;
|
|
466
|
-
product?: string | undefined;
|
|
467
636
|
}[];
|
|
468
637
|
}>;
|
|
469
638
|
getAuctions(signal?: AbortSignal): Promise<{
|
|
@@ -506,9 +675,9 @@ export declare class KiteApi {
|
|
|
506
675
|
getQuote(instruments: string[], signal?: AbortSignal): Promise<Record<string, {
|
|
507
676
|
[x: string]: unknown;
|
|
508
677
|
instrument_token: number;
|
|
509
|
-
last_price: number;
|
|
510
678
|
timestamp?: string | null | undefined;
|
|
511
679
|
last_trade_time?: string | null | undefined;
|
|
680
|
+
last_price: number;
|
|
512
681
|
last_quantity?: number | undefined;
|
|
513
682
|
buy_quantity?: number | undefined;
|
|
514
683
|
sell_quantity?: number | undefined;
|
|
@@ -616,7 +785,7 @@ export declare class KiteApi {
|
|
|
616
785
|
}[]>;
|
|
617
786
|
basketMargins(orders: unknown[], considerPositions?: boolean, signal?: AbortSignal): Promise<{
|
|
618
787
|
[x: string]: unknown;
|
|
619
|
-
|
|
788
|
+
initial?: {
|
|
620
789
|
[x: string]: unknown;
|
|
621
790
|
type?: string | undefined;
|
|
622
791
|
tradingsymbol?: string | undefined;
|
|
@@ -652,8 +821,8 @@ export declare class KiteApi {
|
|
|
652
821
|
realised?: number | undefined;
|
|
653
822
|
unrealised?: number | undefined;
|
|
654
823
|
} | undefined;
|
|
655
|
-
}
|
|
656
|
-
|
|
824
|
+
} | undefined;
|
|
825
|
+
final?: {
|
|
657
826
|
[x: string]: unknown;
|
|
658
827
|
type?: string | undefined;
|
|
659
828
|
tradingsymbol?: string | undefined;
|
|
@@ -690,7 +859,7 @@ export declare class KiteApi {
|
|
|
690
859
|
unrealised?: number | undefined;
|
|
691
860
|
} | undefined;
|
|
692
861
|
} | undefined;
|
|
693
|
-
|
|
862
|
+
orders: {
|
|
694
863
|
[x: string]: unknown;
|
|
695
864
|
type?: string | undefined;
|
|
696
865
|
tradingsymbol?: string | undefined;
|
|
@@ -726,7 +895,7 @@ export declare class KiteApi {
|
|
|
726
895
|
realised?: number | undefined;
|
|
727
896
|
unrealised?: number | undefined;
|
|
728
897
|
} | undefined;
|
|
729
|
-
}
|
|
898
|
+
}[];
|
|
730
899
|
charges?: unknown;
|
|
731
900
|
}>;
|
|
732
901
|
orderCharges(orders: unknown[], signal?: AbortSignal): Promise<{
|
|
@@ -768,14 +937,14 @@ export declare class KiteApi {
|
|
|
768
937
|
}[]>;
|
|
769
938
|
getMfHoldings(signal?: AbortSignal): Promise<{
|
|
770
939
|
[x: string]: unknown;
|
|
940
|
+
folio?: string | null | undefined;
|
|
941
|
+
fund?: string | undefined;
|
|
771
942
|
tradingsymbol: string;
|
|
772
943
|
average_price: number;
|
|
773
944
|
last_price: number;
|
|
945
|
+
last_price_date?: string | undefined;
|
|
774
946
|
pnl: number;
|
|
775
947
|
quantity: number;
|
|
776
|
-
folio?: string | null | undefined;
|
|
777
|
-
fund?: string | undefined;
|
|
778
|
-
last_price_date?: string | undefined;
|
|
779
948
|
}[]>;
|
|
780
949
|
/** Note: only returns the last 7 days of orders. */
|
|
781
950
|
getMfOrders(signal?: AbortSignal): Promise<{
|
|
@@ -822,7 +991,45 @@ export interface GttParams {
|
|
|
822
991
|
price: number;
|
|
823
992
|
}>;
|
|
824
993
|
}
|
|
825
|
-
export declare const
|
|
994
|
+
export declare const ALERT_TYPES: readonly ['simple', 'ato'];
|
|
995
|
+
export type AlertType = (typeof ALERT_TYPES)[number];
|
|
996
|
+
/** Kite's raw comparison operators. The CLI accepts friendlier aliases and
|
|
997
|
+
* normalises to these before they reach the wire. */
|
|
998
|
+
export declare const ALERT_OPERATORS: readonly ['<=', '>=', '<', '>', '=='];
|
|
999
|
+
export type AlertOperator = (typeof ALERT_OPERATORS)[number];
|
|
1000
|
+
export declare const ALERT_RHS_TYPES: readonly ['constant', 'instrument'];
|
|
1001
|
+
export type AlertRhsType = (typeof ALERT_RHS_TYPES)[number];
|
|
1002
|
+
/** The only left/right attribute Kite documents for alerts. */
|
|
1003
|
+
export declare const ALERT_DEFAULT_ATTRIBUTE = "LastTradedPrice";
|
|
1004
|
+
export interface AlertBasketItem {
|
|
1005
|
+
type: 'insert';
|
|
1006
|
+
tradingsymbol: string;
|
|
1007
|
+
exchange: string;
|
|
1008
|
+
weight: number;
|
|
1009
|
+
params: Record<string, unknown>;
|
|
1010
|
+
}
|
|
1011
|
+
export interface AlertBasket {
|
|
1012
|
+
name: string;
|
|
1013
|
+
type: string;
|
|
1014
|
+
tags: string[];
|
|
1015
|
+
items: AlertBasketItem[];
|
|
1016
|
+
}
|
|
1017
|
+
export interface AlertParams {
|
|
1018
|
+
name: string;
|
|
1019
|
+
type: AlertType;
|
|
1020
|
+
lhs_exchange: string;
|
|
1021
|
+
lhs_tradingsymbol: string;
|
|
1022
|
+
lhs_attribute: string;
|
|
1023
|
+
operator: AlertOperator;
|
|
1024
|
+
rhs_type: AlertRhsType;
|
|
1025
|
+
rhs_constant?: number | undefined;
|
|
1026
|
+
rhs_exchange?: string | undefined;
|
|
1027
|
+
rhs_tradingsymbol?: string | undefined;
|
|
1028
|
+
rhs_attribute?: string | undefined;
|
|
1029
|
+
/** Present only for `ato` alerts; placed as an order when the alert fires. */
|
|
1030
|
+
basket?: AlertBasket | undefined;
|
|
1031
|
+
}
|
|
1032
|
+
export declare const HISTORICAL_INTERVALS: readonly ['minute', '3minute', '5minute', '10minute', '15minute', '30minute', '60minute', 'day'];
|
|
826
1033
|
export type HistoricalInterval = (typeof HISTORICAL_INTERVALS)[number];
|
|
827
1034
|
/**
|
|
828
1035
|
* Maximum date range per request, by interval.
|