@gbozee/ultimate 0.0.2-11 → 0.0.2-110

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/dist/index.d.ts CHANGED
@@ -2,9 +2,227 @@
2
2
 
3
3
  import { HttpsProxyAgent } from 'https-proxy-agent';
4
4
  import PocketBase from 'pocketbase';
5
- import { RecordModel } from 'pocketbase';
5
+ import { RecordModel as PocketBaseRecordModel } from 'pocketbase';
6
6
  import { SocksProxyAgent } from 'socks-proxy-agent';
7
7
 
8
+ export type RecordModel = PocketBaseRecordModel;
9
+ export interface BaseSystemFields {
10
+ id: string;
11
+ created: string;
12
+ updated: string;
13
+ }
14
+ export interface ExchangeAccount extends BaseSystemFields {
15
+ exchange: "binance" | "bybit";
16
+ owner: string;
17
+ email?: string;
18
+ user?: string;
19
+ usdt?: number;
20
+ usdc?: number;
21
+ proxy?: string;
22
+ bullish?: boolean;
23
+ bearish?: boolean;
24
+ movePercent?: number;
25
+ totalRisk?: number;
26
+ max_non_essential?: number;
27
+ profit_percent?: number;
28
+ risk_reward?: number;
29
+ exclude_coins?: {
30
+ bullish?: string[];
31
+ };
32
+ include_delisted?: boolean;
33
+ }
34
+ export interface Order extends BaseSystemFields {
35
+ symbol: string;
36
+ account: string;
37
+ kind: "long" | "short";
38
+ price: number;
39
+ quantity: number;
40
+ side: "sell" | "buy";
41
+ stop: number;
42
+ order_id: string;
43
+ }
44
+ export interface SymbolConfig extends BaseSystemFields {
45
+ symbol: string;
46
+ support?: number;
47
+ resistance?: number;
48
+ stop_percent?: number;
49
+ price_places?: string;
50
+ decimal_places?: string;
51
+ min_size?: number;
52
+ weight?: number;
53
+ leverage?: number;
54
+ candle_count?: number;
55
+ interval?: any;
56
+ fee_percent?: number;
57
+ }
58
+ export interface ScheduledTrade extends BaseSystemFields {
59
+ symbol: string;
60
+ account: string;
61
+ profit?: number;
62
+ risk?: number;
63
+ entry?: number;
64
+ stop?: number;
65
+ risk_reward?: number;
66
+ profit_percent?: number;
67
+ place_tp?: boolean;
68
+ kind?: "long" | "short";
69
+ follow?: boolean | 1 | 0;
70
+ reduce_ratio?: number;
71
+ sell_ratio?: number;
72
+ threshold_qty?: number;
73
+ pause_tp?: boolean;
74
+ }
75
+ export interface AccountStrategy extends BaseSystemFields {
76
+ account: string;
77
+ symbol: string;
78
+ risk?: number;
79
+ reward_factor?: number;
80
+ kind?: "long" | "short";
81
+ support?: number;
82
+ resistance?: number;
83
+ running?: boolean;
84
+ max_reward_factor?: number;
85
+ follow?: boolean;
86
+ risk_reward?: number;
87
+ dynamic?: boolean;
88
+ }
89
+ interface Proxy$1 extends BaseSystemFields {
90
+ ip_address?: string;
91
+ type?: "http" | "socks5";
92
+ }
93
+ export interface TradeBlockTracking extends BaseSystemFields {
94
+ account?: string;
95
+ symbol?: string;
96
+ running?: boolean;
97
+ }
98
+ export interface PositionsView {
99
+ id: string;
100
+ symbol?: any;
101
+ entry?: any;
102
+ quantity?: any;
103
+ take_profit?: any;
104
+ account?: any;
105
+ kind?: any;
106
+ target_pnl?: number;
107
+ liquidation?: number;
108
+ avg_price?: number;
109
+ avg_qty?: number;
110
+ next_order?: number;
111
+ last_order?: number;
112
+ config?: any;
113
+ stop_loss?: {
114
+ price: number;
115
+ quantity: number;
116
+ };
117
+ stop_pnl?: any;
118
+ leverage?: any;
119
+ avg_liquidation?: any;
120
+ balance?: any;
121
+ reduce_ratio?: number;
122
+ sell_ratio?: number;
123
+ threshold_qty?: number;
124
+ follow?: boolean | 1 | 0;
125
+ current_price?: number;
126
+ usd_balance?: number;
127
+ }
128
+ export interface BullishMarket extends RecordModel {
129
+ id: string;
130
+ symbol: string;
131
+ risk: number;
132
+ }
133
+ export interface WindingDownMarket extends RecordModel {
134
+ id: string;
135
+ symbol: string;
136
+ risk_reward: number;
137
+ }
138
+ export interface BotInstance extends BaseSystemFields {
139
+ asset: string;
140
+ main_account?: string;
141
+ secondary_account?: string;
142
+ main_symbol: string;
143
+ secondary_symbol?: string;
144
+ direction?: "long" | "short";
145
+ budget?: number;
146
+ settings?: Record<string, any>;
147
+ user?: string;
148
+ }
149
+ export interface BotState extends BaseSystemFields {
150
+ bot: string;
151
+ running?: boolean;
152
+ status?: "main-trading" | "hedge-mode";
153
+ spot_quantity?: number;
154
+ exchange_details?: Record<string, any>;
155
+ completed?: boolean;
156
+ }
157
+ export interface BotOrderHistory extends BaseSystemFields {
158
+ field: string;
159
+ symbol: string;
160
+ pnl?: number;
161
+ kind?: "long" | "short";
162
+ type?: "future" | "spot";
163
+ }
164
+ export interface BotPositionData {
165
+ entry: number;
166
+ quantity: number;
167
+ tp: {
168
+ price: number;
169
+ quantity: number;
170
+ pnl: number;
171
+ };
172
+ current_price: number;
173
+ balance: number;
174
+ kind: "long" | "short";
175
+ next_order: number;
176
+ last_order: number;
177
+ avg: {
178
+ price: number;
179
+ quantity: number;
180
+ };
181
+ sl: {
182
+ price: number;
183
+ quantity: number;
184
+ pnl: number;
185
+ };
186
+ }
187
+ export interface BotView extends RecordModel {
188
+ id: string;
189
+ direction?: "long" | "short";
190
+ budget?: number;
191
+ main_symbol?: string;
192
+ main_long_position?: BotPositionData;
193
+ main_short_position?: BotPositionData;
194
+ secondary_symbol?: string;
195
+ secondary_long_position?: BotPositionData;
196
+ secondary_short_position?: BotPositionData;
197
+ main_account?: string;
198
+ secondary_account?: string;
199
+ settings?: Record<string, any>;
200
+ main_long_strategy?: string;
201
+ main_short_strategy?: string;
202
+ secondary_long_strategy?: string;
203
+ secondary_short_strategy?: string;
204
+ }
205
+ export type GlobalConfig = {
206
+ profit_percent: number;
207
+ symbol: string;
208
+ profit: number;
209
+ risk: number;
210
+ stop_percent: number;
211
+ kind: "long" | "short";
212
+ reduce_percent: number;
213
+ support: number;
214
+ resistance: number;
215
+ price_places: string;
216
+ decimal_places: string;
217
+ min_size: number;
218
+ accounts: {
219
+ owner: string;
220
+ exchange?: string;
221
+ }[];
222
+ risk_reward: number;
223
+ reverse_factor: number;
224
+ leverage?: number;
225
+ };
8
226
  interface Position$1 {
9
227
  id: number;
10
228
  kind: "long" | "short";
@@ -59,9 +277,39 @@ export interface Account {
59
277
  short: any;
60
278
  };
61
279
  }
62
- export interface BaseExchange {
280
+ interface Order$1 {
281
+ order_id?: string;
282
+ symbol?: string;
283
+ price: number;
284
+ quantity: number;
285
+ kind: "long" | "short";
286
+ side: "buy" | "sell";
287
+ stop: number;
288
+ triggerPrice?: number;
289
+ }
290
+ export interface CandlestickAnalysisResult {
291
+ candlesticks: {
292
+ [key: string]: any[];
293
+ };
294
+ resistance: {
295
+ [key: string]: number;
296
+ };
297
+ support: {
298
+ [key: string]: number;
299
+ };
300
+ current_price: number;
301
+ minimum_weekly: number;
302
+ }
303
+ declare abstract class BaseExchange {
63
304
  client: any;
64
- placeStopOrders(payload: {
305
+ constructor(client: any);
306
+ abstract rawCreateLimitPurchaseOrders(payload: {
307
+ symbol: string;
308
+ orders: Order$1[];
309
+ price_places?: string;
310
+ decimal_places?: string;
311
+ }): Promise<any>;
312
+ abstract placeStopOrders(payload: {
65
313
  symbol: string;
66
314
  quantity: number;
67
315
  kind: "long" | "short";
@@ -70,7 +318,7 @@ export interface BaseExchange {
70
318
  decimal_places?: string;
71
319
  place?: boolean;
72
320
  }): Promise<any>;
73
- bulkPlaceLimitOrders(payload: {
321
+ abstract bulkPlaceLimitOrders(payload: {
74
322
  orders: any[];
75
323
  kind: "long" | "short";
76
324
  decimal_places?: string;
@@ -78,30 +326,36 @@ export interface BaseExchange {
78
326
  symbol: string;
79
327
  place?: boolean;
80
328
  }): Promise<any>;
81
- get_current_price(symbol: string): Promise<any>;
82
- analyzeCharts(payload: {
329
+ abstract get_current_price(symbol: string): Promise<any>;
330
+ abstract analyzeCharts(payload: {
83
331
  symbol: string;
84
332
  chartType: any;
85
- count: number;
333
+ limit: number;
86
334
  raw?: boolean;
87
335
  }): Promise<any>;
88
- getExchangeAccountInfo(account: {
89
- owner: string;
90
- exchange: string;
91
- }, symbol: string): Promise<any>;
92
- cancelOrders(payload: {
336
+ abstract getExchangeAccountInfo(options: {
337
+ price_places?: string;
338
+ decimal_places?: string;
339
+ account: {
340
+ owner: string;
341
+ exchange: string;
342
+ };
343
+ symbol: string;
344
+ }): Promise<any>;
345
+ abstract cancelOrders(payload: {
93
346
  symbol: string;
94
347
  orders: number[];
95
348
  }): Promise<any>;
96
- placeTpOrder(payload: {
349
+ abstract placeTpOrder(payload: {
97
350
  symbol: string;
98
351
  take_profit: number;
99
352
  kind: "long" | "short";
100
353
  cancel?: boolean;
354
+ quantity?: number;
101
355
  price_places?: string;
102
356
  decimal_places?: string;
103
357
  }): Promise<any>;
104
- placeLimitOrder(payload: {
358
+ abstract placeLimitOrder(payload: {
105
359
  symbol: string;
106
360
  quantity: number;
107
361
  kind: "long" | "short";
@@ -109,7 +363,7 @@ export interface BaseExchange {
109
363
  price_places?: string;
110
364
  decimal_places?: string;
111
365
  }): Promise<any>;
112
- placeStopOrder(payload: {
366
+ abstract placeStopOrder(payload: {
113
367
  symbol: string;
114
368
  stop: number;
115
369
  quantity: number;
@@ -117,115 +371,120 @@ export interface BaseExchange {
117
371
  price_places?: string;
118
372
  decimal_places?: string;
119
373
  }): Promise<any>;
120
- setLeverage(payload: {
374
+ abstract setLeverage(payload: {
121
375
  symbol: string;
122
376
  leverage: number;
123
377
  }): Promise<any>;
378
+ abstract generateConfig(payload: {
379
+ symbol: string;
380
+ interval?: any;
381
+ limit?: number;
382
+ }): Promise<any>;
383
+ abstract checkDelistedMovers(payload: {
384
+ movePercent: number;
385
+ include_delisted?: boolean;
386
+ }): Promise<any>;
387
+ abstract closePosition(payload: {
388
+ symbol: string;
389
+ kind: "long" | "short";
390
+ price_places?: string;
391
+ decimal_places?: string;
392
+ }): Promise<any>;
393
+ abstract getAllOpenSymbols(): Promise<string[]>;
394
+ abstract createLimitPurchaseOrders(payload: {
395
+ orders: any[];
396
+ kind: "long" | "short";
397
+ decimal_places?: string;
398
+ price_places?: string;
399
+ symbol: string;
400
+ }): Promise<any>;
401
+ abstract getDelistedSpotSymbols(): Promise<any>;
402
+ abstract getOpenPositions(): Promise<any>;
403
+ abstract crossAccountTransfer(payload: {
404
+ from: {
405
+ owner: string;
406
+ wallet: string;
407
+ };
408
+ to: {
409
+ owner: string;
410
+ wallet: string;
411
+ };
412
+ asset: string;
413
+ amount: number;
414
+ }): Promise<any>;
415
+ abstract placeMarketOrder(payload: {
416
+ symbol: string;
417
+ kind: "long" | "short";
418
+ quantity: number;
419
+ price_places?: string;
420
+ decimal_places?: string;
421
+ }): Promise<any>;
422
+ customStopLoss(payload: {
423
+ price_places: string;
424
+ decimal_places: string;
425
+ symbol: string;
426
+ kind: "long" | "short";
427
+ stop: number;
428
+ quantity: number;
429
+ increase?: boolean;
430
+ }): Promise<any>;
431
+ abstract getOpenOrders(payload: {
432
+ symbol: string;
433
+ }): Promise<any>;
434
+ abstract placeBadStopEntry(payload: {
435
+ symbol: string;
436
+ orders: Order$1[];
437
+ price_places?: string;
438
+ decimal_places?: string;
439
+ }): Promise<any>;
440
+ analyzeCandlesticks(payload: {
441
+ symbol: string;
442
+ }): Promise<CandlestickAnalysisResult>;
124
443
  }
125
- export interface BaseSystemFields {
126
- id: string;
127
- created: string;
128
- updated: string;
129
- }
130
- export interface ExchangeAccount extends BaseSystemFields {
131
- exchange: "binance" | "bybit";
444
+ declare function initPocketBaseClient(proxy_credentials: {
445
+ host: string;
446
+ email: string;
447
+ password: string;
448
+ auto_cancellation?: boolean;
449
+ }): Promise<PocketBase>;
450
+ export type ExchangeType = {
132
451
  owner: string;
452
+ exchange: string;
453
+ };
454
+ export declare class AppDatabase {
455
+ pb: PocketBase;
133
456
  email?: string;
134
- user?: string;
135
- usdt?: number;
136
- usdc?: number;
137
- proxy?: string;
138
- }
139
- export interface SymbolConfig extends BaseSystemFields {
140
- symbol: string;
141
- support?: number;
142
- resistance?: number;
143
- stop_percent?: number;
144
- price_places?: string;
145
- decimal_places?: string;
146
- min_size?: number;
147
- weight?: number;
148
- leverage?: number;
149
- }
150
- export interface ScheduledTrade extends BaseSystemFields {
151
- symbol: string;
152
- account: string;
153
- profit?: number;
154
- risk?: number;
155
- entry?: number;
156
- stop?: number;
157
- risk_reward?: number;
158
- profit_percent?: number;
159
- place_tp?: boolean;
160
- kind?: "long" | "short";
161
- current_price?: number;
162
- }
163
- export interface Strategy extends BaseSystemFields {
164
- name: string;
165
- short_risk_factor?: number;
166
- long_risk_factor?: number;
167
- profit_percent?: number;
168
- cancel_short?: boolean;
169
- cancel_long?: boolean;
170
- recompute_short_config?: boolean;
171
- update_stop_loss?: boolean;
172
- liquidation_as_entry?: boolean;
173
- stop_as_entry?: boolean;
174
- tp_as_stop?: boolean;
175
- entry_as_stop?: boolean;
176
- place_stop?: boolean;
177
- save_config?: boolean;
178
- }
179
- interface Proxy$1 extends BaseSystemFields {
180
- ip_address?: string;
181
- type?: "http" | "socks5";
182
- }
183
- export interface TradeBlockTracking extends BaseSystemFields {
184
- account?: string;
185
- symbol?: string;
186
- running?: boolean;
187
- }
188
- export interface PositionsView {
189
- id: string;
190
- symbol?: any;
191
- entry?: any;
192
- quantity?: any;
193
- take_profit?: any;
194
- account?: any;
195
- kind?: any;
196
- target_pnl?: number;
197
- liquidation?: number;
198
- avg_price?: number;
199
- avg_qty?: number;
200
- next_order?: number;
201
- last_order?: number;
202
- config?: any;
203
- stop_loss?: {
204
- price: number;
205
- quantity: number;
206
- };
207
- stop_pnl?: any;
208
- leverage?: any;
209
- avg_liquidation?: any;
210
- balance?: any;
211
- }
212
- export interface BullishMarket extends RecordModel {
213
- id: string;
214
- symbol: string;
215
- risk: number;
216
- }
217
- export interface WindingDownMarket extends RecordModel {
218
- id: string;
219
- symbol: string;
220
- risk_reward: number;
221
- }
222
- export type ExchangeType = {
223
- owner: string;
224
- exchange: string;
225
- };
226
- export declare class AppDatabase {
227
- private pb;
228
- constructor(pb: PocketBase);
457
+ salt?: string;
458
+ constructor(pb: PocketBase, payload: {
459
+ email?: string;
460
+ salt?: string;
461
+ });
462
+ getUserByEmail(): Promise<import("pocketbase").RecordModel>;
463
+ generateUserPassword(): Promise<void>;
464
+ getUserCredentials(): Promise<any>;
465
+ getCredentials(payload: {
466
+ password?: string;
467
+ }): Promise<any>;
468
+ saveCredentials(params: {
469
+ password?: string;
470
+ credentials: any;
471
+ }): Promise<import("pocketbase").RecordModel>;
472
+ addNewCredential(params: {
473
+ password?: string;
474
+ payload: {
475
+ name: string;
476
+ email: string;
477
+ exchange: string;
478
+ api_key: string;
479
+ api_secret: string;
480
+ };
481
+ }): Promise<void>;
482
+ getAccountWithActivePositions(): Promise<import("pocketbase").RecordModel[]>;
483
+ getAllSymbolsFromPositions(options?: {
484
+ no_position?: boolean;
485
+ kind?: "long" | "short";
486
+ custom_filter?: string;
487
+ }): Promise<any[]>;
229
488
  createOrUpdateLiveExchangeInstance(payload: {
230
489
  account: ExchangeType;
231
490
  symbol: string;
@@ -238,18 +497,24 @@ export declare class AppDatabase {
238
497
  }): Promise<import("pocketbase").RecordModel>;
239
498
  getProxyForAccount(account: ExchangeType): Promise<HttpsProxyAgent<`http://${string}`> | SocksProxyAgent>;
240
499
  getAccounts(): Promise<ExchangeAccount[]>;
241
- getAllSymbolConfigs(with_positions?: boolean): Promise<SymbolConfig[]>;
500
+ getAllSymbolConfigs(payload?: {
501
+ with_positions?: boolean;
502
+ custom_filter?: string;
503
+ }): Promise<SymbolConfig[]>;
242
504
  get_exchange_db_instance(account: ExchangeType): Promise<ExchangeAccount & {
243
505
  expand?: {
244
506
  proxy: Proxy$1;
245
507
  };
246
508
  }>;
247
- getPositions(account: ExchangeType, options: {
248
- symbol: string;
509
+ getPositions(options: {
510
+ account?: ExchangeType;
511
+ symbol?: string;
249
512
  as_view?: boolean;
513
+ custom_filter?: string;
250
514
  }): Promise<(PositionsView & {
251
515
  expand?: {
252
516
  config: ScheduledTrade;
517
+ account: ExchangeAccount;
253
518
  };
254
519
  })[]>;
255
520
  private _createOrUpdatePosition;
@@ -261,6 +526,7 @@ export declare class AppDatabase {
261
526
  }): Promise<(PositionsView & {
262
527
  expand?: {
263
528
  config: ScheduledTrade;
529
+ account: ExchangeAccount;
264
530
  };
265
531
  })[]>;
266
532
  update_db_position(position: any, payload: any): Promise<import("pocketbase").RecordModel>;
@@ -272,7 +538,7 @@ export declare class AppDatabase {
272
538
  getOrders(account: ExchangeType, options: {
273
539
  symbol: string;
274
540
  kind: "long" | "short";
275
- }): Promise<import("pocketbase").RecordModel[]>;
541
+ }): Promise<Order[]>;
276
542
  deleteAndRecreateOrders(account: ExchangeType, options: {
277
543
  symbol: string;
278
544
  kind: "long" | "short";
@@ -285,7 +551,32 @@ export declare class AppDatabase {
285
551
  stop: number;
286
552
  order_id: string;
287
553
  triggerPrice?: number;
288
- }>): Promise<import("pocketbase").RecordModel[]>;
554
+ }>): Promise<Order[]>;
555
+ deleteAndBulCreateAllOrders(payload: {
556
+ account: ExchangeType & {
557
+ id: string;
558
+ };
559
+ symbol: string;
560
+ all_orders: Array<{
561
+ symbol: string;
562
+ price: number;
563
+ quantity: number;
564
+ kind: "long" | "short";
565
+ side: "buy" | "sell";
566
+ stop: number;
567
+ order_id: string;
568
+ triggerPrice?: number;
569
+ }>;
570
+ }): Promise<void>;
571
+ cancelLimitOrders(payload: {
572
+ symbol: string;
573
+ kind: "long" | "short";
574
+ account: ExchangeType;
575
+ cancelExchangeOrders: (payload: {
576
+ symbol: string;
577
+ orders: number[];
578
+ }) => Promise<any>;
579
+ }): Promise<void>;
289
580
  cancelOrders(payload: {
290
581
  cancelExchangeOrders: (payload: {
291
582
  symbol: string;
@@ -313,30 +604,69 @@ export declare class AppDatabase {
313
604
  message?: undefined;
314
605
  exchange_result?: undefined;
315
606
  }>;
607
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
608
+ updateScheduledTrade(id: string, payload: any): Promise<import("pocketbase").RecordModel>;
609
+ getPositionsToAutoFollow(): Promise<(Position$1 & {
610
+ expand: {
611
+ account: ExchangeAccount;
612
+ };
613
+ })[]>;
316
614
  createOrUpdatePositionConfig(db_position: any, payload: {
317
615
  entry: number;
318
616
  stop: number;
319
617
  risk_reward: number;
320
618
  risk: number;
321
619
  profit_percent?: number;
322
- }): Promise<void>;
620
+ place_tp?: boolean;
621
+ profit?: number;
622
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
323
623
  getPositionConfig(payload: {
324
624
  symbol: string;
325
625
  kind: "long" | "short";
326
626
  account: ExchangeType;
327
627
  }): Promise<ScheduledTrade | null>;
328
- getPositionStrategy(account: ExchangeType): Promise<{
329
- strategy_instance: Strategy;
330
- focus_account: ExchangeAccount;
331
- }>;
332
- createOrUpdateWindingDownMarket(symbol: string): Promise<import("pocketbase").RecordModel>;
628
+ getRunningAccountStrategies(): Promise<(AccountStrategy & {
629
+ expand?: {
630
+ account: ExchangeAccount;
631
+ };
632
+ })[]>;
633
+ getAccountStrategy(payload: {
634
+ symbol: string;
635
+ account: ExchangeType;
636
+ }): Promise<AccountStrategy>;
637
+ getBotViewInstance(payload: {
638
+ asset: string;
639
+ main_account: ExchangeType;
640
+ }): Promise<BotView | null>;
641
+ getBotInstance(payload: {
642
+ asset: string;
643
+ main_account: ExchangeType;
644
+ }): Promise<BotInstance | null>;
645
+ getBotState(payload: {
646
+ asset: string;
647
+ main_account: ExchangeType;
648
+ running?: boolean;
649
+ }): Promise<BotState[]>;
650
+ getBotOrderHistories(payload: {
651
+ asset: string;
652
+ main_account: ExchangeType;
653
+ symbol?: string;
654
+ kind?: "long" | "short";
655
+ type?: "future" | "spot";
656
+ }): Promise<BotOrderHistory[]>;
657
+ createOrUpdateWindingDownMarket(payload: {
658
+ symbol: string;
659
+ risk_reward?: number;
660
+ }): Promise<import("pocketbase").RecordModel>;
333
661
  getWindingDownMarkets(symbol?: string): Promise<WindingDownMarket[]>;
662
+ getBullishMarket(symbol: string): Promise<BullishMarket>;
334
663
  getBullishMarkets(options?: {
335
664
  new_markets: Array<{
336
665
  symbol: string;
337
666
  percent: number;
338
667
  }>;
339
668
  totalRisk: number;
669
+ max_count?: number;
340
670
  }): Promise<{
341
671
  updated_bullish: BullishMarket[];
342
672
  moved_to_winding: WindingDownMarket[];
@@ -357,20 +687,425 @@ export declare class AppDatabase {
357
687
  } | SymbolConfig[]>;
358
688
  unwindSymbolFromDB(symbol: string): Promise<boolean>;
359
689
  hasExistingPosition(symbol: string): Promise<import("pocketbase").RecordModel[]>;
690
+ hasExistingOrders(symbol: string): Promise<import("pocketbase").RecordModel[]>;
360
691
  removeSymbolFromUnwindingMarkets(symbol: string): Promise<boolean>;
361
692
  removePosition(position: any): Promise<void>;
362
693
  removePositionConfig(position: any): Promise<void>;
363
694
  }
364
- export interface CodeNode {
695
+ export type StrategyPosition = {
696
+ entry: number;
697
+ quantity: number;
698
+ avg_price?: number;
699
+ avg_qty?: number;
700
+ };
701
+ export type GapCloserResult = {
702
+ avg_entry: number;
703
+ avg_size: number;
704
+ loss: number;
705
+ stop: number;
706
+ stop_quantity: number;
707
+ re_entry_quantity: number;
708
+ initial_pnl: number;
709
+ tp: number;
710
+ incurred_loss: number;
711
+ pnl: number;
712
+ remaining_quantity: number;
713
+ };
714
+ export type Config = {
715
+ tp_percent: number;
716
+ short_tp_factor: number;
717
+ fee_percent?: number;
718
+ budget: number;
719
+ risk_reward: number;
720
+ reduce_ratio: number;
721
+ global_config: GlobalConfig;
722
+ };
723
+ export declare class Strategy {
724
+ position: {
725
+ long: StrategyPosition;
726
+ short: StrategyPosition;
727
+ };
728
+ dominant_position?: "long" | "short";
729
+ config: Config;
730
+ constructor(payload: {
731
+ long: StrategyPosition;
732
+ short: StrategyPosition;
733
+ config: Config;
734
+ dominant_position?: "long" | "short";
735
+ });
736
+ get price_places(): string;
737
+ get decimal_places(): string;
738
+ to_f(price: number): number;
739
+ to_df(quantity: number): number;
740
+ pnl(kind: "long" | "short", _position?: StrategyPosition): number;
741
+ tp(kind: "long" | "short"): number;
742
+ calculate_fee(position: {
743
+ price: number;
744
+ quantity: number;
745
+ }): number;
746
+ get long_tp(): number;
747
+ get short_tp(): number;
748
+ generateGapClosingAlgorithm(payload: {
749
+ kind: "long" | "short";
750
+ ignore_entries?: boolean;
751
+ reduce_ratio?: number;
752
+ sell_factor?: number;
753
+ }): {
754
+ last_entry: any;
755
+ first_entry: any;
756
+ threshold: any;
757
+ risk: number;
758
+ risk_reward: number;
759
+ spread: number;
760
+ gap_loss: number;
761
+ net_profit: number;
762
+ long: GapCloserResult;
763
+ short: GapCloserResult;
764
+ };
765
+ gapCloserHelper(payload: {
766
+ risk: number;
767
+ entries?: any[];
768
+ kind: "long" | "short";
769
+ sell_factor?: number;
770
+ reduce_ratio?: number;
771
+ }): {
772
+ risk: number;
773
+ risk_reward: number;
774
+ spread: number;
775
+ gap_loss: number;
776
+ net_profit: number;
777
+ long: GapCloserResult;
778
+ short: GapCloserResult;
779
+ };
780
+ runIterations(payload: {
781
+ kind: "long" | "short";
782
+ iterations: number;
783
+ risk_reward?: number;
784
+ ignore_entries?: boolean;
785
+ reduce_ratio?: number;
786
+ sell_factor?: number;
787
+ }): {
788
+ last_entry: any;
789
+ first_entry: any;
790
+ threshold: any;
791
+ risk: number;
792
+ risk_reward: number;
793
+ spread: number;
794
+ gap_loss: number;
795
+ net_profit: number;
796
+ long: GapCloserResult;
797
+ short: GapCloserResult;
798
+ }[];
799
+ getPositionAfterTp(payload: {
800
+ kind: "long" | "short";
801
+ include_fees?: boolean;
802
+ }): {
803
+ [x: string]: number | {
804
+ entry: number;
805
+ quantity: number;
806
+ diff?: undefined;
807
+ } | {
808
+ [x: string]: number;
809
+ diff: number;
810
+ entry?: undefined;
811
+ quantity?: undefined;
812
+ };
813
+ pnl: {
814
+ [x: string]: number;
815
+ diff: number;
816
+ };
817
+ spread: number;
818
+ };
819
+ getPositionAfterIteration(payload: {
820
+ kind: "long" | "short";
821
+ iterations: number;
822
+ with_fees?: boolean;
823
+ }): {
824
+ [x: string]: number | {
825
+ entry: number;
826
+ quantity: number;
827
+ diff?: undefined;
828
+ } | {
829
+ [x: string]: number;
830
+ diff: number;
831
+ entry?: undefined;
832
+ quantity?: undefined;
833
+ };
834
+ pnl: {
835
+ [x: string]: number;
836
+ diff: number;
837
+ };
838
+ spread: number;
839
+ }[];
840
+ /**To be used as one of the agent tools eventually since
841
+ * it is something that can be triggered continously without
842
+ * any risk
843
+ */
844
+ generateOppositeTrades(payload: {
845
+ kind: "long" | "short";
846
+ risk_factor?: number;
847
+ avg_entry?: number;
848
+ }): {
849
+ avg: {
850
+ entry: number;
851
+ price: number;
852
+ quantity: number;
853
+ };
854
+ loss: number;
855
+ profit_percent: number;
856
+ fee: number;
857
+ risk_per_trade: number;
858
+ risk_reward: number;
859
+ symbol?: string;
860
+ focus: number;
861
+ budget: number;
862
+ support: number;
863
+ resistance: number;
864
+ percent_change: number;
865
+ tradeSplit?: number;
866
+ take_profit?: number;
867
+ kind: "long" | "short";
868
+ entry: number;
869
+ stop: number;
870
+ min_size: number;
871
+ price_places?: string;
872
+ strategy?: "quantity" | "entry";
873
+ as_array?: boolean;
874
+ decimal_places?: string;
875
+ min_profit?: number;
876
+ raw?: boolean;
877
+ gap?: number;
878
+ rr?: number;
879
+ max_size?: number;
880
+ };
881
+ identifyGapConfig(payload: {
882
+ factor?: number;
883
+ sell_factor?: number;
884
+ kind?: "long" | "short";
885
+ risk?: number;
886
+ }): {
887
+ profit_percent: {
888
+ long: number;
889
+ short: number;
890
+ };
891
+ risk: {
892
+ short: number;
893
+ long: number;
894
+ };
895
+ take_profit: {
896
+ long: number;
897
+ short: number;
898
+ };
899
+ to_reduce: {
900
+ short: number;
901
+ long: number;
902
+ };
903
+ full_reduce: {
904
+ short: number;
905
+ long: number;
906
+ };
907
+ sell_quantity: {
908
+ short: number;
909
+ long: number;
910
+ };
911
+ gap: number;
912
+ gap_loss: number;
913
+ };
914
+ analyzeProfit(payload: {
915
+ reward_factor?: number;
916
+ max_reward_factor: number;
917
+ risk: number;
918
+ kind: "long" | "short";
919
+ }): {
920
+ pnl: number;
921
+ loss: number;
922
+ original_pnl: number;
923
+ reward_factor: number;
924
+ profit_percent: number;
925
+ kind: "long" | "short";
926
+ sell_price: number;
927
+ quantity: number;
928
+ price_places: string;
929
+ decimal_places: string;
930
+ };
931
+ simulateGapReduction(payload: {
932
+ iterations?: number;
933
+ factor?: number;
934
+ direction: "long" | "short";
935
+ kind?: "long" | "short";
936
+ risk?: number;
937
+ sell_factor?: number;
938
+ }): {
939
+ results: {
940
+ profit_percent: {
941
+ long: number;
942
+ short: number;
943
+ };
944
+ risk: {
945
+ short: number;
946
+ long: number;
947
+ };
948
+ take_profit: {
949
+ long: number;
950
+ short: number;
951
+ };
952
+ sell_quantity: {
953
+ short: number;
954
+ long: number;
955
+ };
956
+ gap_loss: number;
957
+ position: {
958
+ long: {
959
+ entry: number;
960
+ quantity: number;
961
+ };
962
+ short: {
963
+ entry: number;
964
+ quantity: number;
965
+ };
966
+ };
967
+ }[];
968
+ quantity: number;
969
+ };
970
+ }
971
+ export type SignalConfigType = {
972
+ focus: number;
973
+ budget: number;
974
+ percent_change?: number;
975
+ price_places?: string;
976
+ decimal_places?: string;
977
+ zone_risk?: number;
978
+ fee?: number;
979
+ support?: number;
980
+ risk_reward?: number;
981
+ resistance?: number;
982
+ risk_per_trade?: number;
983
+ increase_size?: boolean;
984
+ additional_increase?: number;
985
+ minimum_pnl?: number;
986
+ take_profit?: number;
987
+ increase_position?: boolean;
988
+ minimum_size?: number;
989
+ first_order_size?: number;
990
+ gap?: number;
991
+ max_size?: number;
992
+ };
993
+ declare class Signal {
994
+ focus: number;
995
+ budget: number;
996
+ percent_change: number;
997
+ price_places: string;
998
+ decimal_places: string;
999
+ zone_risk: number;
1000
+ fee: number;
1001
+ support?: number;
1002
+ risk_reward: number;
1003
+ resistance?: number;
1004
+ risk_per_trade?: number;
1005
+ increase_size: boolean;
1006
+ additional_increase: number;
365
1007
  minimum_pnl: number;
1008
+ take_profit?: number;
1009
+ increase_position: boolean;
1010
+ minimum_size: any;
1011
+ first_order_size: number;
1012
+ gap: number;
366
1013
  max_size: number;
367
- profit: number;
368
- ratio?: number;
369
- increase: boolean;
370
- not_reduce?: boolean;
371
- reduce_ratio?: number;
372
- use_full?: boolean;
1014
+ constructor({ focus, budget, percent_change, price_places, decimal_places, zone_risk, fee, support, risk_reward, resistance, risk_per_trade, increase_size, additional_increase, minimum_pnl, take_profit, increase_position, minimum_size, first_order_size, gap, max_size, }: SignalConfigType);
1015
+ build_entry({ current_price, stop_loss, pnl, stop_percent, kind, risk, no_of_trades, take_profit, }: {
1016
+ take_profit?: number;
1017
+ no_of_trades?: number;
1018
+ current_price: number;
1019
+ stop_loss?: number;
1020
+ kind?: "long" | "short";
1021
+ risk: number;
1022
+ stop_percent?: number;
1023
+ pnl?: number;
1024
+ }): any;
1025
+ get risk(): number;
1026
+ get min_trades(): number;
1027
+ get min_price(): number;
1028
+ build_opposite_order({ current_price, kind, }: {
1029
+ current_price: number;
1030
+ kind?: "long" | "short";
1031
+ }): any;
1032
+ special_build_orders({ current_price, kind, }: {
1033
+ current_price: number;
1034
+ kind?: "long" | "short";
1035
+ }): any;
1036
+ build_orders({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
1037
+ current_price: number;
1038
+ kind?: "long" | "short";
1039
+ limit?: boolean;
1040
+ replace_focus?: boolean;
1041
+ max_index?: number;
1042
+ min_index?: number;
1043
+ }): any;
1044
+ build_orders_old({ current_price, kind, limit, replace_focus, max_index, min_index, }: {
1045
+ current_price: number;
1046
+ kind?: "long" | "short";
1047
+ limit?: boolean;
1048
+ replace_focus?: boolean;
1049
+ max_index?: number;
1050
+ min_index?: number;
1051
+ }): any;
1052
+ get_bulk_trade_zones({ current_price, kind, limit, }: {
1053
+ current_price: number;
1054
+ kind?: "long" | "short";
1055
+ limit?: boolean;
1056
+ }): any;
1057
+ get_future_zones({ current_price, kind, raw, }: {
1058
+ raw?: boolean;
1059
+ current_price: number;
1060
+ kind?: "long" | "short";
1061
+ }): number[];
1062
+ to_f(value: number, places?: string): number;
1063
+ get_margin_zones({ current_price, kind, }: {
1064
+ current_price: number;
1065
+ kind?: "long" | "short";
1066
+ }): number[][];
1067
+ get_margin_range(current_price: number, kind?: string): number[];
1068
+ process_orders({ current_price, stop_loss, trade_zones, kind, }: {
1069
+ current_price: number;
1070
+ stop_loss: number;
1071
+ trade_zones: number[];
1072
+ kind?: "long" | "short";
1073
+ }): any[];
1074
+ get_risk_per_trade(number_of_orders: number): number;
1075
+ build_trade_dict({ entry, stop, risk, arr, index, new_fees, kind, start, take_profit, }: {
1076
+ entry: number;
1077
+ stop: number;
1078
+ risk: number;
1079
+ arr: number[];
1080
+ index: number;
1081
+ new_fees?: number;
1082
+ kind?: "long" | "short";
1083
+ start?: number;
1084
+ take_profit?: number;
1085
+ }): {
1086
+ entry: number;
1087
+ risk: number;
1088
+ quantity: number;
1089
+ sell_price: number;
1090
+ risk_sell: number;
1091
+ stop: number;
1092
+ pnl: number;
1093
+ fee: number;
1094
+ net: number;
1095
+ incurred: number;
1096
+ stop_percent: number;
1097
+ };
1098
+ to_df(currentPrice: number, places?: string): number;
373
1099
  }
1100
+ export declare function determine_average_entry_and_size(orders: Array<{
1101
+ price: number;
1102
+ quantity: number;
1103
+ }>, places?: string, price_places?: string): {
1104
+ entry: number;
1105
+ price: number;
1106
+ quantity: number;
1107
+ };
1108
+ export declare const createArray: (start: number, stop: number, step: number) => number[];
374
1109
  export type AppConfig = {
375
1110
  fee: number;
376
1111
  risk_per_trade: number;
@@ -396,71 +1131,476 @@ export type AppConfig = {
396
1131
  gap?: number;
397
1132
  rr?: number;
398
1133
  max_size?: number;
1134
+ last_value?: any;
1135
+ entries?: any[];
399
1136
  };
400
- declare class ExchangeAccount$1 {
401
- private instance;
402
- private exchange;
403
- private app_db;
404
- constructor(payload: ExchangeType, options: {
405
- exchange: BaseExchange;
406
- app_db: AppDatabase;
407
- });
408
- /**
409
- *In order to avoid rate limiting issues, we cache the live exchange
410
- details for each symbol for an account in the database with an option
411
- to refresh.
412
- */
413
- getLiveExchangeInstance(payload: {
414
- symbol: string;
415
- refresh?: boolean;
416
- price_places?: string;
417
- decimal_places?: string;
418
- }): Promise<import("pocketbase").RecordModel>;
419
- getActiveAccount(symbol: string, full?: boolean): Promise<Account | {
420
- liquidation: {
421
- long: number;
422
- short: number;
423
- };
424
- active_account: Account;
425
- current_price: any;
426
- exchange: any;
427
- }>;
428
- syncAccount(options: {
429
- symbol: string;
430
- kind?: "long" | "short";
431
- update?: boolean;
432
- as_view?: boolean;
433
- leverage?: number;
434
- }): Promise<(PositionsView & {
435
- expand?: {
436
- config: ScheduledTrade;
437
- };
438
- }) | (PositionsView & {
439
- expand?: {
440
- config: ScheduledTrade;
441
- };
442
- })[]>;
443
- getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
444
- syncOrders(options: {
445
- symbol: string;
446
- kind: "long" | "short";
447
- update?: boolean;
448
- }): Promise<import("pocketbase").RecordModel[]>;
449
- toggleStopBuying(payload: {
450
- symbol: string;
451
- kind: "long" | "short";
452
- should_stop?: boolean;
453
- }): Promise<import("pocketbase").RecordModel>;
454
- cancelOrders(payload: {
455
- symbol: string;
456
- kind: "long" | "short";
457
- price?: number;
458
- all?: boolean;
459
- stop?: boolean;
460
- }): Promise<{
461
- success: boolean;
462
- message: string;
463
- exchange_result?: undefined;
1137
+ export type ExtendConfigType = {
1138
+ take_profit?: number;
1139
+ entry: number;
1140
+ risk?: number;
1141
+ stop?: number;
1142
+ risk_reward?: number;
1143
+ raw_instance?: boolean;
1144
+ no_of_trades?: number;
1145
+ increase?: boolean;
1146
+ price_places?: string;
1147
+ decimal_places?: string;
1148
+ min_profit?: number;
1149
+ kind?: "long" | "short";
1150
+ gap?: number;
1151
+ rr?: number;
1152
+ };
1153
+ export declare function buildConfig(app_config: AppConfig, { take_profit, entry, stop, raw_instance, risk, no_of_trades, min_profit, risk_reward, kind, increase, gap, rr, price_places, decimal_places, }: ExtendConfigType): any[] | Signal;
1154
+ export declare function buildAvg({ _trades, kind, }: {
1155
+ _trades: any[];
1156
+ kind: "long" | "short";
1157
+ }): any;
1158
+ export declare function sortedBuildConfig(app_config: AppConfig, options: any): any[];
1159
+ export declare function get_app_config_and_max_size(config: GlobalConfig, payload: {
1160
+ entry: number;
1161
+ stop: number;
1162
+ kind: "long" | "short";
1163
+ }): {
1164
+ app_config: AppConfig;
1165
+ max_size: any;
1166
+ last_value: any;
1167
+ entries: {
1168
+ entry: any;
1169
+ avg_entry: any;
1170
+ avg_size: any;
1171
+ neg_pnl: any;
1172
+ quantity: any;
1173
+ }[];
1174
+ };
1175
+ export declare function buildAppConfig(config: GlobalConfig, payload: {
1176
+ entry: number;
1177
+ stop: number;
1178
+ risk_reward: number;
1179
+ risk: number;
1180
+ symbol: string;
1181
+ profit?: number;
1182
+ }): AppConfig;
1183
+ export declare function getOptimumStopAndRisk(app_config: AppConfig, params: {
1184
+ max_size: number;
1185
+ target_stop: number;
1186
+ highest_risk?: number;
1187
+ }): {
1188
+ optimal_stop: number;
1189
+ optimal_risk: number;
1190
+ avg_size: any;
1191
+ avg_entry: any;
1192
+ result: any[];
1193
+ first_entry: any;
1194
+ neg_pnl: any;
1195
+ risk_reward: number;
1196
+ size_diff: number;
1197
+ entry_diff: number;
1198
+ };
1199
+ export declare function generate_config_params(app_config: AppConfig, payload: {
1200
+ entry: number;
1201
+ stop: number;
1202
+ risk_reward: number;
1203
+ risk: number;
1204
+ symbol: string;
1205
+ }): {
1206
+ entry: number;
1207
+ stop: number;
1208
+ avg_size: any;
1209
+ avg_entry: any;
1210
+ risk_reward: number;
1211
+ neg_pnl: any;
1212
+ risk: number;
1213
+ };
1214
+ export declare function determine_break_even_price(payload: {
1215
+ long_position: {
1216
+ entry: number;
1217
+ quantity: number;
1218
+ };
1219
+ short_position: {
1220
+ entry: number;
1221
+ quantity: number;
1222
+ };
1223
+ fee_percent?: number;
1224
+ }): {
1225
+ price: number;
1226
+ direction: string;
1227
+ };
1228
+ export declare function determine_amount_to_buy(payload: {
1229
+ orders: any[];
1230
+ kind: "long" | "short";
1231
+ decimal_places?: string;
1232
+ price_places?: string;
1233
+ place?: boolean;
1234
+ position: any;
1235
+ existingOrders: any[];
1236
+ }): any[];
1237
+ export declare function generateOptimumAppConfig(config: GlobalConfig, payload: {
1238
+ entry: number;
1239
+ stop: number;
1240
+ risk_reward: number;
1241
+ start_risk: number;
1242
+ max_risk?: number;
1243
+ }, position: {
1244
+ entry: number;
1245
+ quantity: number;
1246
+ kind: "long" | "short";
1247
+ }): AppConfig | null;
1248
+ export declare function determineOptimumReward(app_config: AppConfig, increase?: boolean, low_range?: number, high_range?: number): number | {
1249
+ result: any[];
1250
+ value: number;
1251
+ total: number;
1252
+ risk_per_trade: number;
1253
+ max: number;
1254
+ min: number;
1255
+ neg_pnl: any;
1256
+ entry: any;
1257
+ };
1258
+ export declare function computeRiskReward(payload: {
1259
+ app_config: AppConfig;
1260
+ entry: number;
1261
+ stop: number;
1262
+ risk_per_trade: number;
1263
+ }): number | {
1264
+ result: any[];
1265
+ value: number;
1266
+ total: number;
1267
+ risk_per_trade: number;
1268
+ max: number;
1269
+ min: number;
1270
+ neg_pnl: any;
1271
+ entry: any;
1272
+ };
1273
+ export declare function getRiskReward(payload: {
1274
+ entry: number;
1275
+ stop: number;
1276
+ risk: number;
1277
+ global_config: GlobalConfig;
1278
+ }): any;
1279
+ export declare function computeProfitDetail(payload: {
1280
+ focus_position: {
1281
+ kind: "long" | "short";
1282
+ entry: number;
1283
+ quantity: number;
1284
+ avg_qty: number;
1285
+ avg_price: number;
1286
+ };
1287
+ strategy: {
1288
+ reward_factor: number;
1289
+ max_reward_factor: number;
1290
+ risk: number;
1291
+ };
1292
+ pnl: number;
1293
+ reduce_position?: {
1294
+ kind: "long" | "short";
1295
+ entry: number;
1296
+ quantity: number;
1297
+ avg_qty: number;
1298
+ avg_price: number;
1299
+ };
1300
+ reverse_position?: {
1301
+ kind: "long" | "short";
1302
+ avg_qty: number;
1303
+ avg_price: number;
1304
+ stop_loss: {
1305
+ price: number;
1306
+ quantity: number;
1307
+ };
1308
+ };
1309
+ price_places?: string;
1310
+ decimal_places?: string;
1311
+ }): {
1312
+ pnl: number;
1313
+ loss: number;
1314
+ original_pnl: number;
1315
+ reward_factor: number;
1316
+ profit_percent: number;
1317
+ kind: "long" | "short";
1318
+ sell_price: number;
1319
+ quantity: number;
1320
+ price_places: string;
1321
+ decimal_places: string;
1322
+ };
1323
+ export declare function generateGapTp(payload: {
1324
+ long: {
1325
+ entry: number;
1326
+ quantity: number;
1327
+ };
1328
+ short: {
1329
+ entry: number;
1330
+ quantity: number;
1331
+ };
1332
+ risk?: number;
1333
+ kind?: "long" | "short";
1334
+ factor?: number;
1335
+ sell_factor?: number;
1336
+ price_places?: string;
1337
+ decimal_places?: string;
1338
+ }): {
1339
+ profit_percent: {
1340
+ long: number;
1341
+ short: number;
1342
+ };
1343
+ risk: {
1344
+ short: number;
1345
+ long: number;
1346
+ };
1347
+ take_profit: {
1348
+ long: number;
1349
+ short: number;
1350
+ };
1351
+ to_reduce: {
1352
+ short: number;
1353
+ long: number;
1354
+ };
1355
+ full_reduce: {
1356
+ short: number;
1357
+ long: number;
1358
+ };
1359
+ sell_quantity: {
1360
+ short: number;
1361
+ long: number;
1362
+ };
1363
+ gap: number;
1364
+ gap_loss: number;
1365
+ };
1366
+ export declare function determineRewardFactor(payload: {
1367
+ quantity: number;
1368
+ avg_qty: number;
1369
+ minimum_pnl: number;
1370
+ risk: number;
1371
+ }): number;
1372
+ export declare function getHedgeZone(payload: {
1373
+ symbol_config: GlobalConfig;
1374
+ risk: number;
1375
+ position: {
1376
+ kind: "long" | "short";
1377
+ entry: number;
1378
+ quantity: number;
1379
+ tp: {
1380
+ price: number;
1381
+ };
1382
+ };
1383
+ reward_factor: number;
1384
+ risk_factor?: number;
1385
+ }): {
1386
+ support: number;
1387
+ resistance: number;
1388
+ risk: number;
1389
+ profit_percent: number;
1390
+ };
1391
+ declare class ExchangePosition {
1392
+ exchange: BaseExchange;
1393
+ exchange_account: ExchangeAccount$1;
1394
+ private app_db;
1395
+ private instance;
1396
+ constructor(payload: {
1397
+ exchange: BaseExchange;
1398
+ app_db: AppDatabase;
1399
+ instance: PositionsView;
1400
+ exchange_account: ExchangeAccount$1;
1401
+ without_view?: PositionsView;
1402
+ });
1403
+ get symbol(): any;
1404
+ get kind(): any;
1405
+ get account(): any;
1406
+ cancelOrders(payload: {
1407
+ limit?: boolean;
1408
+ price?: number;
1409
+ }): Promise<void | {
1410
+ success: boolean;
1411
+ message: string;
1412
+ exchange_result?: undefined;
1413
+ error?: undefined;
1414
+ } | {
1415
+ success: boolean;
1416
+ exchange_result: any;
1417
+ message?: undefined;
1418
+ error?: undefined;
1419
+ } | {
1420
+ success: boolean;
1421
+ error: any;
1422
+ message?: undefined;
1423
+ exchange_result?: undefined;
1424
+ }>;
1425
+ getConfig(payload?: {
1426
+ params?: {
1427
+ entry?: number;
1428
+ stop?: number;
1429
+ risk_reward?: number;
1430
+ risk?: number;
1431
+ profit_percent?: number;
1432
+ place_tp?: boolean;
1433
+ profit?: number;
1434
+ };
1435
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
1436
+ updateTargetPnl(): Promise<number>;
1437
+ updateConfigPnl(): Promise<void>;
1438
+ triggerTradeFromConfig(payload: {
1439
+ place?: boolean;
1440
+ raw?: boolean;
1441
+ tp?: boolean;
1442
+ stop?: boolean;
1443
+ use_current?: boolean;
1444
+ ignore_config?: boolean;
1445
+ }): Promise<any>;
1446
+ placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
1447
+ entry: number;
1448
+ stop: number;
1449
+ risk_reward: number;
1450
+ risk: number;
1451
+ place?: boolean;
1452
+ update_db?: boolean;
1453
+ raw?: boolean;
1454
+ use_current?: boolean;
1455
+ }): Promise<any>;
1456
+ buildAppConfig(payload: {
1457
+ entry: number;
1458
+ stop: number;
1459
+ risk_reward: number;
1460
+ risk: number;
1461
+ profit?: number;
1462
+ update_db?: boolean;
1463
+ profit_percent?: number;
1464
+ }): Promise<AppConfig>;
1465
+ placeConfigOrders(app_config: AppConfig, solution: {
1466
+ risk_reward: number;
1467
+ entry: number;
1468
+ stop: number;
1469
+ risk_per_trade: number;
1470
+ avg_size: number;
1471
+ neg_pnl: number;
1472
+ min_size: number;
1473
+ symbol: string;
1474
+ }, place?: boolean, skip_stop?: boolean): Promise<{
1475
+ entry_orders: {
1476
+ orders: {
1477
+ entry: any;
1478
+ quantity: any;
1479
+ reverse_avg_entry: any;
1480
+ reverse_avg_quantity: any;
1481
+ avg_entry: any;
1482
+ avg_size: any;
1483
+ }[];
1484
+ kind: "long" | "short";
1485
+ };
1486
+ stop_orders: {
1487
+ stop: number;
1488
+ final_stop: number;
1489
+ kind: "long" | "short";
1490
+ quantity: any;
1491
+ is_limit: boolean;
1492
+ neg_pnl: any;
1493
+ };
1494
+ trades: any[];
1495
+ }>;
1496
+ determineAmountToBuy(payload: {
1497
+ orders: any[];
1498
+ kind: "long" | "short";
1499
+ refresh?: boolean;
1500
+ decimal_places?: string;
1501
+ price_places?: string;
1502
+ cancel?: boolean;
1503
+ place?: boolean;
1504
+ }): Promise<any[]>;
1505
+ refresh(live_refresh?: boolean): Promise<{
1506
+ instance: PositionsView;
1507
+ existingOrders: void | Order[];
1508
+ }>;
1509
+ placeTrade(payload: {
1510
+ place?: boolean;
1511
+ tp?: boolean;
1512
+ stop?: boolean;
1513
+ raw?: boolean;
1514
+ cancel?: boolean;
1515
+ ignore_config?: boolean;
1516
+ }): Promise<any>;
1517
+ }
1518
+ declare class ExchangeAccount$1 {
1519
+ private instance;
1520
+ exchange: BaseExchange;
1521
+ main_exchange?: BaseExchange;
1522
+ private app_db;
1523
+ private long_position?;
1524
+ private short_position?;
1525
+ constructor(payload: ExchangeType, options: {
1526
+ exchange: BaseExchange;
1527
+ app_db: AppDatabase;
1528
+ main_exchange?: BaseExchange;
1529
+ });
1530
+ /**
1531
+ *In order to avoid rate limiting issues, we cache the live exchange
1532
+ details for each symbol for an account in the database with an option
1533
+ to refresh.
1534
+ */
1535
+ getDBInstance(): AppDatabase;
1536
+ getLiveExchangeInstance(payload: {
1537
+ symbol: string;
1538
+ refresh?: boolean;
1539
+ refresh_symbol_config?: boolean;
1540
+ }): Promise<import("pocketbase").RecordModel>;
1541
+ initializePositions(payload: {
1542
+ symbol: string;
1543
+ as_view?: boolean;
1544
+ kind: "long" | "short";
1545
+ }): Promise<ExchangePosition>;
1546
+ getActiveAccount(payload: {
1547
+ symbol: string;
1548
+ full?: boolean;
1549
+ refresh?: boolean;
1550
+ }): Promise<Account | {
1551
+ liquidation: {
1552
+ long: number;
1553
+ short: number;
1554
+ };
1555
+ active_account: Account;
1556
+ current_price: any;
1557
+ exchange: any;
1558
+ }>;
1559
+ refreshAccount(payload: {
1560
+ symbol: string;
1561
+ live_refresh?: boolean;
1562
+ leverage?: number;
1563
+ }): Promise<(PositionsView & {
1564
+ expand?: {
1565
+ config: ScheduledTrade;
1566
+ account: ExchangeAccount;
1567
+ };
1568
+ })[]>;
1569
+ syncAccount(options: {
1570
+ symbol: string;
1571
+ kind?: "long" | "short";
1572
+ update?: boolean;
1573
+ as_view?: boolean;
1574
+ leverage?: number;
1575
+ live_refresh?: boolean;
1576
+ }): Promise<PositionsView | (PositionsView & {
1577
+ expand?: {
1578
+ config: ScheduledTrade;
1579
+ account: ExchangeAccount;
1580
+ };
1581
+ })[]>;
1582
+ getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
1583
+ syncOrders(options: {
1584
+ symbol: string;
1585
+ kind?: "long" | "short";
1586
+ update?: boolean;
1587
+ }): Promise<void | Order[]>;
1588
+ toggleStopBuying(payload: {
1589
+ symbol: string;
1590
+ kind: "long" | "short";
1591
+ should_stop?: boolean;
1592
+ }): Promise<import("pocketbase").RecordModel>;
1593
+ cancelOrders(payload: {
1594
+ symbol: string;
1595
+ kind: "long" | "short";
1596
+ price?: number;
1597
+ all?: boolean;
1598
+ stop?: boolean;
1599
+ limit?: boolean;
1600
+ }): Promise<void | {
1601
+ success: boolean;
1602
+ message: string;
1603
+ exchange_result?: undefined;
464
1604
  error?: undefined;
465
1605
  } | {
466
1606
  success: boolean;
@@ -477,6 +1617,12 @@ declare class ExchangeAccount$1 {
477
1617
  symbol: string;
478
1618
  orders: number[];
479
1619
  }): Promise<any>;
1620
+ getBreakEvenPrice(payload: {
1621
+ symbol: string;
1622
+ }): Promise<{
1623
+ price: number;
1624
+ direction: string;
1625
+ }>;
480
1626
  buildAppConfig(payload: {
481
1627
  entry: number;
482
1628
  stop: number;
@@ -487,6 +1633,36 @@ declare class ExchangeAccount$1 {
487
1633
  update_db?: boolean;
488
1634
  profit_percent?: number;
489
1635
  }): Promise<AppConfig>;
1636
+ tradeConfig(payload: {
1637
+ symbol: string;
1638
+ kind: "long" | "short";
1639
+ }): Promise<AppConfig>;
1640
+ justInTimeProfit(payload: {
1641
+ symbol: string;
1642
+ target_pnl: number;
1643
+ kind: "long" | "short";
1644
+ refresh?: boolean;
1645
+ place?: boolean;
1646
+ take_profit?: number;
1647
+ pause_tp?: boolean;
1648
+ }): Promise<{
1649
+ sell_ratio: number;
1650
+ current_pnl: number;
1651
+ profit_percent: number;
1652
+ current_price: number;
1653
+ notional_value: number;
1654
+ }>;
1655
+ buildTrades(payload: {
1656
+ symbol: string;
1657
+ kind: "long" | "short";
1658
+ risk?: number;
1659
+ }): Promise<{
1660
+ trades: any[];
1661
+ max_size: any;
1662
+ last_price: any;
1663
+ total_size: number;
1664
+ avg_entry: number;
1665
+ }>;
490
1666
  placeConfigOrders(app_config: AppConfig, solution: {
491
1667
  risk_reward: number;
492
1668
  entry: number;
@@ -514,9 +1690,20 @@ declare class ExchangeAccount$1 {
514
1690
  kind: "long" | "short";
515
1691
  quantity: any;
516
1692
  is_limit: boolean;
1693
+ neg_pnl: any;
517
1694
  };
518
1695
  trades: any[];
519
1696
  }>;
1697
+ determineAmountToBuy(payload: {
1698
+ orders: any[];
1699
+ kind: "long" | "short";
1700
+ refresh?: boolean;
1701
+ decimal_places?: string;
1702
+ price_places?: string;
1703
+ symbol: string;
1704
+ cancel?: boolean;
1705
+ place?: boolean;
1706
+ }): Promise<any[]>;
520
1707
  placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
521
1708
  symbol: string;
522
1709
  entry: number;
@@ -525,86 +1712,526 @@ declare class ExchangeAccount$1 {
525
1712
  risk: number;
526
1713
  place?: boolean;
527
1714
  update_db?: boolean;
1715
+ raw?: boolean;
1716
+ use_current?: boolean;
528
1717
  }): Promise<any>;
1718
+ getOrCreatePositionConfig(payload: {
1719
+ symbol: string;
1720
+ kind: "long" | "short";
1721
+ risk?: number;
1722
+ risk_reward?: number;
1723
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
529
1724
  getPositionConfig(payload: {
530
1725
  symbol: string;
531
1726
  kind: "long" | "short";
532
1727
  params?: {
533
- entry: number;
534
- stop: number;
535
- risk_reward: number;
536
- risk: number;
1728
+ entry?: number;
1729
+ stop?: number;
1730
+ risk_reward?: number;
1731
+ risk?: number;
537
1732
  profit_percent?: number;
1733
+ place_tp?: boolean;
1734
+ profit?: number;
1735
+ };
1736
+ }): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
1737
+ getCurrentPrice(symbol: string): Promise<any>;
1738
+ getAccountStrategy(payload: {
1739
+ symbol: string;
1740
+ }): Promise<AccountStrategy>;
1741
+ buildReduceConfig(payload: {
1742
+ symbol: string;
1743
+ kind?: "long" | "short";
1744
+ as_dict?: boolean;
1745
+ target_pnl?: number;
1746
+ trigger?: {
1747
+ long: boolean;
1748
+ short: boolean;
1749
+ };
1750
+ use_full?: boolean;
1751
+ }): Promise<{
1752
+ trigger_short: boolean;
1753
+ trigger_long: boolean;
1754
+ symbol: string;
1755
+ short_minimum_pnl: number;
1756
+ long_minimum_pnl: number;
1757
+ short_profit: any;
1758
+ long_profit: any;
1759
+ owner: string;
1760
+ exchange: string;
1761
+ not_reduce: boolean;
1762
+ reduce_ratio_long: any;
1763
+ reduce_ratio_short: any;
1764
+ use_full_long: any;
1765
+ use_full_short: any;
1766
+ } | {
1767
+ long: {
1768
+ minimum_pnl: number;
1769
+ max_size: number;
1770
+ profit: any;
1771
+ increase: boolean;
1772
+ not_reduce: boolean;
1773
+ ratio: any;
1774
+ use_full: boolean;
1775
+ sell_ratio: any;
1776
+ };
1777
+ short: {
1778
+ minimum_pnl: number;
1779
+ max_size: number;
1780
+ profit: any;
1781
+ increase: boolean;
1782
+ not_reduce: boolean;
1783
+ ratio: any;
1784
+ use_full: boolean;
1785
+ sell_ratio: any;
1786
+ };
1787
+ trigger: {
1788
+ long: boolean;
1789
+ short: boolean;
538
1790
  };
539
- }): Promise<ScheduledTrade>;
540
- getCurrentPrice(symbol: string): Promise<any>;
541
- getPositionStrategy(): Promise<{
542
- strategy_instance: Strategy;
543
- focus_account: ExchangeAccount;
544
1791
  }>;
545
1792
  getOriginalPlannedStop(payload: {
546
1793
  symbol: string;
547
1794
  kind: "long" | "short";
548
1795
  }): Promise<any>;
549
- syncReduceClosePosition(symbol: string, payload?: {
1796
+ syncReduceClosePosition(payload?: {
1797
+ symbol: string;
550
1798
  kind?: "long" | "short";
551
- long?: CodeNode;
552
- short?: CodeNode;
553
- trigger?: {
1799
+ trigger?: boolean;
1800
+ }): Promise<any>;
1801
+ reduceMajorPositionEntry(payload: {
1802
+ symbol: string;
1803
+ long: any;
1804
+ short: any;
1805
+ trigger: {
554
1806
  long: boolean;
555
1807
  short: boolean;
556
1808
  };
557
1809
  }): Promise<any>;
1810
+ placeProfitAndStop(payload: {
1811
+ symbol: string;
1812
+ trigger?: boolean;
1813
+ refresh?: boolean;
1814
+ kind?: "long" | "short";
1815
+ target_pnl?: number;
1816
+ }): Promise<any>;
1817
+ reEnterPositionOnEmpty(symbol: string): Promise<void>;
558
1818
  generate_config_params(payload: {
559
1819
  entry: number;
560
1820
  stop: number;
561
1821
  risk_reward: number;
562
1822
  risk: number;
563
1823
  symbol: string;
564
- }): Promise<{
565
- place_stop: boolean;
566
- profit_percent: number;
567
- entry: number;
568
- stop: number;
569
- avg_size: any;
570
- avg_entry: any;
571
- risk_reward: number;
572
- neg_pnl: any;
573
- risk: number;
574
- }>;
1824
+ with_trades?: boolean;
1825
+ }): Promise<any>;
1826
+ build_short_order(payload: {
1827
+ symbol: string;
1828
+ kind: "long" | "short";
1829
+ }): Promise<any>;
575
1830
  extrapolateShortConfig(payload: {
576
1831
  kind: "long" | "short";
577
1832
  symbol: string;
578
1833
  risk_reward?: number;
1834
+ risk?: number;
1835
+ }): Promise<any>;
1836
+ placeMarketOrder(payload: {
1837
+ symbol: string;
1838
+ kind: "long" | "short";
1839
+ quantity: number;
1840
+ }): Promise<void>;
1841
+ placeSingleOrder(payload: {
1842
+ symbol: string;
1843
+ kind: "long" | "short";
1844
+ }): Promise<string>;
1845
+ triggerTradeFromConfig(payload: {
1846
+ symbol: string;
1847
+ kind: "long" | "short";
1848
+ place?: boolean;
1849
+ raw?: boolean;
1850
+ tp?: boolean;
1851
+ stop?: boolean;
1852
+ use_current?: boolean;
1853
+ ignore_config?: boolean;
1854
+ }): Promise<any>;
1855
+ verifyStopLoss(payload: {
1856
+ symbol: string;
1857
+ kind: "long" | "short";
1858
+ revert?: boolean;
1859
+ }): Promise<void | Order[]>;
1860
+ windDownSymbol(payload: {
1861
+ symbol: string;
1862
+ risk_reward?: number;
1863
+ risk?: number;
1864
+ }): Promise<void>;
1865
+ updateTargetPnl(payload: {
1866
+ symbol: string;
1867
+ kind: "long" | "short";
1868
+ }): Promise<number>;
1869
+ placeOppositeTradeAction(payload: {
1870
+ symbol: string;
1871
+ kind: "long" | "short";
1872
+ data: {
1873
+ avg: {
1874
+ quantity: number;
1875
+ price: number;
1876
+ };
1877
+ entry: number;
1878
+ stop: number;
1879
+ risk_per_trade: number;
1880
+ profit_percent: number;
1881
+ risk_reward: number;
1882
+ };
1883
+ }): Promise<void>;
1884
+ buildOppositeTrades(payload: {
1885
+ symbol: string;
1886
+ kind: "long" | "short";
1887
+ place?: boolean;
1888
+ place_symbol?: string;
579
1889
  }): Promise<{
580
- place_stop: boolean;
1890
+ avg: {
1891
+ entry: number;
1892
+ price: number;
1893
+ quantity: number;
1894
+ };
1895
+ loss: number;
581
1896
  profit_percent: number;
1897
+ fee: number;
1898
+ risk_per_trade: number;
1899
+ risk_reward: number;
1900
+ symbol?: string;
1901
+ focus: number;
1902
+ budget: number;
1903
+ support: number;
1904
+ resistance: number;
1905
+ percent_change: number;
1906
+ tradeSplit?: number;
1907
+ take_profit?: number;
1908
+ kind: "long" | "short";
582
1909
  entry: number;
583
1910
  stop: number;
584
- avg_size: any;
585
- avg_entry: any;
1911
+ min_size: number;
1912
+ price_places?: string;
1913
+ strategy?: "quantity" | "entry";
1914
+ as_array?: boolean;
1915
+ decimal_places?: string;
1916
+ min_profit?: number;
1917
+ raw?: boolean;
1918
+ gap?: number;
1919
+ rr?: number;
1920
+ max_size?: number;
1921
+ }>;
1922
+ runSimulation(payload: {
1923
+ symbol: string;
1924
+ kind: "long" | "short";
1925
+ iterations?: number;
1926
+ raw?: boolean;
1927
+ }): Promise<Strategy | {
1928
+ last_entry: any;
1929
+ first_entry: any;
1930
+ threshold: any;
1931
+ risk: number;
586
1932
  risk_reward: number;
587
- neg_pnl: any;
1933
+ spread: number;
1934
+ gap_loss: number;
1935
+ net_profit: number;
1936
+ long: {
1937
+ avg_entry: number;
1938
+ avg_size: number;
1939
+ loss: number;
1940
+ stop: number;
1941
+ stop_quantity: number;
1942
+ re_entry_quantity: number;
1943
+ initial_pnl: number;
1944
+ tp: number;
1945
+ incurred_loss: number;
1946
+ pnl: number;
1947
+ remaining_quantity: number;
1948
+ };
1949
+ short: {
1950
+ avg_entry: number;
1951
+ avg_size: number;
1952
+ loss: number;
1953
+ stop: number;
1954
+ stop_quantity: number;
1955
+ re_entry_quantity: number;
1956
+ initial_pnl: number;
1957
+ tp: number;
1958
+ incurred_loss: number;
1959
+ pnl: number;
1960
+ remaining_quantity: number;
1961
+ };
1962
+ }[]>;
1963
+ getCurrentRun(payload: {
1964
+ symbol: string;
1965
+ kind?: "long" | "short";
1966
+ pnl?: number;
1967
+ }): Promise<true | import("pocketbase").RecordModel>;
1968
+ recomputeSymbolConfig(payload: {
1969
+ symbol: string;
1970
+ refresh?: boolean;
1971
+ }): Promise<SymbolConfig>;
1972
+ /**
1973
+ * This function builds a config for a symbol
1974
+ * @param payload
1975
+ * @returns
1976
+ */
1977
+ buildConfigForSymbol(payload: {
1978
+ symbol: string;
588
1979
  risk: number;
1980
+ kind?: "long" | "short";
1981
+ risk_reward?: number;
1982
+ as_config?: boolean;
1983
+ with_trades?: boolean;
1984
+ }): Promise<any>;
1985
+ triggerBullishMarket(payload: {
1986
+ symbol: string;
1987
+ profit_percent?: number;
1988
+ risk_reward?: number;
1989
+ }): Promise<any>;
1990
+ updateAllActiveSymbols(payload: {
1991
+ interval?: number;
1992
+ }): Promise<void>;
1993
+ updateAllPositionsWithNoConfig(payload: {
1994
+ kind: "long" | "short";
1995
+ }): Promise<void>;
1996
+ getSymbolsForPositions(): Promise<any[]>;
1997
+ getNonEssentialSymbols(): Promise<any[]>;
1998
+ _terminatePositions(payload: {
1999
+ symbol: string;
2000
+ }): Promise<void>;
2001
+ getOrders(payload: {
2002
+ symbol: string;
2003
+ kind: "long" | "short";
2004
+ type: "limit" | "stop" | "tp";
2005
+ }): Promise<Order[]>;
2006
+ syncPositionConfigs(payload: {
2007
+ symbol: string;
2008
+ kind: "long" | "short";
2009
+ refresh?: boolean;
2010
+ }): Promise<void>;
2011
+ terminatePositions(payload: {
2012
+ symbol: string;
2013
+ }): Promise<void>;
2014
+ fetchAndUpdateTopMovers(): Promise<{
2015
+ updated_bullish: BullishMarket[];
2016
+ moved_to_winding: WindingDownMarket[];
589
2017
  }>;
590
- triggerTradeFromConfig(payload: {
2018
+ computeTargetPnl(payload: {
2019
+ symbol: string;
2020
+ kind: "long" | "short";
2021
+ }): Promise<number>;
2022
+ placeStopLimit(payload: {
591
2023
  symbol: string;
592
2024
  kind: "long" | "short";
2025
+ place?: boolean;
2026
+ stop: number;
2027
+ quantity?: number;
593
2028
  }): Promise<any>;
594
- verifyStopLoss(payload: {
2029
+ placeTrade(payload: {
595
2030
  symbol: string;
596
2031
  kind: "long" | "short";
597
- revert?: boolean;
598
- }): Promise<import("pocketbase").RecordModel[]>;
599
- windDownSymbol(symbol: string, risk_reward?: number): Promise<void>;
2032
+ place?: boolean;
2033
+ limit?: boolean;
2034
+ tp?: boolean;
2035
+ stop?: boolean;
2036
+ raw?: boolean;
2037
+ cancel?: boolean;
2038
+ ignore_config?: boolean;
2039
+ target_pnl?: number;
2040
+ }): Promise<any>;
2041
+ updateConfigPnl(payload: {
2042
+ symbol: string;
2043
+ kind: "long" | "short";
2044
+ }): Promise<void>;
2045
+ determineReduceTp(payload: {
2046
+ symbol: string;
2047
+ factor: number;
2048
+ }): Promise<{
2049
+ long_diff: number;
2050
+ short_diff: number;
2051
+ gap: number;
2052
+ gap_cost: number;
2053
+ long_tp: number;
2054
+ short_tp: number;
2055
+ long_percent: number;
2056
+ short_percent: number;
2057
+ }>;
2058
+ profitWithinGapStrategy(payload: {
2059
+ symbol: string;
2060
+ }): Promise<{
2061
+ reverse_config: any;
2062
+ reverse_action: {
2063
+ avg: {
2064
+ entry: number;
2065
+ price: number;
2066
+ quantity: number;
2067
+ };
2068
+ loss: number;
2069
+ profit_percent: number;
2070
+ fee: number;
2071
+ risk_per_trade: number;
2072
+ risk_reward: number;
2073
+ symbol?: string;
2074
+ focus: number;
2075
+ budget: number;
2076
+ support: number;
2077
+ resistance: number;
2078
+ percent_change: number;
2079
+ tradeSplit?: number;
2080
+ take_profit?: number;
2081
+ kind: "long" | "short";
2082
+ entry: number;
2083
+ stop: number;
2084
+ min_size: number;
2085
+ price_places?: string;
2086
+ strategy?: "quantity" | "entry";
2087
+ as_array?: boolean;
2088
+ decimal_places?: string;
2089
+ min_profit?: number;
2090
+ raw?: boolean;
2091
+ gap?: number;
2092
+ rr?: number;
2093
+ max_size?: number;
2094
+ };
2095
+ reverse_orders_to_buy: any;
2096
+ positions: {
2097
+ long: PositionsView & {
2098
+ expand?: {
2099
+ account_strategy?: AccountStrategy;
2100
+ };
2101
+ };
2102
+ short: PositionsView & {
2103
+ expand?: {
2104
+ account_strategy?: AccountStrategy;
2105
+ };
2106
+ };
2107
+ };
2108
+ orders_to_place: any;
2109
+ config_details: {
2110
+ app_config: {
2111
+ fee: number;
2112
+ risk_per_trade: number;
2113
+ risk_reward: number;
2114
+ symbol?: string;
2115
+ focus: number;
2116
+ budget: number;
2117
+ support: number;
2118
+ resistance: number;
2119
+ percent_change: number;
2120
+ tradeSplit?: number;
2121
+ take_profit?: number;
2122
+ kind: "long" | "short";
2123
+ entry: number;
2124
+ stop: number;
2125
+ min_size: number;
2126
+ price_places?: string;
2127
+ strategy?: "quantity" | "entry";
2128
+ as_array?: boolean;
2129
+ decimal_places?: string;
2130
+ min_profit?: number;
2131
+ raw?: boolean;
2132
+ gap?: number;
2133
+ rr?: number;
2134
+ max_size?: number;
2135
+ };
2136
+ last_value: any;
2137
+ config: {
2138
+ entry: number;
2139
+ stop: number;
2140
+ risk: number;
2141
+ risk_reward: number | {
2142
+ result: any[];
2143
+ value: number;
2144
+ total: number;
2145
+ risk_per_trade: number;
2146
+ max: number;
2147
+ min: number;
2148
+ neg_pnl: any;
2149
+ entry: any;
2150
+ };
2151
+ profit_percent: number;
2152
+ };
2153
+ pnl: number;
2154
+ };
2155
+ }>;
2156
+ generateGapTp(payload: {
2157
+ symbol: string;
2158
+ factor?: number;
2159
+ }): Promise<{
2160
+ profit_percent: {
2161
+ long: number;
2162
+ short: number;
2163
+ };
2164
+ risk: {
2165
+ short: number;
2166
+ long: number;
2167
+ };
2168
+ take_profit: {
2169
+ long: number;
2170
+ short: number;
2171
+ };
2172
+ to_reduce: {
2173
+ short: number;
2174
+ long: number;
2175
+ };
2176
+ full_reduce: {
2177
+ short: number;
2178
+ long: number;
2179
+ };
2180
+ sell_quantity: {
2181
+ short: number;
2182
+ long: number;
2183
+ };
2184
+ gap: number;
2185
+ gap_loss: number;
2186
+ }>;
2187
+ getSellPriceFromStrategy(payload: {
2188
+ symbol: string;
2189
+ reduce_position: PositionsView;
2190
+ kind?: "long" | "short";
2191
+ }): Promise<{
2192
+ pnl: number;
2193
+ loss: number;
2194
+ original_pnl: number;
2195
+ reward_factor: number;
2196
+ profit_percent: number;
2197
+ kind: "long" | "short";
2198
+ sell_price: number;
2199
+ quantity: number;
2200
+ price_places: string;
2201
+ decimal_places: string;
2202
+ }>;
600
2203
  }
2204
+ declare function getExchangeAccount(payload: {
2205
+ account: ExchangeType;
2206
+ app_db: AppDatabase;
2207
+ getCredentials: (account: string, exchange: string) => {
2208
+ api_key: string;
2209
+ api_secret: string;
2210
+ email: string;
2211
+ };
2212
+ proxyOptions?: {
2213
+ proxy?: any;
2214
+ ignore_proxy?: boolean;
2215
+ };
2216
+ canWithdraw?: boolean;
2217
+ }): Promise<ExchangeAccount$1>;
601
2218
  declare class App {
602
- private app_db;
2219
+ app_db: AppDatabase;
2220
+ proxyOptions?: {
2221
+ proxy?: any;
2222
+ ignore_proxy?: boolean;
2223
+ canWithdraw?: boolean;
2224
+ };
603
2225
  private getCredentials;
604
- constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
2226
+ constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => {
605
2227
  api_key: string;
606
2228
  api_secret: string;
607
- }>);
2229
+ email: string;
2230
+ }, proxyOptions?: {
2231
+ proxy?: any;
2232
+ ignore_proxy?: boolean;
2233
+ canWithdraw?: boolean;
2234
+ });
608
2235
  getExchangeAccount(account: ExchangeType): Promise<ExchangeAccount$1>;
609
2236
  syncAccount(payload: {
610
2237
  account: ExchangeType;
@@ -612,13 +2239,10 @@ declare class App {
612
2239
  kind?: "long" | "short";
613
2240
  update?: boolean;
614
2241
  as_view?: boolean;
615
- }): Promise<(PositionsView & {
616
- expand?: {
617
- config: ScheduledTrade;
618
- };
619
- }) | (PositionsView & {
2242
+ }): Promise<PositionsView | (PositionsView & {
620
2243
  expand?: {
621
2244
  config: ScheduledTrade;
2245
+ account: ExchangeAccount;
622
2246
  };
623
2247
  })[]>;
624
2248
  syncOrders(payload: {
@@ -633,7 +2257,7 @@ declare class App {
633
2257
  price?: number;
634
2258
  all?: boolean;
635
2259
  stop?: boolean;
636
- }): Promise<{
2260
+ }): Promise<void | {
637
2261
  success: boolean;
638
2262
  message: string;
639
2263
  exchange_result?: undefined;
@@ -649,39 +2273,6 @@ declare class App {
649
2273
  message?: undefined;
650
2274
  exchange_result?: undefined;
651
2275
  }>;
652
- generateConfig(payload: {
653
- account: ExchangeType;
654
- symbol: string;
655
- kind: "long" | "short";
656
- update_orders?: boolean;
657
- place_orders?: boolean;
658
- }): Promise<any>;
659
- updateReduceRatio(payload: {
660
- account: ExchangeType;
661
- symbol: string;
662
- }): Promise<{
663
- long_position: any;
664
- short_position: any;
665
- long_db_position: any;
666
- short_db_position: any;
667
- balance: any;
668
- }>;
669
- verifyStopLoss(payload: {
670
- account: ExchangeType;
671
- symbol: string;
672
- kind: "long" | "short";
673
- revert?: boolean;
674
- }): Promise<import("pocketbase").RecordModel[]>;
675
- updateTopMovers(payload?: {
676
- new_markets: {
677
- symbol: string;
678
- percent: number;
679
- }[];
680
- totalRisk: number;
681
- }): Promise<{
682
- updated_bullish: BullishMarket[];
683
- moved_to_winding: WindingDownMarket[];
684
- }>;
685
2276
  getWindingDownMarkets(): Promise<WindingDownMarket[]>;
686
2277
  updateSymbolConfigs(payload: {
687
2278
  configs: {
@@ -698,7 +2289,151 @@ declare class App {
698
2289
  created: number;
699
2290
  }>;
700
2291
  updateAllAccountWithSymbols(with_positions?: boolean): Promise<void>;
701
- windDownSymbol(symbol: string): Promise<boolean>;
2292
+ windDownSymbol(payload: {
2293
+ symbol: string;
2294
+ risk?: number;
2295
+ }): Promise<boolean>;
2296
+ getNonEssentialSymbols(): Promise<Set<any>>;
2297
+ refreshAllPositionsWithSymbol(payload: {
2298
+ symbol: string;
2299
+ }): Promise<void>;
2300
+ autoFollowPositions(): Promise<void>;
2301
+ getMoverExchangeInstances(): Promise<ExchangeAccount[]>;
2302
+ updateTpOnAllMarkets(): Promise<void>;
2303
+ triggerMoverTask(payload: {
2304
+ callback: (params: {
2305
+ symbol: string;
2306
+ account: ExchangeType;
2307
+ }) => Promise<any>;
2308
+ removeCallback?: (params: {
2309
+ symbol: string;
2310
+ account: ExchangeType;
2311
+ }) => Promise<any>;
2312
+ }): Promise<void>;
2313
+ placeTrade(payload: {
2314
+ account: ExchangeType;
2315
+ symbol: string;
2316
+ kind: "long" | "short";
2317
+ place?: boolean;
2318
+ tp?: boolean;
2319
+ cancel?: boolean;
2320
+ raw?: boolean;
2321
+ }): Promise<any>;
2322
+ runDbStrategyAccounts(callback: (params: {
2323
+ symbol: string;
2324
+ account: ExchangeType;
2325
+ }) => Promise<any>): Promise<void>;
2326
+ profitWithinGapStrategy(payload: {
2327
+ account: ExchangeType;
2328
+ symbol: string;
2329
+ }): Promise<{
2330
+ reverse_config: any;
2331
+ reverse_action: {
2332
+ avg: {
2333
+ entry: number;
2334
+ price: number;
2335
+ quantity: number;
2336
+ };
2337
+ loss: number;
2338
+ profit_percent: number;
2339
+ fee: number;
2340
+ risk_per_trade: number;
2341
+ risk_reward: number;
2342
+ symbol?: string;
2343
+ focus: number;
2344
+ budget: number;
2345
+ support: number;
2346
+ resistance: number;
2347
+ percent_change: number;
2348
+ tradeSplit?: number;
2349
+ take_profit?: number;
2350
+ kind: "long" | "short";
2351
+ entry: number;
2352
+ stop: number;
2353
+ min_size: number;
2354
+ price_places?: string;
2355
+ strategy?: "quantity" | "entry";
2356
+ as_array?: boolean;
2357
+ decimal_places?: string;
2358
+ min_profit?: number;
2359
+ raw?: boolean;
2360
+ gap?: number;
2361
+ rr?: number;
2362
+ max_size?: number;
2363
+ };
2364
+ reverse_orders_to_buy: any;
2365
+ positions: {
2366
+ long: PositionsView & {
2367
+ expand?: {
2368
+ account_strategy?: AccountStrategy;
2369
+ };
2370
+ };
2371
+ short: PositionsView & {
2372
+ expand?: {
2373
+ account_strategy?: AccountStrategy;
2374
+ };
2375
+ };
2376
+ };
2377
+ orders_to_place: any;
2378
+ config_details: {
2379
+ app_config: {
2380
+ fee: number;
2381
+ risk_per_trade: number;
2382
+ risk_reward: number;
2383
+ symbol?: string;
2384
+ focus: number;
2385
+ budget: number;
2386
+ support: number;
2387
+ resistance: number;
2388
+ percent_change: number;
2389
+ tradeSplit?: number;
2390
+ take_profit?: number;
2391
+ kind: "long" | "short";
2392
+ entry: number;
2393
+ stop: number;
2394
+ min_size: number;
2395
+ price_places?: string;
2396
+ strategy?: "quantity" | "entry";
2397
+ as_array?: boolean;
2398
+ decimal_places?: string;
2399
+ min_profit?: number;
2400
+ raw?: boolean;
2401
+ gap?: number;
2402
+ rr?: number;
2403
+ max_size?: number;
2404
+ };
2405
+ last_value: any;
2406
+ config: {
2407
+ entry: number;
2408
+ stop: number;
2409
+ risk: number;
2410
+ risk_reward: number | {
2411
+ result: any[];
2412
+ value: number;
2413
+ total: number;
2414
+ risk_per_trade: number;
2415
+ max: number;
2416
+ min: number;
2417
+ neg_pnl: any;
2418
+ entry: any;
2419
+ };
2420
+ profit_percent: number;
2421
+ };
2422
+ pnl: number;
2423
+ };
2424
+ }>;
2425
+ reduceExistingPosition(payload: {
2426
+ main_account: ExchangeType & {
2427
+ symbol: string;
2428
+ kind?: "long" | "short";
2429
+ };
2430
+ reduce_account: ExchangeType & {
2431
+ symbol: string;
2432
+ };
2433
+ kind: "long" | "short";
2434
+ place?: boolean;
2435
+ increase?: boolean;
2436
+ }): Promise<any>;
702
2437
  }
703
2438
  export declare function initApp(payload: {
704
2439
  db: {
@@ -706,14 +2441,46 @@ export declare function initApp(payload: {
706
2441
  email: string;
707
2442
  password: string;
708
2443
  };
709
- getCredentials: (account: string, exchange: string) => (account: string, exchange: string) => Promise<{
2444
+ password?: string;
2445
+ salt?: string;
2446
+ email?: string;
2447
+ getCredentials: (account: string, exchange: string) => {
710
2448
  api_key: string;
711
2449
  api_secret: string;
712
- }>;
2450
+ email: string;
2451
+ };
2452
+ proxy?: any;
2453
+ ignore_proxy?: boolean;
2454
+ canWithdraw?: boolean;
2455
+ triggerToken?: string;
2456
+ }): Promise<App>;
2457
+ declare function getCredentials(account: string, exchange: string): {
2458
+ api_key: string;
2459
+ api_secret: string;
2460
+ email: string;
2461
+ };
2462
+ export declare function initialize(payload: {
2463
+ password?: string;
2464
+ proxy?: any;
2465
+ ignore_proxy?: boolean;
2466
+ canWithdraw?: boolean;
713
2467
  }): Promise<App>;
714
2468
 
2469
+ declare namespace database {
2470
+ export { AppDatabase, ExchangeType, initPocketBaseClient };
2471
+ }
2472
+ declare namespace exchange_account {
2473
+ export { ExchangeAccount$1 as ExchangeAccount, getExchangeAccount };
2474
+ }
2475
+ declare namespace app {
2476
+ export { App, getCredentials, initApp, initialize };
2477
+ }
2478
+
715
2479
  export {
716
2480
  ExchangeAccount$1 as ExchangeAccount,
2481
+ app,
2482
+ database,
2483
+ exchange_account,
717
2484
  };
718
2485
 
719
2486
  export {};