@gbozee/ultimate 0.0.2-40 → 0.0.2-45
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/frontend-index.d.ts +9 -0
- package/dist/frontend-index.js +33 -0
- package/dist/index.d.ts +173 -4
- package/dist/index.js +32604 -13079
- package/package.json +1 -1
package/dist/frontend-index.d.ts
CHANGED
|
@@ -277,5 +277,14 @@ export declare function determine_break_even_price(payload: {
|
|
|
277
277
|
price: number;
|
|
278
278
|
direction: string;
|
|
279
279
|
};
|
|
280
|
+
export declare function determine_amount_to_buy(payload: {
|
|
281
|
+
orders: any[];
|
|
282
|
+
kind: "long" | "short";
|
|
283
|
+
decimal_places?: string;
|
|
284
|
+
price_places?: string;
|
|
285
|
+
place?: boolean;
|
|
286
|
+
position: any;
|
|
287
|
+
existingOrders: any[];
|
|
288
|
+
}): any[];
|
|
280
289
|
|
|
281
290
|
export {};
|
package/dist/frontend-index.js
CHANGED
|
@@ -1317,6 +1317,38 @@ function determine_break_even_price(payload) {
|
|
|
1317
1317
|
direction: net_quantity > 0 ? "long" : "short"
|
|
1318
1318
|
};
|
|
1319
1319
|
}
|
|
1320
|
+
function determine_amount_to_buy(payload) {
|
|
1321
|
+
const {
|
|
1322
|
+
orders,
|
|
1323
|
+
kind,
|
|
1324
|
+
decimal_places = "%.3f",
|
|
1325
|
+
position: position2,
|
|
1326
|
+
existingOrders
|
|
1327
|
+
} = payload;
|
|
1328
|
+
const totalQuantity = orders.reduce((sum, order) => sum + (order.quantity || 0), 0);
|
|
1329
|
+
let runningTotal = to_f2(totalQuantity, decimal_places);
|
|
1330
|
+
let sortedOrders = [...orders].sort((a, b) => (a.entry || 0) - (b.entry || 0));
|
|
1331
|
+
if (kind === "short") {
|
|
1332
|
+
sortedOrders.reverse();
|
|
1333
|
+
}
|
|
1334
|
+
const withCumulative = [];
|
|
1335
|
+
for (const order of sortedOrders) {
|
|
1336
|
+
withCumulative.push({
|
|
1337
|
+
...order,
|
|
1338
|
+
cumulative_quantity: runningTotal
|
|
1339
|
+
});
|
|
1340
|
+
runningTotal -= order.quantity;
|
|
1341
|
+
runningTotal = to_f2(runningTotal, decimal_places);
|
|
1342
|
+
}
|
|
1343
|
+
let filteredOrders = withCumulative.filter((order) => (order.cumulative_quantity || 0) > position2?.quantity).map((order) => ({
|
|
1344
|
+
...order,
|
|
1345
|
+
price: order.entry,
|
|
1346
|
+
kind,
|
|
1347
|
+
side: kind.toLowerCase() === "long" ? "buy" : "sell"
|
|
1348
|
+
}));
|
|
1349
|
+
filteredOrders = filteredOrders.filter((k) => !existingOrders.map((j) => j.price).includes(k.price));
|
|
1350
|
+
return filteredOrders;
|
|
1351
|
+
}
|
|
1320
1352
|
export {
|
|
1321
1353
|
sortedBuildConfig,
|
|
1322
1354
|
get_app_config_and_max_size,
|
|
@@ -1324,6 +1356,7 @@ export {
|
|
|
1324
1356
|
generate_config_params,
|
|
1325
1357
|
determine_break_even_price,
|
|
1326
1358
|
determine_average_entry_and_size,
|
|
1359
|
+
determine_amount_to_buy,
|
|
1327
1360
|
createArray,
|
|
1328
1361
|
buildConfig,
|
|
1329
1362
|
buildAvg,
|
package/dist/index.d.ts
CHANGED
|
@@ -377,6 +377,22 @@ export declare class AppDatabase {
|
|
|
377
377
|
order_id: string;
|
|
378
378
|
triggerPrice?: number;
|
|
379
379
|
}>): Promise<import("pocketbase").RecordModel[]>;
|
|
380
|
+
deleteAndBulCreateAllOrders(payload: {
|
|
381
|
+
account: ExchangeType & {
|
|
382
|
+
id: string;
|
|
383
|
+
};
|
|
384
|
+
symbol: string;
|
|
385
|
+
all_orders: Array<{
|
|
386
|
+
symbol: string;
|
|
387
|
+
price: number;
|
|
388
|
+
quantity: number;
|
|
389
|
+
kind: "long" | "short";
|
|
390
|
+
side: "buy" | "sell";
|
|
391
|
+
stop: number;
|
|
392
|
+
order_id: string;
|
|
393
|
+
triggerPrice?: number;
|
|
394
|
+
}>;
|
|
395
|
+
}): Promise<void>;
|
|
380
396
|
cancelLimitOrders(payload: {
|
|
381
397
|
symbol: string;
|
|
382
398
|
kind: "long" | "short";
|
|
@@ -730,11 +746,149 @@ export declare function determine_break_even_price(payload: {
|
|
|
730
746
|
price: number;
|
|
731
747
|
direction: string;
|
|
732
748
|
};
|
|
749
|
+
export declare function determine_amount_to_buy(payload: {
|
|
750
|
+
orders: any[];
|
|
751
|
+
kind: "long" | "short";
|
|
752
|
+
decimal_places?: string;
|
|
753
|
+
price_places?: string;
|
|
754
|
+
place?: boolean;
|
|
755
|
+
position: any;
|
|
756
|
+
existingOrders: any[];
|
|
757
|
+
}): any[];
|
|
758
|
+
declare class ExchangePosition {
|
|
759
|
+
exchange: BaseExchange;
|
|
760
|
+
exchange_account: ExchangeAccount$1;
|
|
761
|
+
private app_db;
|
|
762
|
+
private instance;
|
|
763
|
+
constructor(payload: {
|
|
764
|
+
exchange: BaseExchange;
|
|
765
|
+
app_db: AppDatabase;
|
|
766
|
+
instance: PositionsView;
|
|
767
|
+
exchange_account: ExchangeAccount$1;
|
|
768
|
+
without_view?: PositionsView;
|
|
769
|
+
});
|
|
770
|
+
get symbol(): any;
|
|
771
|
+
get kind(): any;
|
|
772
|
+
get account(): any;
|
|
773
|
+
cancelOrders(payload: {
|
|
774
|
+
limit?: boolean;
|
|
775
|
+
price?: number;
|
|
776
|
+
}): Promise<void | {
|
|
777
|
+
success: boolean;
|
|
778
|
+
message: string;
|
|
779
|
+
exchange_result?: undefined;
|
|
780
|
+
error?: undefined;
|
|
781
|
+
} | {
|
|
782
|
+
success: boolean;
|
|
783
|
+
exchange_result: any;
|
|
784
|
+
message?: undefined;
|
|
785
|
+
error?: undefined;
|
|
786
|
+
} | {
|
|
787
|
+
success: boolean;
|
|
788
|
+
error: any;
|
|
789
|
+
message?: undefined;
|
|
790
|
+
exchange_result?: undefined;
|
|
791
|
+
}>;
|
|
792
|
+
getConfig(payload?: {
|
|
793
|
+
params?: {
|
|
794
|
+
entry?: number;
|
|
795
|
+
stop?: number;
|
|
796
|
+
risk_reward?: number;
|
|
797
|
+
risk?: number;
|
|
798
|
+
profit_percent?: number;
|
|
799
|
+
place_tp?: boolean;
|
|
800
|
+
profit?: number;
|
|
801
|
+
};
|
|
802
|
+
}): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
|
|
803
|
+
updateTargetPnl(): Promise<number>;
|
|
804
|
+
updateConfigPnl(): Promise<void>;
|
|
805
|
+
triggerTradeFromConfig(payload: {
|
|
806
|
+
place?: boolean;
|
|
807
|
+
raw?: boolean;
|
|
808
|
+
tp?: boolean;
|
|
809
|
+
stop?: boolean;
|
|
810
|
+
use_current?: boolean;
|
|
811
|
+
ignore_config?: boolean;
|
|
812
|
+
}): Promise<any>;
|
|
813
|
+
placeSharedOrder(action: "place_limit_orders" | "place_stop_orders" | "place_tp_orders", payload: {
|
|
814
|
+
entry: number;
|
|
815
|
+
stop: number;
|
|
816
|
+
risk_reward: number;
|
|
817
|
+
risk: number;
|
|
818
|
+
place?: boolean;
|
|
819
|
+
update_db?: boolean;
|
|
820
|
+
raw?: boolean;
|
|
821
|
+
use_current?: boolean;
|
|
822
|
+
}): Promise<any>;
|
|
823
|
+
buildAppConfig(payload: {
|
|
824
|
+
entry: number;
|
|
825
|
+
stop: number;
|
|
826
|
+
risk_reward: number;
|
|
827
|
+
risk: number;
|
|
828
|
+
profit?: number;
|
|
829
|
+
update_db?: boolean;
|
|
830
|
+
profit_percent?: number;
|
|
831
|
+
}): Promise<AppConfig>;
|
|
832
|
+
placeConfigOrders(app_config: AppConfig, solution: {
|
|
833
|
+
risk_reward: number;
|
|
834
|
+
entry: number;
|
|
835
|
+
stop: number;
|
|
836
|
+
risk_per_trade: number;
|
|
837
|
+
avg_size: number;
|
|
838
|
+
neg_pnl: number;
|
|
839
|
+
min_size: number;
|
|
840
|
+
symbol: string;
|
|
841
|
+
}, place?: boolean, skip_stop?: boolean): Promise<{
|
|
842
|
+
entry_orders: {
|
|
843
|
+
orders: {
|
|
844
|
+
entry: any;
|
|
845
|
+
quantity: any;
|
|
846
|
+
reverse_avg_entry: any;
|
|
847
|
+
reverse_avg_quantity: any;
|
|
848
|
+
avg_entry: any;
|
|
849
|
+
avg_size: any;
|
|
850
|
+
}[];
|
|
851
|
+
kind: "long" | "short";
|
|
852
|
+
};
|
|
853
|
+
stop_orders: {
|
|
854
|
+
stop: number;
|
|
855
|
+
final_stop: number;
|
|
856
|
+
kind: "long" | "short";
|
|
857
|
+
quantity: any;
|
|
858
|
+
is_limit: boolean;
|
|
859
|
+
neg_pnl: any;
|
|
860
|
+
};
|
|
861
|
+
trades: any[];
|
|
862
|
+
}>;
|
|
863
|
+
determineAmountToBuy(payload: {
|
|
864
|
+
orders: any[];
|
|
865
|
+
kind: "long" | "short";
|
|
866
|
+
refresh?: boolean;
|
|
867
|
+
decimal_places?: string;
|
|
868
|
+
price_places?: string;
|
|
869
|
+
cancel?: boolean;
|
|
870
|
+
place?: boolean;
|
|
871
|
+
}): Promise<any[]>;
|
|
872
|
+
refresh(live_refresh?: boolean): Promise<{
|
|
873
|
+
instance: PositionsView;
|
|
874
|
+
existingOrders: void | import("pocketbase").RecordModel[];
|
|
875
|
+
}>;
|
|
876
|
+
placeTrade(payload: {
|
|
877
|
+
place?: boolean;
|
|
878
|
+
tp?: boolean;
|
|
879
|
+
stop?: boolean;
|
|
880
|
+
raw?: boolean;
|
|
881
|
+
cancel?: boolean;
|
|
882
|
+
ignore_config?: boolean;
|
|
883
|
+
}): Promise<any>;
|
|
884
|
+
}
|
|
733
885
|
declare class ExchangeAccount$1 {
|
|
734
886
|
private instance;
|
|
735
887
|
exchange: BaseExchange;
|
|
736
888
|
main_exchange?: BaseExchange;
|
|
737
889
|
private app_db;
|
|
890
|
+
private long_position?;
|
|
891
|
+
private short_position?;
|
|
738
892
|
constructor(payload: ExchangeType, options: {
|
|
739
893
|
exchange: BaseExchange;
|
|
740
894
|
app_db: AppDatabase;
|
|
@@ -751,6 +905,11 @@ declare class ExchangeAccount$1 {
|
|
|
751
905
|
refresh?: boolean;
|
|
752
906
|
refresh_symbol_config?: boolean;
|
|
753
907
|
}): Promise<import("pocketbase").RecordModel>;
|
|
908
|
+
initializePositions(payload: {
|
|
909
|
+
symbol: string;
|
|
910
|
+
as_view?: boolean;
|
|
911
|
+
kind: "long" | "short";
|
|
912
|
+
}): Promise<ExchangePosition>;
|
|
754
913
|
getActiveAccount(payload: {
|
|
755
914
|
symbol: string;
|
|
756
915
|
full?: boolean;
|
|
@@ -764,6 +923,16 @@ declare class ExchangeAccount$1 {
|
|
|
764
923
|
current_price: any;
|
|
765
924
|
exchange: any;
|
|
766
925
|
}>;
|
|
926
|
+
refreshAccount(payload: {
|
|
927
|
+
symbol: string;
|
|
928
|
+
live_refresh?: boolean;
|
|
929
|
+
leverage?: number;
|
|
930
|
+
}): Promise<(PositionsView & {
|
|
931
|
+
expand?: {
|
|
932
|
+
config: ScheduledTrade;
|
|
933
|
+
account: ExchangeAccount;
|
|
934
|
+
};
|
|
935
|
+
})[]>;
|
|
767
936
|
syncAccount(options: {
|
|
768
937
|
symbol: string;
|
|
769
938
|
kind?: "long" | "short";
|
|
@@ -780,9 +949,9 @@ declare class ExchangeAccount$1 {
|
|
|
780
949
|
getRunningInstanceFromDB(symbol: string): Promise<TradeBlockTracking>;
|
|
781
950
|
syncOrders(options: {
|
|
782
951
|
symbol: string;
|
|
783
|
-
kind
|
|
952
|
+
kind?: "long" | "short";
|
|
784
953
|
update?: boolean;
|
|
785
|
-
}): Promise<import("pocketbase").RecordModel[]>;
|
|
954
|
+
}): Promise<void | import("pocketbase").RecordModel[]>;
|
|
786
955
|
toggleStopBuying(payload: {
|
|
787
956
|
symbol: string;
|
|
788
957
|
kind: "long" | "short";
|
|
@@ -1032,7 +1201,7 @@ declare class ExchangeAccount$1 {
|
|
|
1032
1201
|
symbol: string;
|
|
1033
1202
|
kind: "long" | "short";
|
|
1034
1203
|
revert?: boolean;
|
|
1035
|
-
}): Promise<import("pocketbase").RecordModel[]>;
|
|
1204
|
+
}): Promise<void | import("pocketbase").RecordModel[]>;
|
|
1036
1205
|
windDownSymbol(payload: {
|
|
1037
1206
|
symbol: string;
|
|
1038
1207
|
risk_reward?: number;
|
|
@@ -1079,7 +1248,6 @@ declare class ExchangeAccount$1 {
|
|
|
1079
1248
|
symbol: string;
|
|
1080
1249
|
kind: "long" | "short";
|
|
1081
1250
|
type: "limit" | "stop" | "tp";
|
|
1082
|
-
refresh?: boolean;
|
|
1083
1251
|
}): Promise<import("pocketbase").RecordModel[]>;
|
|
1084
1252
|
syncPositionConfigs(payload: {
|
|
1085
1253
|
symbol: string;
|
|
@@ -1242,6 +1410,7 @@ export declare function initApp(payload: {
|
|
|
1242
1410
|
proxy?: any;
|
|
1243
1411
|
ignore_proxy?: boolean;
|
|
1244
1412
|
canWithdraw?: boolean;
|
|
1413
|
+
triggerToken?: string;
|
|
1245
1414
|
}): Promise<App>;
|
|
1246
1415
|
export declare function initialize(payload: {
|
|
1247
1416
|
password?: string;
|