@gbozee/ultimate 0.0.2-83 → 0.0.2-87
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 +220 -164
- package/dist/index.d.ts +114 -8
- package/dist/index.js +220 -164
- package/dist/mcp-server.cjs +221 -179
- package/dist/mcp-server.js +221 -179
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -51980,9 +51980,17 @@ class AppDatabase {
|
|
|
51980
51980
|
}
|
|
51981
51981
|
return null;
|
|
51982
51982
|
}
|
|
51983
|
-
async
|
|
51983
|
+
async getRunningAccountStrategies() {
|
|
51984
|
+
const result = await this.pb.collection("account_strategies").getFullList({
|
|
51985
|
+
filter: `running=true`,
|
|
51986
|
+
expand: "account"
|
|
51987
|
+
});
|
|
51988
|
+
return result;
|
|
51989
|
+
}
|
|
51990
|
+
async getAccountStrategy(payload) {
|
|
51991
|
+
const { symbol, account } = payload;
|
|
51984
51992
|
const _strategy_instance = await this.pb.collection("account_strategies").getFullList({
|
|
51985
|
-
filter: `account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}"`,
|
|
51993
|
+
filter: `symbol:lower="${symbol.toLowerCase()}" && account.owner:lower="${account.owner.toLowerCase()}" && account.exchange:lower="${account.exchange.toLowerCase()}"`,
|
|
51986
51994
|
expand: "account"
|
|
51987
51995
|
});
|
|
51988
51996
|
if (_strategy_instance.length > 0) {
|
|
@@ -57398,8 +57406,11 @@ class ExchangeAccount {
|
|
|
57398
57406
|
async getCurrentPrice(symbol) {
|
|
57399
57407
|
return await this.exchange.get_current_price(symbol);
|
|
57400
57408
|
}
|
|
57401
|
-
async
|
|
57402
|
-
return await this.app_db.
|
|
57409
|
+
async getAccountStrategy(payload) {
|
|
57410
|
+
return await this.app_db.getAccountStrategy({
|
|
57411
|
+
symbol: payload.symbol,
|
|
57412
|
+
account: this.instance
|
|
57413
|
+
});
|
|
57403
57414
|
}
|
|
57404
57415
|
async buildReduceConfig(payload) {
|
|
57405
57416
|
const positions = await this.syncAccount({
|
|
@@ -58725,6 +58736,187 @@ class ExchangeAccount {
|
|
|
58725
58736
|
});
|
|
58726
58737
|
}
|
|
58727
58738
|
}
|
|
58739
|
+
async profitWithinGapStrategy(payload) {
|
|
58740
|
+
const {
|
|
58741
|
+
symbol,
|
|
58742
|
+
kind,
|
|
58743
|
+
risk,
|
|
58744
|
+
resistance,
|
|
58745
|
+
support,
|
|
58746
|
+
reward_factor = 1
|
|
58747
|
+
} = payload;
|
|
58748
|
+
console.log("Getting entry and stop for ", symbol, kind);
|
|
58749
|
+
const entry = kind === "long" ? resistance : support;
|
|
58750
|
+
const stop = kind === "long" ? support : resistance;
|
|
58751
|
+
console.log("Building app config for ", symbol, kind);
|
|
58752
|
+
const initial_app_config = await this.buildAppConfig({
|
|
58753
|
+
entry,
|
|
58754
|
+
stop,
|
|
58755
|
+
risk_reward: 199,
|
|
58756
|
+
risk,
|
|
58757
|
+
symbol
|
|
58758
|
+
});
|
|
58759
|
+
console.log("Computing risk reward for ", symbol, kind);
|
|
58760
|
+
const risk_reward = computeRiskReward({
|
|
58761
|
+
app_config: initial_app_config,
|
|
58762
|
+
entry: initial_app_config.entry,
|
|
58763
|
+
stop: initial_app_config.stop,
|
|
58764
|
+
risk_per_trade: initial_app_config.risk_per_trade
|
|
58765
|
+
});
|
|
58766
|
+
console.log("Re-computing app config for ", symbol, kind);
|
|
58767
|
+
const { entries, last_value, ...app_config } = await this.buildAppConfig({
|
|
58768
|
+
entry: initial_app_config.entry,
|
|
58769
|
+
stop: initial_app_config.stop,
|
|
58770
|
+
risk_reward,
|
|
58771
|
+
risk,
|
|
58772
|
+
symbol
|
|
58773
|
+
});
|
|
58774
|
+
console.log("Computing profit percent for ", symbol, kind);
|
|
58775
|
+
const pnl = reward_factor * risk;
|
|
58776
|
+
const profit_percent = to_f2(pnl * 100 / (last_value.avg_entry * last_value.avg_size), "%.4f");
|
|
58777
|
+
let config2 = {
|
|
58778
|
+
entry,
|
|
58779
|
+
stop,
|
|
58780
|
+
risk,
|
|
58781
|
+
risk_reward,
|
|
58782
|
+
profit_percent
|
|
58783
|
+
};
|
|
58784
|
+
console.log("Saving new config for ", symbol, kind);
|
|
58785
|
+
const data = await this.getPositionConfig({
|
|
58786
|
+
symbol,
|
|
58787
|
+
kind,
|
|
58788
|
+
params: config2
|
|
58789
|
+
});
|
|
58790
|
+
console.log("Checking orders to place for ", symbol, kind);
|
|
58791
|
+
const orders_to_place = await this.placeTrade({
|
|
58792
|
+
symbol,
|
|
58793
|
+
raw: true,
|
|
58794
|
+
kind,
|
|
58795
|
+
place: false,
|
|
58796
|
+
ignore_config: true
|
|
58797
|
+
});
|
|
58798
|
+
await this.placeTrade({
|
|
58799
|
+
symbol,
|
|
58800
|
+
kind,
|
|
58801
|
+
limit: false,
|
|
58802
|
+
ignore_config: true,
|
|
58803
|
+
tp: true
|
|
58804
|
+
});
|
|
58805
|
+
config2 = {
|
|
58806
|
+
...config2,
|
|
58807
|
+
...data
|
|
58808
|
+
};
|
|
58809
|
+
console.log("Fetching positions for ", symbol);
|
|
58810
|
+
const positions = await this.syncAccount({
|
|
58811
|
+
symbol,
|
|
58812
|
+
as_view: true
|
|
58813
|
+
});
|
|
58814
|
+
console.log("Getting long and short positions for ", symbol);
|
|
58815
|
+
const long_position = positions.find((k) => k.kind === "long");
|
|
58816
|
+
const short_position = positions.find((k) => k.kind === "short");
|
|
58817
|
+
console.log("Getting focus position for ", symbol, kind);
|
|
58818
|
+
const focus_position = kind === "long" ? long_position : short_position;
|
|
58819
|
+
const reverse_position = kind === "long" ? short_position : long_position;
|
|
58820
|
+
let reverse_action = null;
|
|
58821
|
+
let reverse_orders_to_buy = [];
|
|
58822
|
+
let reverse_config = null;
|
|
58823
|
+
console.log("Checking if focus position has quantity for ", symbol, kind);
|
|
58824
|
+
if (focus_position.quantity > 0) {
|
|
58825
|
+
console.log("Getting details for ", reverse_position.kind);
|
|
58826
|
+
reverse_action = await this.buildOppositeTrades({
|
|
58827
|
+
symbol,
|
|
58828
|
+
kind
|
|
58829
|
+
});
|
|
58830
|
+
console.log("Updating config for ", symbol, reverse_action.kind);
|
|
58831
|
+
await this.getPositionConfig({
|
|
58832
|
+
symbol,
|
|
58833
|
+
kind: reverse_action.kind,
|
|
58834
|
+
params: {
|
|
58835
|
+
entry: reverse_action.entry,
|
|
58836
|
+
stop: reverse_action.stop,
|
|
58837
|
+
risk: reverse_action.risk_per_trade,
|
|
58838
|
+
profit_percent: reverse_action.profit_percent,
|
|
58839
|
+
risk_reward: reverse_action.risk_reward
|
|
58840
|
+
}
|
|
58841
|
+
});
|
|
58842
|
+
console.log("Checking reverse orders to buy for ", symbol, reverse_action.kind);
|
|
58843
|
+
const reverse_app_config = await this.buildAppConfig({
|
|
58844
|
+
entry: reverse_action.entry,
|
|
58845
|
+
stop: reverse_action.stop,
|
|
58846
|
+
risk_reward: reverse_action.risk_reward,
|
|
58847
|
+
risk: reverse_action.risk_per_trade,
|
|
58848
|
+
symbol
|
|
58849
|
+
});
|
|
58850
|
+
if (reverse_app_config.max_size != reverse_position.avg_qty) {
|
|
58851
|
+
reverse_orders_to_buy = await this.placeTrade({
|
|
58852
|
+
symbol,
|
|
58853
|
+
raw: true,
|
|
58854
|
+
kind: reverse_action.kind,
|
|
58855
|
+
ignore_config: true,
|
|
58856
|
+
place: false
|
|
58857
|
+
});
|
|
58858
|
+
let _reverse_config = {
|
|
58859
|
+
avg: reverse_action.avg,
|
|
58860
|
+
entry: reverse_action.entry,
|
|
58861
|
+
stop: reverse_action.stop,
|
|
58862
|
+
risk_per_trade: reverse_action.risk_per_trade,
|
|
58863
|
+
profit_percent: reverse_action.profit_percent,
|
|
58864
|
+
risk_reward: reverse_action.risk_reward
|
|
58865
|
+
};
|
|
58866
|
+
if (reverse_orders_to_buy.length > 0) {
|
|
58867
|
+
console.log("Placing opposite trade action for ", symbol, reverse_action.kind);
|
|
58868
|
+
let existing = await this.placeOppositeTradeAction({
|
|
58869
|
+
symbol,
|
|
58870
|
+
kind: reverse_action.kind,
|
|
58871
|
+
data: _reverse_config
|
|
58872
|
+
});
|
|
58873
|
+
_reverse_config = {
|
|
58874
|
+
...existing,
|
|
58875
|
+
..._reverse_config
|
|
58876
|
+
};
|
|
58877
|
+
}
|
|
58878
|
+
reverse_config = _reverse_config;
|
|
58879
|
+
}
|
|
58880
|
+
if (!reverse_config?.id) {
|
|
58881
|
+
console.log("fetching reverse config for ", symbol, reverse_action.kind);
|
|
58882
|
+
reverse_config = await this.getPositionConfig({
|
|
58883
|
+
symbol,
|
|
58884
|
+
kind: reverse_action.kind
|
|
58885
|
+
});
|
|
58886
|
+
}
|
|
58887
|
+
if (reverse_position.quantity > 0 && reverse_config?.id) {
|
|
58888
|
+
console.log("Checking if reverse position has quantity for ", symbol, reverse_action.kind);
|
|
58889
|
+
const max_size = app_config.max_size * 0.98;
|
|
58890
|
+
if (reverse_config.threshold_qty !== max_size) {
|
|
58891
|
+
await this.app_db.updateScheduledTrade(reverse_config.id, {
|
|
58892
|
+
follow: true,
|
|
58893
|
+
threshold_qty: max_size
|
|
58894
|
+
});
|
|
58895
|
+
}
|
|
58896
|
+
console.log("Updating follow and threshold for ", symbol, reverse_action.kind);
|
|
58897
|
+
} else {
|
|
58898
|
+
await this.app_db.updateScheduledTrade(reverse_config.id, {
|
|
58899
|
+
follow: false
|
|
58900
|
+
});
|
|
58901
|
+
}
|
|
58902
|
+
}
|
|
58903
|
+
return {
|
|
58904
|
+
reverse_config,
|
|
58905
|
+
reverse_action,
|
|
58906
|
+
reverse_orders_to_buy,
|
|
58907
|
+
positions: {
|
|
58908
|
+
long: long_position,
|
|
58909
|
+
short: short_position
|
|
58910
|
+
},
|
|
58911
|
+
orders_to_place,
|
|
58912
|
+
config_details: {
|
|
58913
|
+
app_config,
|
|
58914
|
+
last_value,
|
|
58915
|
+
config: config2,
|
|
58916
|
+
pnl
|
|
58917
|
+
}
|
|
58918
|
+
};
|
|
58919
|
+
}
|
|
58728
58920
|
}
|
|
58729
58921
|
function getExchangeKlass(exchange) {
|
|
58730
58922
|
const func = exchange === "binance" ? BinanceExchange : BybitExchange;
|
|
@@ -58770,6 +58962,7 @@ async function getExchangeAccount(payload) {
|
|
|
58770
58962
|
app_db
|
|
58771
58963
|
});
|
|
58772
58964
|
}
|
|
58965
|
+
|
|
58773
58966
|
// src/app.ts
|
|
58774
58967
|
class App {
|
|
58775
58968
|
app_db;
|
|
@@ -58990,7 +59183,9 @@ class App {
|
|
|
58990
59183
|
await exchange_account.placeTrade({
|
|
58991
59184
|
symbol,
|
|
58992
59185
|
kind: "long",
|
|
58993
|
-
tp: true
|
|
59186
|
+
tp: true,
|
|
59187
|
+
limit: false,
|
|
59188
|
+
place: true
|
|
58994
59189
|
});
|
|
58995
59190
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
58996
59191
|
}
|
|
@@ -59037,6 +59232,20 @@ class App {
|
|
|
59037
59232
|
});
|
|
59038
59233
|
return result;
|
|
59039
59234
|
}
|
|
59235
|
+
async runDbStrategyAccounts() {
|
|
59236
|
+
const strategies = await this.app_db.getRunningAccountStrategies();
|
|
59237
|
+
for (const strategy of strategies) {
|
|
59238
|
+
console.log("Running strategy for ", strategy.symbol, "for account", strategy.expand.account.owner, strategy.expand.account.exchange);
|
|
59239
|
+
await this.profitWithinGapStrategy({
|
|
59240
|
+
symbol: strategy.symbol,
|
|
59241
|
+
kind: strategy.kind,
|
|
59242
|
+
risk: strategy.risk,
|
|
59243
|
+
resistance: strategy.resistance,
|
|
59244
|
+
support: strategy.support,
|
|
59245
|
+
account: strategy.expand.account
|
|
59246
|
+
});
|
|
59247
|
+
}
|
|
59248
|
+
}
|
|
59040
59249
|
async profitWithinGapStrategy(payload) {
|
|
59041
59250
|
const {
|
|
59042
59251
|
account,
|
|
@@ -59048,168 +59257,15 @@ class App {
|
|
|
59048
59257
|
reward_factor = 1
|
|
59049
59258
|
} = payload;
|
|
59050
59259
|
const exchange_account = await this.getExchangeAccount(account);
|
|
59051
|
-
|
|
59052
|
-
const entry = kind === "long" ? resistance : support;
|
|
59053
|
-
const stop = kind === "long" ? support : resistance;
|
|
59054
|
-
console.log("Building app config for ", symbol, kind);
|
|
59055
|
-
const initial_app_config = await exchange_account.buildAppConfig({
|
|
59056
|
-
entry,
|
|
59057
|
-
stop,
|
|
59058
|
-
risk_reward: 199,
|
|
59059
|
-
risk,
|
|
59060
|
-
symbol
|
|
59061
|
-
});
|
|
59062
|
-
console.log("Computing risk reward for ", symbol, kind);
|
|
59063
|
-
const risk_reward = computeRiskReward({
|
|
59064
|
-
app_config: initial_app_config,
|
|
59065
|
-
entry: initial_app_config.entry,
|
|
59066
|
-
stop: initial_app_config.stop,
|
|
59067
|
-
risk_per_trade: initial_app_config.risk_per_trade
|
|
59068
|
-
});
|
|
59069
|
-
console.log("Re-computing app config for ", symbol, kind);
|
|
59070
|
-
const { entries, last_value, ...app_config } = await exchange_account.buildAppConfig({
|
|
59071
|
-
entry: initial_app_config.entry,
|
|
59072
|
-
stop: initial_app_config.stop,
|
|
59073
|
-
risk_reward,
|
|
59074
|
-
risk,
|
|
59075
|
-
symbol
|
|
59076
|
-
});
|
|
59077
|
-
console.log("Computing profit percent for ", symbol, kind);
|
|
59078
|
-
const pnl = reward_factor * risk;
|
|
59079
|
-
const profit_percent = to_f2(pnl * 100 / (last_value.avg_entry * last_value.avg_size), "%.4f");
|
|
59080
|
-
let config2 = {
|
|
59081
|
-
entry,
|
|
59082
|
-
stop,
|
|
59083
|
-
risk,
|
|
59084
|
-
risk_reward,
|
|
59085
|
-
profit_percent
|
|
59086
|
-
};
|
|
59087
|
-
console.log("Saving new config for ", symbol, kind);
|
|
59088
|
-
const data = await exchange_account.getPositionConfig({
|
|
59260
|
+
const result = await exchange_account.profitWithinGapStrategy({
|
|
59089
59261
|
symbol,
|
|
59090
59262
|
kind,
|
|
59091
|
-
|
|
59092
|
-
|
|
59093
|
-
|
|
59094
|
-
|
|
59095
|
-
symbol,
|
|
59096
|
-
raw: true,
|
|
59097
|
-
kind,
|
|
59098
|
-
place: false
|
|
59099
|
-
});
|
|
59100
|
-
config2 = {
|
|
59101
|
-
...config2,
|
|
59102
|
-
...data
|
|
59103
|
-
};
|
|
59104
|
-
console.log("Fetching positions for ", symbol);
|
|
59105
|
-
const positions = await exchange_account.syncAccount({
|
|
59106
|
-
symbol,
|
|
59107
|
-
as_view: true
|
|
59263
|
+
risk,
|
|
59264
|
+
resistance,
|
|
59265
|
+
support,
|
|
59266
|
+
reward_factor
|
|
59108
59267
|
});
|
|
59109
|
-
|
|
59110
|
-
const long_position = positions.find((k) => k.kind === "long");
|
|
59111
|
-
const short_position = positions.find((k) => k.kind === "short");
|
|
59112
|
-
console.log("Getting focus position for ", symbol, kind);
|
|
59113
|
-
const focus_position = kind === "long" ? long_position : short_position;
|
|
59114
|
-
const reverse_position = kind === "long" ? short_position : long_position;
|
|
59115
|
-
let reverse_action = null;
|
|
59116
|
-
let reverse_orders_to_buy = [];
|
|
59117
|
-
let reverse_config = null;
|
|
59118
|
-
console.log("Checking if focus position has quantity for ", symbol, kind);
|
|
59119
|
-
if (focus_position.quantity > 0) {
|
|
59120
|
-
console.log("Getting details for ", reverse_position.kind);
|
|
59121
|
-
reverse_action = await exchange_account.buildOppositeTrades({
|
|
59122
|
-
symbol,
|
|
59123
|
-
kind
|
|
59124
|
-
});
|
|
59125
|
-
console.log("Updating config for ", symbol, reverse_action.kind);
|
|
59126
|
-
await exchange_account.getPositionConfig({
|
|
59127
|
-
symbol,
|
|
59128
|
-
kind: reverse_action.kind,
|
|
59129
|
-
params: {
|
|
59130
|
-
entry: reverse_action.entry,
|
|
59131
|
-
stop: reverse_action.stop,
|
|
59132
|
-
risk: reverse_action.risk_per_trade,
|
|
59133
|
-
profit_percent: reverse_action.profit_percent,
|
|
59134
|
-
risk_reward: reverse_action.risk_reward
|
|
59135
|
-
}
|
|
59136
|
-
});
|
|
59137
|
-
console.log("Checking reverse orders to buy for ", symbol, reverse_action.kind);
|
|
59138
|
-
const reverse_app_config = await exchange_account.buildAppConfig({
|
|
59139
|
-
entry: reverse_action.entry,
|
|
59140
|
-
stop: reverse_action.stop,
|
|
59141
|
-
risk_reward: reverse_action.risk_reward,
|
|
59142
|
-
risk: reverse_action.risk_per_trade,
|
|
59143
|
-
symbol
|
|
59144
|
-
});
|
|
59145
|
-
if (reverse_app_config.max_size != reverse_position.avg_qty) {
|
|
59146
|
-
reverse_orders_to_buy = await exchange_account.placeTrade({
|
|
59147
|
-
symbol,
|
|
59148
|
-
raw: true,
|
|
59149
|
-
kind: reverse_action.kind,
|
|
59150
|
-
place: false
|
|
59151
|
-
});
|
|
59152
|
-
let _reverse_config = {
|
|
59153
|
-
avg: reverse_action.avg,
|
|
59154
|
-
entry: reverse_action.entry,
|
|
59155
|
-
stop: reverse_action.stop,
|
|
59156
|
-
risk_per_trade: reverse_action.risk_per_trade,
|
|
59157
|
-
profit_percent: reverse_action.profit_percent,
|
|
59158
|
-
risk_reward: reverse_action.risk_reward
|
|
59159
|
-
};
|
|
59160
|
-
if (reverse_orders_to_buy.length > 0) {
|
|
59161
|
-
console.log("Placing opposite trade action for ", symbol, reverse_action.kind);
|
|
59162
|
-
let existing = await exchange_account.placeOppositeTradeAction({
|
|
59163
|
-
symbol,
|
|
59164
|
-
kind: reverse_action.kind,
|
|
59165
|
-
data: _reverse_config
|
|
59166
|
-
});
|
|
59167
|
-
_reverse_config = {
|
|
59168
|
-
...existing,
|
|
59169
|
-
..._reverse_config
|
|
59170
|
-
};
|
|
59171
|
-
}
|
|
59172
|
-
reverse_config = _reverse_config;
|
|
59173
|
-
}
|
|
59174
|
-
if (!reverse_config?.id) {
|
|
59175
|
-
console.log("fetching reverse config for ", symbol, reverse_action.kind);
|
|
59176
|
-
reverse_config = await exchange_account.getPositionConfig({
|
|
59177
|
-
symbol,
|
|
59178
|
-
kind: reverse_action.kind
|
|
59179
|
-
});
|
|
59180
|
-
}
|
|
59181
|
-
if (reverse_position.quantity > 0 && reverse_config?.id) {
|
|
59182
|
-
console.log("Checking if reverse position has quantity for ", symbol, reverse_action.kind);
|
|
59183
|
-
const max_size = app_config.max_size * 0.98;
|
|
59184
|
-
if (reverse_config.threshold_qty !== max_size) {
|
|
59185
|
-
await this.app_db.updateScheduledTrade(reverse_config.id, {
|
|
59186
|
-
follow: true,
|
|
59187
|
-
threshold_qty: max_size
|
|
59188
|
-
});
|
|
59189
|
-
}
|
|
59190
|
-
console.log("Updating follow and threshold for ", symbol, reverse_action.kind);
|
|
59191
|
-
} else {
|
|
59192
|
-
await this.app_db.updateScheduledTrade(reverse_config.id, {
|
|
59193
|
-
follow: false
|
|
59194
|
-
});
|
|
59195
|
-
}
|
|
59196
|
-
}
|
|
59197
|
-
return {
|
|
59198
|
-
reverse_config,
|
|
59199
|
-
reverse_action,
|
|
59200
|
-
reverse_orders_to_buy,
|
|
59201
|
-
positions: {
|
|
59202
|
-
long: long_position,
|
|
59203
|
-
short: short_position
|
|
59204
|
-
},
|
|
59205
|
-
orders_to_place,
|
|
59206
|
-
config_details: {
|
|
59207
|
-
app_config,
|
|
59208
|
-
last_value,
|
|
59209
|
-
config: config2,
|
|
59210
|
-
pnl
|
|
59211
|
-
}
|
|
59212
|
-
};
|
|
59268
|
+
return result;
|
|
59213
59269
|
}
|
|
59214
59270
|
}
|
|
59215
59271
|
async function initApp(payload) {
|
package/dist/index.d.ts
CHANGED
|
@@ -75,12 +75,12 @@ export interface ScheduledTrade extends BaseSystemFields {
|
|
|
75
75
|
export interface AccountStrategy extends BaseSystemFields {
|
|
76
76
|
account: string;
|
|
77
77
|
symbol: string;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
risk?: number;
|
|
79
|
+
reward_factor?: number;
|
|
80
|
+
kind?: "long" | "short";
|
|
81
|
+
support?: number;
|
|
82
|
+
resistance?: number;
|
|
83
|
+
running?: boolean;
|
|
84
84
|
}
|
|
85
85
|
interface Proxy$1 extends BaseSystemFields {
|
|
86
86
|
ip_address?: string;
|
|
@@ -486,7 +486,15 @@ export declare class AppDatabase {
|
|
|
486
486
|
kind: "long" | "short";
|
|
487
487
|
account: ExchangeType;
|
|
488
488
|
}): Promise<ScheduledTrade | null>;
|
|
489
|
-
|
|
489
|
+
getRunningAccountStrategies(): Promise<(AccountStrategy & {
|
|
490
|
+
expand?: {
|
|
491
|
+
account: ExchangeAccount;
|
|
492
|
+
};
|
|
493
|
+
})[]>;
|
|
494
|
+
getAccountStrategy(payload: {
|
|
495
|
+
symbol: string;
|
|
496
|
+
account: ExchangeType;
|
|
497
|
+
}): Promise<AccountStrategy>;
|
|
490
498
|
createOrUpdateWindingDownMarket(payload: {
|
|
491
499
|
symbol: string;
|
|
492
500
|
risk_reward?: number;
|
|
@@ -1366,7 +1374,9 @@ declare class ExchangeAccount$1 {
|
|
|
1366
1374
|
};
|
|
1367
1375
|
}): Promise<import("pocketbase").RecordModel | ScheduledTrade>;
|
|
1368
1376
|
getCurrentPrice(symbol: string): Promise<any>;
|
|
1369
|
-
|
|
1377
|
+
getAccountStrategy(payload: {
|
|
1378
|
+
symbol: string;
|
|
1379
|
+
}): Promise<AccountStrategy>;
|
|
1370
1380
|
buildReduceConfig(payload: {
|
|
1371
1381
|
symbol: string;
|
|
1372
1382
|
kind?: "long" | "short";
|
|
@@ -1664,6 +1674,101 @@ declare class ExchangeAccount$1 {
|
|
|
1664
1674
|
symbol: string;
|
|
1665
1675
|
kind: "long" | "short";
|
|
1666
1676
|
}): Promise<void>;
|
|
1677
|
+
profitWithinGapStrategy(payload: {
|
|
1678
|
+
symbol: string;
|
|
1679
|
+
kind: "long" | "short";
|
|
1680
|
+
risk: number;
|
|
1681
|
+
resistance: number;
|
|
1682
|
+
support: number;
|
|
1683
|
+
reward_factor?: number;
|
|
1684
|
+
}): Promise<{
|
|
1685
|
+
reverse_config: any;
|
|
1686
|
+
reverse_action: {
|
|
1687
|
+
avg: {
|
|
1688
|
+
entry: number;
|
|
1689
|
+
price: number;
|
|
1690
|
+
quantity: number;
|
|
1691
|
+
};
|
|
1692
|
+
loss: number;
|
|
1693
|
+
profit_percent: number;
|
|
1694
|
+
fee: number;
|
|
1695
|
+
risk_per_trade: number;
|
|
1696
|
+
risk_reward: number;
|
|
1697
|
+
symbol?: string;
|
|
1698
|
+
focus: number;
|
|
1699
|
+
budget: number;
|
|
1700
|
+
support: number;
|
|
1701
|
+
resistance: number;
|
|
1702
|
+
percent_change: number;
|
|
1703
|
+
tradeSplit?: number;
|
|
1704
|
+
take_profit?: number;
|
|
1705
|
+
kind: "long" | "short";
|
|
1706
|
+
entry: number;
|
|
1707
|
+
stop: number;
|
|
1708
|
+
min_size: number;
|
|
1709
|
+
price_places?: string;
|
|
1710
|
+
strategy?: "quantity" | "entry";
|
|
1711
|
+
as_array?: boolean;
|
|
1712
|
+
decimal_places?: string;
|
|
1713
|
+
min_profit?: number;
|
|
1714
|
+
raw?: boolean;
|
|
1715
|
+
gap?: number;
|
|
1716
|
+
rr?: number;
|
|
1717
|
+
max_size?: number;
|
|
1718
|
+
};
|
|
1719
|
+
reverse_orders_to_buy: any;
|
|
1720
|
+
positions: {
|
|
1721
|
+
long: PositionsView;
|
|
1722
|
+
short: PositionsView;
|
|
1723
|
+
};
|
|
1724
|
+
orders_to_place: any;
|
|
1725
|
+
config_details: {
|
|
1726
|
+
app_config: {
|
|
1727
|
+
fee: number;
|
|
1728
|
+
risk_per_trade: number;
|
|
1729
|
+
risk_reward: number;
|
|
1730
|
+
symbol?: string;
|
|
1731
|
+
focus: number;
|
|
1732
|
+
budget: number;
|
|
1733
|
+
support: number;
|
|
1734
|
+
resistance: number;
|
|
1735
|
+
percent_change: number;
|
|
1736
|
+
tradeSplit?: number;
|
|
1737
|
+
take_profit?: number;
|
|
1738
|
+
kind: "long" | "short";
|
|
1739
|
+
entry: number;
|
|
1740
|
+
stop: number;
|
|
1741
|
+
min_size: number;
|
|
1742
|
+
price_places?: string;
|
|
1743
|
+
strategy?: "quantity" | "entry";
|
|
1744
|
+
as_array?: boolean;
|
|
1745
|
+
decimal_places?: string;
|
|
1746
|
+
min_profit?: number;
|
|
1747
|
+
raw?: boolean;
|
|
1748
|
+
gap?: number;
|
|
1749
|
+
rr?: number;
|
|
1750
|
+
max_size?: number;
|
|
1751
|
+
};
|
|
1752
|
+
last_value: any;
|
|
1753
|
+
config: {
|
|
1754
|
+
entry: number;
|
|
1755
|
+
stop: number;
|
|
1756
|
+
risk: number;
|
|
1757
|
+
risk_reward: number | {
|
|
1758
|
+
result: any[];
|
|
1759
|
+
value: number;
|
|
1760
|
+
total: number;
|
|
1761
|
+
risk_per_trade: number;
|
|
1762
|
+
max: number;
|
|
1763
|
+
min: number;
|
|
1764
|
+
neg_pnl: any;
|
|
1765
|
+
entry: any;
|
|
1766
|
+
};
|
|
1767
|
+
profit_percent: number;
|
|
1768
|
+
};
|
|
1769
|
+
pnl: number;
|
|
1770
|
+
};
|
|
1771
|
+
}>;
|
|
1667
1772
|
}
|
|
1668
1773
|
declare function getExchangeAccount(payload: {
|
|
1669
1774
|
account: ExchangeType;
|
|
@@ -1783,6 +1888,7 @@ declare class App {
|
|
|
1783
1888
|
cancel?: boolean;
|
|
1784
1889
|
raw?: boolean;
|
|
1785
1890
|
}): Promise<any>;
|
|
1891
|
+
runDbStrategyAccounts(): Promise<void>;
|
|
1786
1892
|
profitWithinGapStrategy(payload: {
|
|
1787
1893
|
account: ExchangeType;
|
|
1788
1894
|
symbol: string;
|