@gbozee/ultimate 0.0.2-35 → 0.0.2-36
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 +6 -0
- package/dist/index.js +26 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -898,6 +898,12 @@ declare class ExchangeAccount$1 {
|
|
|
898
898
|
raw?: boolean;
|
|
899
899
|
use_current?: boolean;
|
|
900
900
|
}): Promise<any>;
|
|
901
|
+
getOrCreatePositionConfig(payload: {
|
|
902
|
+
symbol: string;
|
|
903
|
+
kind: "long" | "short";
|
|
904
|
+
risk?: number;
|
|
905
|
+
risk_reward?: number;
|
|
906
|
+
}): Promise<ScheduledTrade | import("pocketbase").RecordModel>;
|
|
901
907
|
getPositionConfig(payload: {
|
|
902
908
|
symbol: string;
|
|
903
909
|
kind: "long" | "short";
|
package/dist/index.js
CHANGED
|
@@ -36704,6 +36704,31 @@ class ExchangeAccount {
|
|
|
36704
36704
|
stop_orders
|
|
36705
36705
|
};
|
|
36706
36706
|
}
|
|
36707
|
+
async getOrCreatePositionConfig(payload) {
|
|
36708
|
+
const { symbol, kind, risk = 50, risk_reward = 199 } = payload;
|
|
36709
|
+
const config = await this.getPositionConfig({
|
|
36710
|
+
symbol: payload.symbol,
|
|
36711
|
+
kind: payload.kind
|
|
36712
|
+
});
|
|
36713
|
+
if (!config) {
|
|
36714
|
+
const long_c = await this.buildConfigForSymbol({
|
|
36715
|
+
symbol,
|
|
36716
|
+
risk,
|
|
36717
|
+
risk_reward
|
|
36718
|
+
});
|
|
36719
|
+
return this.getPositionConfig({
|
|
36720
|
+
symbol,
|
|
36721
|
+
kind,
|
|
36722
|
+
params: {
|
|
36723
|
+
entry: kind === "long" ? long_c.entry : long_c.stop,
|
|
36724
|
+
stop: kind === "long" ? long_c.stop : long_c.entry,
|
|
36725
|
+
risk_reward: long_c.risk_reward,
|
|
36726
|
+
risk: long_c.risk
|
|
36727
|
+
}
|
|
36728
|
+
});
|
|
36729
|
+
}
|
|
36730
|
+
return config;
|
|
36731
|
+
}
|
|
36707
36732
|
async getPositionConfig(payload) {
|
|
36708
36733
|
if (payload.params) {
|
|
36709
36734
|
const db_position = await this.syncAccount({
|
|
@@ -38132,6 +38157,7 @@ class App {
|
|
|
38132
38157
|
}
|
|
38133
38158
|
const positions = await this.app_db.hasExistingPosition(symbol);
|
|
38134
38159
|
if (positions.length === 0) {
|
|
38160
|
+
console.log("Removing symbol from DB", symbol);
|
|
38135
38161
|
return this.app_db.unwindSymbolFromDB(symbol);
|
|
38136
38162
|
}
|
|
38137
38163
|
const unique_instances = new Set(positions.map((x) => `${x.symbol}-${x.expand.account.owner}-${x.expand.account.exchange}`));
|