@gbozee/ultimate 0.0.2-next.17 → 0.0.2-next.19
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.cjs +21 -18
- package/dist/index.js +21 -18
- package/dist/mcp-server.cjs +21 -18
- package/dist/mcp-server.js +21 -18
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -60306,7 +60306,7 @@ function preComputePositionState({
|
|
|
60306
60306
|
trades,
|
|
60307
60307
|
take_profit: null,
|
|
60308
60308
|
stop_loss: null,
|
|
60309
|
-
newTrades:
|
|
60309
|
+
newTrades: () => {
|
|
60310
60310
|
const tradesList = state.trades.get();
|
|
60311
60311
|
const pos = state.position.get();
|
|
60312
60312
|
if (!tradesList || tradesList.length === 0) {
|
|
@@ -60330,9 +60330,9 @@ function preComputePositionState({
|
|
|
60330
60330
|
};
|
|
60331
60331
|
});
|
|
60332
60332
|
return processedTrades.reverse();
|
|
60333
|
-
}
|
|
60333
|
+
},
|
|
60334
60334
|
generateSummary() {
|
|
60335
|
-
const trades2 = state.newTrades
|
|
60335
|
+
const trades2 = state.newTrades();
|
|
60336
60336
|
return {
|
|
60337
60337
|
...generateSummary2({
|
|
60338
60338
|
trades: trades2,
|
|
@@ -60342,7 +60342,7 @@ function preComputePositionState({
|
|
|
60342
60342
|
};
|
|
60343
60343
|
},
|
|
60344
60344
|
summary: computed(() => {
|
|
60345
|
-
const trades2 = state.newTrades
|
|
60345
|
+
const trades2 = state.newTrades();
|
|
60346
60346
|
return {
|
|
60347
60347
|
...generateSummary2({
|
|
60348
60348
|
trades: trades2,
|
|
@@ -60352,7 +60352,7 @@ function preComputePositionState({
|
|
|
60352
60352
|
};
|
|
60353
60353
|
}),
|
|
60354
60354
|
positionAt(price) {
|
|
60355
|
-
const trades2 = state.newTrades
|
|
60355
|
+
const trades2 = state.newTrades();
|
|
60356
60356
|
const kind = state.position.get().kind;
|
|
60357
60357
|
const filtered = trades2.filter((trade) => {
|
|
60358
60358
|
if (kind === "long") {
|
|
@@ -60364,7 +60364,7 @@ function preComputePositionState({
|
|
|
60364
60364
|
},
|
|
60365
60365
|
newPositionState(price) {
|
|
60366
60366
|
const position3 = state.position.get();
|
|
60367
|
-
const trades2 = state.newTrades
|
|
60367
|
+
const trades2 = state.newTrades();
|
|
60368
60368
|
const instance = state.positionAt(price);
|
|
60369
60369
|
return positionAt({
|
|
60370
60370
|
price,
|
|
@@ -60388,7 +60388,7 @@ function preComputePositionState({
|
|
|
60388
60388
|
},
|
|
60389
60389
|
updateStopLoss(payload) {
|
|
60390
60390
|
const { stop, quantity } = payload || {
|
|
60391
|
-
stop: state.newTrades
|
|
60391
|
+
stop: state.newTrades()[0].entry,
|
|
60392
60392
|
quantity: state.summary.get().quantity
|
|
60393
60393
|
};
|
|
60394
60394
|
state.stop_loss.set({
|
|
@@ -60757,7 +60757,7 @@ async function initClient3(credentials, options) {
|
|
|
60757
60757
|
const [account, exchange] = credentials.api_key.split(",");
|
|
60758
60758
|
const [email, password] = credentials.api_secret.split(",");
|
|
60759
60759
|
const db = await initPocketBaseClient({
|
|
60760
|
-
host:
|
|
60760
|
+
host: options.host,
|
|
60761
60761
|
email,
|
|
60762
60762
|
password
|
|
60763
60763
|
});
|
|
@@ -61323,14 +61323,16 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
61323
61323
|
}
|
|
61324
61324
|
async _createLimitPurchaseOrders(payload) {
|
|
61325
61325
|
const { positions, symbol_config, current_price } = await fetchDBExchangeData(this.client, payload.symbol);
|
|
61326
|
-
const
|
|
61326
|
+
const kind = payload.orders[0].kind;
|
|
61327
|
+
const params = {
|
|
61327
61328
|
position: {
|
|
61328
|
-
kind
|
|
61329
|
-
entry: positions[
|
|
61330
|
-
quantity: positions[
|
|
61329
|
+
kind,
|
|
61330
|
+
entry: positions[kind]?.entry || 0,
|
|
61331
|
+
quantity: positions[kind]?.quantity || 0
|
|
61331
61332
|
},
|
|
61332
61333
|
global_config: symbol_config
|
|
61333
|
-
}
|
|
61334
|
+
};
|
|
61335
|
+
const generator = primitiveTradeGenerator(params);
|
|
61334
61336
|
const state = await generator.initializeEngine({
|
|
61335
61337
|
trades: payload.orders,
|
|
61336
61338
|
price: current_price
|
|
@@ -61339,9 +61341,9 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
61339
61341
|
entry: state.position.get().entry,
|
|
61340
61342
|
quantity: state.position.get().quantity
|
|
61341
61343
|
};
|
|
61342
|
-
const remaining_orders = state.newTrades
|
|
61344
|
+
const remaining_orders = state.newTrades();
|
|
61343
61345
|
return await savePaperDetails(this.client, {
|
|
61344
|
-
kind
|
|
61346
|
+
kind,
|
|
61345
61347
|
symbol: payload.symbol,
|
|
61346
61348
|
price_places: payload.price_places,
|
|
61347
61349
|
decimal_places: payload.decimal_places
|
|
@@ -63171,7 +63173,7 @@ class ExchangeAccount {
|
|
|
63171
63173
|
return profiles;
|
|
63172
63174
|
}
|
|
63173
63175
|
}
|
|
63174
|
-
function getExchangeKlass(exchange) {
|
|
63176
|
+
function getExchangeKlass(exchange, db_url) {
|
|
63175
63177
|
const func = exchange === "binance" ? BinanceExchange : exchange === "paper" ? PaperBinanceExchange : BybitExchange;
|
|
63176
63178
|
const clientFunc = exchange === "binance" ? initClient : exchange === "paper" ? initClient3 : initClient2;
|
|
63177
63179
|
return async (payload) => {
|
|
@@ -63181,7 +63183,8 @@ function getExchangeKlass(exchange) {
|
|
|
63181
63183
|
});
|
|
63182
63184
|
const client = await clientFunc(credentials, {
|
|
63183
63185
|
type: "future",
|
|
63184
|
-
proxyAgent: payload.proxyAgent
|
|
63186
|
+
proxyAgent: payload.proxyAgent,
|
|
63187
|
+
host: db_url
|
|
63185
63188
|
});
|
|
63186
63189
|
let main_client = null;
|
|
63187
63190
|
if (exchange === "binance") {
|
|
@@ -63207,7 +63210,7 @@ async function getExchangeAccount(payload) {
|
|
|
63207
63210
|
const { account, app_db, proxyOptions = {}, canWithdraw = false } = payload;
|
|
63208
63211
|
const _proxyAgent = await app_db.getProxyForAccount(account);
|
|
63209
63212
|
const proxyAgent = proxyOptions?.ignore_proxy ? null : proxyOptions?.proxy || _proxyAgent;
|
|
63210
|
-
const exchange_instance = await getExchangeKlass(account.exchange)({
|
|
63213
|
+
const exchange_instance = await getExchangeKlass(account.exchange, app_db.pb.baseURL)({
|
|
63211
63214
|
account: account.owner,
|
|
63212
63215
|
getCredentials: async (_payload) => {
|
|
63213
63216
|
return await payload.getCredentials({ ..._payload, app_db });
|
package/dist/index.js
CHANGED
|
@@ -60243,7 +60243,7 @@ function preComputePositionState({
|
|
|
60243
60243
|
trades,
|
|
60244
60244
|
take_profit: null,
|
|
60245
60245
|
stop_loss: null,
|
|
60246
|
-
newTrades:
|
|
60246
|
+
newTrades: () => {
|
|
60247
60247
|
const tradesList = state.trades.get();
|
|
60248
60248
|
const pos = state.position.get();
|
|
60249
60249
|
if (!tradesList || tradesList.length === 0) {
|
|
@@ -60267,9 +60267,9 @@ function preComputePositionState({
|
|
|
60267
60267
|
};
|
|
60268
60268
|
});
|
|
60269
60269
|
return processedTrades.reverse();
|
|
60270
|
-
}
|
|
60270
|
+
},
|
|
60271
60271
|
generateSummary() {
|
|
60272
|
-
const trades2 = state.newTrades
|
|
60272
|
+
const trades2 = state.newTrades();
|
|
60273
60273
|
return {
|
|
60274
60274
|
...generateSummary2({
|
|
60275
60275
|
trades: trades2,
|
|
@@ -60279,7 +60279,7 @@ function preComputePositionState({
|
|
|
60279
60279
|
};
|
|
60280
60280
|
},
|
|
60281
60281
|
summary: computed(() => {
|
|
60282
|
-
const trades2 = state.newTrades
|
|
60282
|
+
const trades2 = state.newTrades();
|
|
60283
60283
|
return {
|
|
60284
60284
|
...generateSummary2({
|
|
60285
60285
|
trades: trades2,
|
|
@@ -60289,7 +60289,7 @@ function preComputePositionState({
|
|
|
60289
60289
|
};
|
|
60290
60290
|
}),
|
|
60291
60291
|
positionAt(price) {
|
|
60292
|
-
const trades2 = state.newTrades
|
|
60292
|
+
const trades2 = state.newTrades();
|
|
60293
60293
|
const kind = state.position.get().kind;
|
|
60294
60294
|
const filtered = trades2.filter((trade) => {
|
|
60295
60295
|
if (kind === "long") {
|
|
@@ -60301,7 +60301,7 @@ function preComputePositionState({
|
|
|
60301
60301
|
},
|
|
60302
60302
|
newPositionState(price) {
|
|
60303
60303
|
const position3 = state.position.get();
|
|
60304
|
-
const trades2 = state.newTrades
|
|
60304
|
+
const trades2 = state.newTrades();
|
|
60305
60305
|
const instance = state.positionAt(price);
|
|
60306
60306
|
return positionAt({
|
|
60307
60307
|
price,
|
|
@@ -60325,7 +60325,7 @@ function preComputePositionState({
|
|
|
60325
60325
|
},
|
|
60326
60326
|
updateStopLoss(payload) {
|
|
60327
60327
|
const { stop, quantity } = payload || {
|
|
60328
|
-
stop: state.newTrades
|
|
60328
|
+
stop: state.newTrades()[0].entry,
|
|
60329
60329
|
quantity: state.summary.get().quantity
|
|
60330
60330
|
};
|
|
60331
60331
|
state.stop_loss.set({
|
|
@@ -60694,7 +60694,7 @@ async function initClient3(credentials, options) {
|
|
|
60694
60694
|
const [account, exchange] = credentials.api_key.split(",");
|
|
60695
60695
|
const [email, password] = credentials.api_secret.split(",");
|
|
60696
60696
|
const db = await initPocketBaseClient({
|
|
60697
|
-
host:
|
|
60697
|
+
host: options.host,
|
|
60698
60698
|
email,
|
|
60699
60699
|
password
|
|
60700
60700
|
});
|
|
@@ -61260,14 +61260,16 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
61260
61260
|
}
|
|
61261
61261
|
async _createLimitPurchaseOrders(payload) {
|
|
61262
61262
|
const { positions, symbol_config, current_price } = await fetchDBExchangeData(this.client, payload.symbol);
|
|
61263
|
-
const
|
|
61263
|
+
const kind = payload.orders[0].kind;
|
|
61264
|
+
const params = {
|
|
61264
61265
|
position: {
|
|
61265
|
-
kind
|
|
61266
|
-
entry: positions[
|
|
61267
|
-
quantity: positions[
|
|
61266
|
+
kind,
|
|
61267
|
+
entry: positions[kind]?.entry || 0,
|
|
61268
|
+
quantity: positions[kind]?.quantity || 0
|
|
61268
61269
|
},
|
|
61269
61270
|
global_config: symbol_config
|
|
61270
|
-
}
|
|
61271
|
+
};
|
|
61272
|
+
const generator = primitiveTradeGenerator(params);
|
|
61271
61273
|
const state = await generator.initializeEngine({
|
|
61272
61274
|
trades: payload.orders,
|
|
61273
61275
|
price: current_price
|
|
@@ -61276,9 +61278,9 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
61276
61278
|
entry: state.position.get().entry,
|
|
61277
61279
|
quantity: state.position.get().quantity
|
|
61278
61280
|
};
|
|
61279
|
-
const remaining_orders = state.newTrades
|
|
61281
|
+
const remaining_orders = state.newTrades();
|
|
61280
61282
|
return await savePaperDetails(this.client, {
|
|
61281
|
-
kind
|
|
61283
|
+
kind,
|
|
61282
61284
|
symbol: payload.symbol,
|
|
61283
61285
|
price_places: payload.price_places,
|
|
61284
61286
|
decimal_places: payload.decimal_places
|
|
@@ -63108,7 +63110,7 @@ class ExchangeAccount {
|
|
|
63108
63110
|
return profiles;
|
|
63109
63111
|
}
|
|
63110
63112
|
}
|
|
63111
|
-
function getExchangeKlass(exchange) {
|
|
63113
|
+
function getExchangeKlass(exchange, db_url) {
|
|
63112
63114
|
const func = exchange === "binance" ? BinanceExchange : exchange === "paper" ? PaperBinanceExchange : BybitExchange;
|
|
63113
63115
|
const clientFunc = exchange === "binance" ? initClient : exchange === "paper" ? initClient3 : initClient2;
|
|
63114
63116
|
return async (payload) => {
|
|
@@ -63118,7 +63120,8 @@ function getExchangeKlass(exchange) {
|
|
|
63118
63120
|
});
|
|
63119
63121
|
const client = await clientFunc(credentials, {
|
|
63120
63122
|
type: "future",
|
|
63121
|
-
proxyAgent: payload.proxyAgent
|
|
63123
|
+
proxyAgent: payload.proxyAgent,
|
|
63124
|
+
host: db_url
|
|
63122
63125
|
});
|
|
63123
63126
|
let main_client = null;
|
|
63124
63127
|
if (exchange === "binance") {
|
|
@@ -63144,7 +63147,7 @@ async function getExchangeAccount(payload) {
|
|
|
63144
63147
|
const { account, app_db, proxyOptions = {}, canWithdraw = false } = payload;
|
|
63145
63148
|
const _proxyAgent = await app_db.getProxyForAccount(account);
|
|
63146
63149
|
const proxyAgent = proxyOptions?.ignore_proxy ? null : proxyOptions?.proxy || _proxyAgent;
|
|
63147
|
-
const exchange_instance = await getExchangeKlass(account.exchange)({
|
|
63150
|
+
const exchange_instance = await getExchangeKlass(account.exchange, app_db.pb.baseURL)({
|
|
63148
63151
|
account: account.owner,
|
|
63149
63152
|
getCredentials: async (_payload) => {
|
|
63150
63153
|
return await payload.getCredentials({ ..._payload, app_db });
|
package/dist/mcp-server.cjs
CHANGED
|
@@ -73286,7 +73286,7 @@ function preComputePositionState({
|
|
|
73286
73286
|
trades,
|
|
73287
73287
|
take_profit: null,
|
|
73288
73288
|
stop_loss: null,
|
|
73289
|
-
newTrades:
|
|
73289
|
+
newTrades: () => {
|
|
73290
73290
|
const tradesList = state.trades.get();
|
|
73291
73291
|
const pos = state.position.get();
|
|
73292
73292
|
if (!tradesList || tradesList.length === 0) {
|
|
@@ -73310,9 +73310,9 @@ function preComputePositionState({
|
|
|
73310
73310
|
};
|
|
73311
73311
|
});
|
|
73312
73312
|
return processedTrades.reverse();
|
|
73313
|
-
}
|
|
73313
|
+
},
|
|
73314
73314
|
generateSummary() {
|
|
73315
|
-
const trades2 = state.newTrades
|
|
73315
|
+
const trades2 = state.newTrades();
|
|
73316
73316
|
return {
|
|
73317
73317
|
...generateSummary2({
|
|
73318
73318
|
trades: trades2,
|
|
@@ -73322,7 +73322,7 @@ function preComputePositionState({
|
|
|
73322
73322
|
};
|
|
73323
73323
|
},
|
|
73324
73324
|
summary: computed(() => {
|
|
73325
|
-
const trades2 = state.newTrades
|
|
73325
|
+
const trades2 = state.newTrades();
|
|
73326
73326
|
return {
|
|
73327
73327
|
...generateSummary2({
|
|
73328
73328
|
trades: trades2,
|
|
@@ -73332,7 +73332,7 @@ function preComputePositionState({
|
|
|
73332
73332
|
};
|
|
73333
73333
|
}),
|
|
73334
73334
|
positionAt(price) {
|
|
73335
|
-
const trades2 = state.newTrades
|
|
73335
|
+
const trades2 = state.newTrades();
|
|
73336
73336
|
const kind = state.position.get().kind;
|
|
73337
73337
|
const filtered = trades2.filter((trade) => {
|
|
73338
73338
|
if (kind === "long") {
|
|
@@ -73344,7 +73344,7 @@ function preComputePositionState({
|
|
|
73344
73344
|
},
|
|
73345
73345
|
newPositionState(price) {
|
|
73346
73346
|
const position3 = state.position.get();
|
|
73347
|
-
const trades2 = state.newTrades
|
|
73347
|
+
const trades2 = state.newTrades();
|
|
73348
73348
|
const instance = state.positionAt(price);
|
|
73349
73349
|
return positionAt({
|
|
73350
73350
|
price,
|
|
@@ -73368,7 +73368,7 @@ function preComputePositionState({
|
|
|
73368
73368
|
},
|
|
73369
73369
|
updateStopLoss(payload) {
|
|
73370
73370
|
const { stop, quantity } = payload || {
|
|
73371
|
-
stop: state.newTrades
|
|
73371
|
+
stop: state.newTrades()[0].entry,
|
|
73372
73372
|
quantity: state.summary.get().quantity
|
|
73373
73373
|
};
|
|
73374
73374
|
state.stop_loss.set({
|
|
@@ -73737,7 +73737,7 @@ async function initClient3(credentials, options) {
|
|
|
73737
73737
|
const [account, exchange] = credentials.api_key.split(",");
|
|
73738
73738
|
const [email, password] = credentials.api_secret.split(",");
|
|
73739
73739
|
const db = await initPocketBaseClient({
|
|
73740
|
-
host:
|
|
73740
|
+
host: options.host,
|
|
73741
73741
|
email,
|
|
73742
73742
|
password
|
|
73743
73743
|
});
|
|
@@ -74303,14 +74303,16 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
74303
74303
|
}
|
|
74304
74304
|
async _createLimitPurchaseOrders(payload) {
|
|
74305
74305
|
const { positions, symbol_config, current_price } = await fetchDBExchangeData(this.client, payload.symbol);
|
|
74306
|
-
const
|
|
74306
|
+
const kind = payload.orders[0].kind;
|
|
74307
|
+
const params = {
|
|
74307
74308
|
position: {
|
|
74308
|
-
kind
|
|
74309
|
-
entry: positions[
|
|
74310
|
-
quantity: positions[
|
|
74309
|
+
kind,
|
|
74310
|
+
entry: positions[kind]?.entry || 0,
|
|
74311
|
+
quantity: positions[kind]?.quantity || 0
|
|
74311
74312
|
},
|
|
74312
74313
|
global_config: symbol_config
|
|
74313
|
-
}
|
|
74314
|
+
};
|
|
74315
|
+
const generator = primitiveTradeGenerator(params);
|
|
74314
74316
|
const state = await generator.initializeEngine({
|
|
74315
74317
|
trades: payload.orders,
|
|
74316
74318
|
price: current_price
|
|
@@ -74319,9 +74321,9 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
74319
74321
|
entry: state.position.get().entry,
|
|
74320
74322
|
quantity: state.position.get().quantity
|
|
74321
74323
|
};
|
|
74322
|
-
const remaining_orders = state.newTrades
|
|
74324
|
+
const remaining_orders = state.newTrades();
|
|
74323
74325
|
return await savePaperDetails(this.client, {
|
|
74324
|
-
kind
|
|
74326
|
+
kind,
|
|
74325
74327
|
symbol: payload.symbol,
|
|
74326
74328
|
price_places: payload.price_places,
|
|
74327
74329
|
decimal_places: payload.decimal_places
|
|
@@ -76151,7 +76153,7 @@ class ExchangeAccount {
|
|
|
76151
76153
|
return profiles;
|
|
76152
76154
|
}
|
|
76153
76155
|
}
|
|
76154
|
-
function getExchangeKlass(exchange) {
|
|
76156
|
+
function getExchangeKlass(exchange, db_url) {
|
|
76155
76157
|
const func = exchange === "binance" ? BinanceExchange : exchange === "paper" ? PaperBinanceExchange : BybitExchange;
|
|
76156
76158
|
const clientFunc = exchange === "binance" ? initClient : exchange === "paper" ? initClient3 : initClient2;
|
|
76157
76159
|
return async (payload) => {
|
|
@@ -76161,7 +76163,8 @@ function getExchangeKlass(exchange) {
|
|
|
76161
76163
|
});
|
|
76162
76164
|
const client = await clientFunc(credentials, {
|
|
76163
76165
|
type: "future",
|
|
76164
|
-
proxyAgent: payload.proxyAgent
|
|
76166
|
+
proxyAgent: payload.proxyAgent,
|
|
76167
|
+
host: db_url
|
|
76165
76168
|
});
|
|
76166
76169
|
let main_client = null;
|
|
76167
76170
|
if (exchange === "binance") {
|
|
@@ -76187,7 +76190,7 @@ async function getExchangeAccount(payload) {
|
|
|
76187
76190
|
const { account, app_db, proxyOptions = {}, canWithdraw = false } = payload;
|
|
76188
76191
|
const _proxyAgent = await app_db.getProxyForAccount(account);
|
|
76189
76192
|
const proxyAgent = proxyOptions?.ignore_proxy ? null : proxyOptions?.proxy || _proxyAgent;
|
|
76190
|
-
const exchange_instance = await getExchangeKlass(account.exchange)({
|
|
76193
|
+
const exchange_instance = await getExchangeKlass(account.exchange, app_db.pb.baseURL)({
|
|
76191
76194
|
account: account.owner,
|
|
76192
76195
|
getCredentials: async (_payload) => {
|
|
76193
76196
|
return await payload.getCredentials({ ..._payload, app_db });
|
package/dist/mcp-server.js
CHANGED
|
@@ -73259,7 +73259,7 @@ function preComputePositionState({
|
|
|
73259
73259
|
trades,
|
|
73260
73260
|
take_profit: null,
|
|
73261
73261
|
stop_loss: null,
|
|
73262
|
-
newTrades:
|
|
73262
|
+
newTrades: () => {
|
|
73263
73263
|
const tradesList = state.trades.get();
|
|
73264
73264
|
const pos = state.position.get();
|
|
73265
73265
|
if (!tradesList || tradesList.length === 0) {
|
|
@@ -73283,9 +73283,9 @@ function preComputePositionState({
|
|
|
73283
73283
|
};
|
|
73284
73284
|
});
|
|
73285
73285
|
return processedTrades.reverse();
|
|
73286
|
-
}
|
|
73286
|
+
},
|
|
73287
73287
|
generateSummary() {
|
|
73288
|
-
const trades2 = state.newTrades
|
|
73288
|
+
const trades2 = state.newTrades();
|
|
73289
73289
|
return {
|
|
73290
73290
|
...generateSummary2({
|
|
73291
73291
|
trades: trades2,
|
|
@@ -73295,7 +73295,7 @@ function preComputePositionState({
|
|
|
73295
73295
|
};
|
|
73296
73296
|
},
|
|
73297
73297
|
summary: computed(() => {
|
|
73298
|
-
const trades2 = state.newTrades
|
|
73298
|
+
const trades2 = state.newTrades();
|
|
73299
73299
|
return {
|
|
73300
73300
|
...generateSummary2({
|
|
73301
73301
|
trades: trades2,
|
|
@@ -73305,7 +73305,7 @@ function preComputePositionState({
|
|
|
73305
73305
|
};
|
|
73306
73306
|
}),
|
|
73307
73307
|
positionAt(price) {
|
|
73308
|
-
const trades2 = state.newTrades
|
|
73308
|
+
const trades2 = state.newTrades();
|
|
73309
73309
|
const kind = state.position.get().kind;
|
|
73310
73310
|
const filtered = trades2.filter((trade) => {
|
|
73311
73311
|
if (kind === "long") {
|
|
@@ -73317,7 +73317,7 @@ function preComputePositionState({
|
|
|
73317
73317
|
},
|
|
73318
73318
|
newPositionState(price) {
|
|
73319
73319
|
const position3 = state.position.get();
|
|
73320
|
-
const trades2 = state.newTrades
|
|
73320
|
+
const trades2 = state.newTrades();
|
|
73321
73321
|
const instance = state.positionAt(price);
|
|
73322
73322
|
return positionAt({
|
|
73323
73323
|
price,
|
|
@@ -73341,7 +73341,7 @@ function preComputePositionState({
|
|
|
73341
73341
|
},
|
|
73342
73342
|
updateStopLoss(payload) {
|
|
73343
73343
|
const { stop, quantity } = payload || {
|
|
73344
|
-
stop: state.newTrades
|
|
73344
|
+
stop: state.newTrades()[0].entry,
|
|
73345
73345
|
quantity: state.summary.get().quantity
|
|
73346
73346
|
};
|
|
73347
73347
|
state.stop_loss.set({
|
|
@@ -73710,7 +73710,7 @@ async function initClient3(credentials, options) {
|
|
|
73710
73710
|
const [account, exchange] = credentials.api_key.split(",");
|
|
73711
73711
|
const [email, password] = credentials.api_secret.split(",");
|
|
73712
73712
|
const db = await initPocketBaseClient({
|
|
73713
|
-
host:
|
|
73713
|
+
host: options.host,
|
|
73714
73714
|
email,
|
|
73715
73715
|
password
|
|
73716
73716
|
});
|
|
@@ -74276,14 +74276,16 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
74276
74276
|
}
|
|
74277
74277
|
async _createLimitPurchaseOrders(payload) {
|
|
74278
74278
|
const { positions, symbol_config, current_price } = await fetchDBExchangeData(this.client, payload.symbol);
|
|
74279
|
-
const
|
|
74279
|
+
const kind = payload.orders[0].kind;
|
|
74280
|
+
const params = {
|
|
74280
74281
|
position: {
|
|
74281
|
-
kind
|
|
74282
|
-
entry: positions[
|
|
74283
|
-
quantity: positions[
|
|
74282
|
+
kind,
|
|
74283
|
+
entry: positions[kind]?.entry || 0,
|
|
74284
|
+
quantity: positions[kind]?.quantity || 0
|
|
74284
74285
|
},
|
|
74285
74286
|
global_config: symbol_config
|
|
74286
|
-
}
|
|
74287
|
+
};
|
|
74288
|
+
const generator = primitiveTradeGenerator(params);
|
|
74287
74289
|
const state = await generator.initializeEngine({
|
|
74288
74290
|
trades: payload.orders,
|
|
74289
74291
|
price: current_price
|
|
@@ -74292,9 +74294,9 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
74292
74294
|
entry: state.position.get().entry,
|
|
74293
74295
|
quantity: state.position.get().quantity
|
|
74294
74296
|
};
|
|
74295
|
-
const remaining_orders = state.newTrades
|
|
74297
|
+
const remaining_orders = state.newTrades();
|
|
74296
74298
|
return await savePaperDetails(this.client, {
|
|
74297
|
-
kind
|
|
74299
|
+
kind,
|
|
74298
74300
|
symbol: payload.symbol,
|
|
74299
74301
|
price_places: payload.price_places,
|
|
74300
74302
|
decimal_places: payload.decimal_places
|
|
@@ -76124,7 +76126,7 @@ class ExchangeAccount {
|
|
|
76124
76126
|
return profiles;
|
|
76125
76127
|
}
|
|
76126
76128
|
}
|
|
76127
|
-
function getExchangeKlass(exchange) {
|
|
76129
|
+
function getExchangeKlass(exchange, db_url) {
|
|
76128
76130
|
const func = exchange === "binance" ? BinanceExchange : exchange === "paper" ? PaperBinanceExchange : BybitExchange;
|
|
76129
76131
|
const clientFunc = exchange === "binance" ? initClient : exchange === "paper" ? initClient3 : initClient2;
|
|
76130
76132
|
return async (payload) => {
|
|
@@ -76134,7 +76136,8 @@ function getExchangeKlass(exchange) {
|
|
|
76134
76136
|
});
|
|
76135
76137
|
const client = await clientFunc(credentials, {
|
|
76136
76138
|
type: "future",
|
|
76137
|
-
proxyAgent: payload.proxyAgent
|
|
76139
|
+
proxyAgent: payload.proxyAgent,
|
|
76140
|
+
host: db_url
|
|
76138
76141
|
});
|
|
76139
76142
|
let main_client = null;
|
|
76140
76143
|
if (exchange === "binance") {
|
|
@@ -76160,7 +76163,7 @@ async function getExchangeAccount(payload) {
|
|
|
76160
76163
|
const { account, app_db, proxyOptions = {}, canWithdraw = false } = payload;
|
|
76161
76164
|
const _proxyAgent = await app_db.getProxyForAccount(account);
|
|
76162
76165
|
const proxyAgent = proxyOptions?.ignore_proxy ? null : proxyOptions?.proxy || _proxyAgent;
|
|
76163
|
-
const exchange_instance = await getExchangeKlass(account.exchange)({
|
|
76166
|
+
const exchange_instance = await getExchangeKlass(account.exchange, app_db.pb.baseURL)({
|
|
76164
76167
|
account: account.owner,
|
|
76165
76168
|
getCredentials: async (_payload) => {
|
|
76166
76169
|
return await payload.getCredentials({ ..._payload, app_db });
|