@gbozee/ultimate 0.0.2-71 → 0.0.2-73

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.
@@ -506,6 +506,7 @@ export declare class Strategy {
506
506
  generateOppositeTrades(payload: {
507
507
  kind: "long" | "short";
508
508
  risk_factor?: number;
509
+ avg_entry?: number;
509
510
  }): {
510
511
  avg: {
511
512
  entry: number;
@@ -2040,8 +2040,8 @@ class Strategy {
2040
2040
  return result;
2041
2041
  }
2042
2042
  generateOppositeTrades(payload) {
2043
- const { kind, risk_factor = 0.5 } = payload;
2044
- const entry = this.position[kind].entry;
2043
+ const { kind, risk_factor = 0.5, avg_entry } = payload;
2044
+ const entry = avg_entry || this.position[kind].entry;
2045
2045
  const stop = this.tp(kind);
2046
2046
  const risk = this.pnl(kind) * risk_factor;
2047
2047
  const risk_reward = getRiskReward({
package/dist/index.cjs CHANGED
@@ -3973,7 +3973,7 @@ var require_util = __commonJS((exports2) => {
3973
3973
  }
3974
3974
  return value;
3975
3975
  };
3976
- })(util4 = exports2.util || (exports2.util = {}));
3976
+ })(util4 || (exports2.util = util4 = {}));
3977
3977
  var objectUtil2;
3978
3978
  (function(objectUtil3) {
3979
3979
  objectUtil3.mergeShapes = (first, second) => {
@@ -3982,7 +3982,7 @@ var require_util = __commonJS((exports2) => {
3982
3982
  ...second
3983
3983
  };
3984
3984
  };
3985
- })(objectUtil2 = exports2.objectUtil || (exports2.objectUtil = {}));
3985
+ })(objectUtil2 || (exports2.objectUtil = objectUtil2 = {}));
3986
3986
  exports2.ZodParsedType = util4.arrayToEnum([
3987
3987
  "string",
3988
3988
  "nan",
@@ -4079,6 +4079,9 @@ var require_ZodError = __commonJS((exports2) => {
4079
4079
  exports2.quotelessJson = quotelessJson2;
4080
4080
 
4081
4081
  class ZodError2 extends Error {
4082
+ get errors() {
4083
+ return this.issues;
4084
+ }
4082
4085
  constructor(issues) {
4083
4086
  super();
4084
4087
  this.issues = [];
@@ -4097,9 +4100,6 @@ var require_ZodError = __commonJS((exports2) => {
4097
4100
  this.name = "ZodError";
4098
4101
  this.issues = issues;
4099
4102
  }
4100
- get errors() {
4101
- return this.issues;
4102
- }
4103
4103
  format(_mapper) {
4104
4104
  const mapper = _mapper || function(issue) {
4105
4105
  return issue.message;
@@ -4438,7 +4438,7 @@ var require_errorUtil = __commonJS((exports2) => {
4438
4438
  (function(errorUtil3) {
4439
4439
  errorUtil3.errToObj = (message2) => typeof message2 === "string" ? { message: message2 } : message2 || {};
4440
4440
  errorUtil3.toString = (message2) => typeof message2 === "string" ? message2 : message2 === null || message2 === undefined ? undefined : message2.message;
4441
- })(errorUtil2 = exports2.errorUtil || (exports2.errorUtil = {}));
4441
+ })(errorUtil2 || (exports2.errorUtil = errorUtil2 = {}));
4442
4442
  });
4443
4443
 
4444
4444
  // node_modules/zod/lib/types.js
@@ -4534,34 +4534,6 @@ var require_types = __commonJS((exports2) => {
4534
4534
  }
4535
4535
 
4536
4536
  class ZodType2 {
4537
- constructor(def) {
4538
- this.spa = this.safeParseAsync;
4539
- this._def = def;
4540
- this.parse = this.parse.bind(this);
4541
- this.safeParse = this.safeParse.bind(this);
4542
- this.parseAsync = this.parseAsync.bind(this);
4543
- this.safeParseAsync = this.safeParseAsync.bind(this);
4544
- this.spa = this.spa.bind(this);
4545
- this.refine = this.refine.bind(this);
4546
- this.refinement = this.refinement.bind(this);
4547
- this.superRefine = this.superRefine.bind(this);
4548
- this.optional = this.optional.bind(this);
4549
- this.nullable = this.nullable.bind(this);
4550
- this.nullish = this.nullish.bind(this);
4551
- this.array = this.array.bind(this);
4552
- this.promise = this.promise.bind(this);
4553
- this.or = this.or.bind(this);
4554
- this.and = this.and.bind(this);
4555
- this.transform = this.transform.bind(this);
4556
- this.brand = this.brand.bind(this);
4557
- this.default = this.default.bind(this);
4558
- this.catch = this.catch.bind(this);
4559
- this.describe = this.describe.bind(this);
4560
- this.pipe = this.pipe.bind(this);
4561
- this.readonly = this.readonly.bind(this);
4562
- this.isNullable = this.isNullable.bind(this);
4563
- this.isOptional = this.isOptional.bind(this);
4564
- }
4565
4537
  get description() {
4566
4538
  return this._def.description;
4567
4539
  }
@@ -4625,6 +4597,43 @@ var require_types = __commonJS((exports2) => {
4625
4597
  const result = this._parseSync({ data, path: ctx.path, parent: ctx });
4626
4598
  return handleResult2(ctx, result);
4627
4599
  }
4600
+ "~validate"(data) {
4601
+ var _a, _b;
4602
+ const ctx = {
4603
+ common: {
4604
+ issues: [],
4605
+ async: !!this["~standard"].async
4606
+ },
4607
+ path: [],
4608
+ schemaErrorMap: this._def.errorMap,
4609
+ parent: null,
4610
+ data,
4611
+ parsedType: (0, util_1.getParsedType)(data)
4612
+ };
4613
+ if (!this["~standard"].async) {
4614
+ try {
4615
+ const result = this._parseSync({ data, path: [], parent: ctx });
4616
+ return (0, parseUtil_1.isValid)(result) ? {
4617
+ value: result.value
4618
+ } : {
4619
+ issues: ctx.common.issues
4620
+ };
4621
+ } catch (err) {
4622
+ if ((_b = (_a = err === null || err === undefined ? undefined : err.message) === null || _a === undefined ? undefined : _a.toLowerCase()) === null || _b === undefined ? undefined : _b.includes("encountered")) {
4623
+ this["~standard"].async = true;
4624
+ }
4625
+ ctx.common = {
4626
+ issues: [],
4627
+ async: true
4628
+ };
4629
+ }
4630
+ }
4631
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => (0, parseUtil_1.isValid)(result) ? {
4632
+ value: result.value
4633
+ } : {
4634
+ issues: ctx.common.issues
4635
+ });
4636
+ }
4628
4637
  async parseAsync(data, params) {
4629
4638
  const result = await this.safeParseAsync(data, params);
4630
4639
  if (result.success)
@@ -4702,6 +4711,39 @@ var require_types = __commonJS((exports2) => {
4702
4711
  superRefine(refinement) {
4703
4712
  return this._refinement(refinement);
4704
4713
  }
4714
+ constructor(def) {
4715
+ this.spa = this.safeParseAsync;
4716
+ this._def = def;
4717
+ this.parse = this.parse.bind(this);
4718
+ this.safeParse = this.safeParse.bind(this);
4719
+ this.parseAsync = this.parseAsync.bind(this);
4720
+ this.safeParseAsync = this.safeParseAsync.bind(this);
4721
+ this.spa = this.spa.bind(this);
4722
+ this.refine = this.refine.bind(this);
4723
+ this.refinement = this.refinement.bind(this);
4724
+ this.superRefine = this.superRefine.bind(this);
4725
+ this.optional = this.optional.bind(this);
4726
+ this.nullable = this.nullable.bind(this);
4727
+ this.nullish = this.nullish.bind(this);
4728
+ this.array = this.array.bind(this);
4729
+ this.promise = this.promise.bind(this);
4730
+ this.or = this.or.bind(this);
4731
+ this.and = this.and.bind(this);
4732
+ this.transform = this.transform.bind(this);
4733
+ this.brand = this.brand.bind(this);
4734
+ this.default = this.default.bind(this);
4735
+ this.catch = this.catch.bind(this);
4736
+ this.describe = this.describe.bind(this);
4737
+ this.pipe = this.pipe.bind(this);
4738
+ this.readonly = this.readonly.bind(this);
4739
+ this.isNullable = this.isNullable.bind(this);
4740
+ this.isOptional = this.isOptional.bind(this);
4741
+ this["~standard"] = {
4742
+ version: 1,
4743
+ vendor: "zod",
4744
+ validate: (data) => this["~validate"](data)
4745
+ };
4746
+ }
4705
4747
  optional() {
4706
4748
  return ZodOptional2.create(this, this._def);
4707
4749
  }
@@ -4712,7 +4754,7 @@ var require_types = __commonJS((exports2) => {
4712
4754
  return this.nullable().optional();
4713
4755
  }
4714
4756
  array() {
4715
- return ZodArray2.create(this, this._def);
4757
+ return ZodArray2.create(this);
4716
4758
  }
4717
4759
  promise() {
4718
4760
  return ZodPromise2.create(this, this._def);
@@ -4781,26 +4823,31 @@ var require_types = __commonJS((exports2) => {
4781
4823
  exports2.ZodSchema = ZodType2;
4782
4824
  var cuidRegex2 = /^c[^\s-]{8,}$/i;
4783
4825
  var cuid2Regex2 = /^[0-9a-z]+$/;
4784
- var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/;
4826
+ var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
4785
4827
  var uuidRegex2 = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
4786
4828
  var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
4829
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
4787
4830
  var durationRegex2 = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
4788
4831
  var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
4789
4832
  var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
4790
4833
  var emojiRegex2;
4791
4834
  var ipv4Regex2 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
4792
- var ipv6Regex2 = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
4835
+ var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
4836
+ var ipv6Regex2 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
4837
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
4793
4838
  var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
4839
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
4794
4840
  var dateRegexSource2 = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
4795
4841
  var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
4796
4842
  function timeRegexSource2(args) {
4797
- let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
4843
+ let secondsRegexSource = `[0-5]\\d`;
4798
4844
  if (args.precision) {
4799
- regex = `${regex}\\.\\d{${args.precision}}`;
4845
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
4800
4846
  } else if (args.precision == null) {
4801
- regex = `${regex}(\\.\\d+)?`;
4847
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
4802
4848
  }
4803
- return regex;
4849
+ const secondsQuantifier = args.precision ? "+" : "?";
4850
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
4804
4851
  }
4805
4852
  function timeRegex2(args) {
4806
4853
  return new RegExp(`^${timeRegexSource2(args)}$`);
@@ -4824,6 +4871,33 @@ var require_types = __commonJS((exports2) => {
4824
4871
  }
4825
4872
  return false;
4826
4873
  }
4874
+ function isValidJWT(jwt, alg) {
4875
+ if (!jwtRegex.test(jwt))
4876
+ return false;
4877
+ try {
4878
+ const [header] = jwt.split(".");
4879
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
4880
+ const decoded = JSON.parse(atob(base64));
4881
+ if (typeof decoded !== "object" || decoded === null)
4882
+ return false;
4883
+ if (!decoded.typ || !decoded.alg)
4884
+ return false;
4885
+ if (alg && decoded.alg !== alg)
4886
+ return false;
4887
+ return true;
4888
+ } catch (_a) {
4889
+ return false;
4890
+ }
4891
+ }
4892
+ function isValidCidr(ip, version) {
4893
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
4894
+ return true;
4895
+ }
4896
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
4897
+ return true;
4898
+ }
4899
+ return false;
4900
+ }
4827
4901
 
4828
4902
  class ZodString2 extends ZodType2 {
4829
4903
  _parse(input) {
@@ -5081,6 +5155,26 @@ var require_types = __commonJS((exports2) => {
5081
5155
  });
5082
5156
  status.dirty();
5083
5157
  }
5158
+ } else if (check2.kind === "jwt") {
5159
+ if (!isValidJWT(input.data, check2.alg)) {
5160
+ ctx = this._getOrReturnCtx(input, ctx);
5161
+ (0, parseUtil_1.addIssueToContext)(ctx, {
5162
+ validation: "jwt",
5163
+ code: ZodError_1.ZodIssueCode.invalid_string,
5164
+ message: check2.message
5165
+ });
5166
+ status.dirty();
5167
+ }
5168
+ } else if (check2.kind === "cidr") {
5169
+ if (!isValidCidr(input.data, check2.version)) {
5170
+ ctx = this._getOrReturnCtx(input, ctx);
5171
+ (0, parseUtil_1.addIssueToContext)(ctx, {
5172
+ validation: "cidr",
5173
+ code: ZodError_1.ZodIssueCode.invalid_string,
5174
+ message: check2.message
5175
+ });
5176
+ status.dirty();
5177
+ }
5084
5178
  } else if (check2.kind === "base64") {
5085
5179
  if (!base64Regex2.test(input.data)) {
5086
5180
  ctx = this._getOrReturnCtx(input, ctx);
@@ -5091,6 +5185,16 @@ var require_types = __commonJS((exports2) => {
5091
5185
  });
5092
5186
  status.dirty();
5093
5187
  }
5188
+ } else if (check2.kind === "base64url") {
5189
+ if (!base64urlRegex.test(input.data)) {
5190
+ ctx = this._getOrReturnCtx(input, ctx);
5191
+ (0, parseUtil_1.addIssueToContext)(ctx, {
5192
+ validation: "base64url",
5193
+ code: ZodError_1.ZodIssueCode.invalid_string,
5194
+ message: check2.message
5195
+ });
5196
+ status.dirty();
5197
+ }
5094
5198
  } else {
5095
5199
  util_1.util.assertNever(check2);
5096
5200
  }
@@ -5137,9 +5241,21 @@ var require_types = __commonJS((exports2) => {
5137
5241
  base64(message2) {
5138
5242
  return this._addCheck({ kind: "base64", ...errorUtil_1.errorUtil.errToObj(message2) });
5139
5243
  }
5244
+ base64url(message2) {
5245
+ return this._addCheck({
5246
+ kind: "base64url",
5247
+ ...errorUtil_1.errorUtil.errToObj(message2)
5248
+ });
5249
+ }
5250
+ jwt(options) {
5251
+ return this._addCheck({ kind: "jwt", ...errorUtil_1.errorUtil.errToObj(options) });
5252
+ }
5140
5253
  ip(options) {
5141
5254
  return this._addCheck({ kind: "ip", ...errorUtil_1.errorUtil.errToObj(options) });
5142
5255
  }
5256
+ cidr(options) {
5257
+ return this._addCheck({ kind: "cidr", ...errorUtil_1.errorUtil.errToObj(options) });
5258
+ }
5143
5259
  datetime(options) {
5144
5260
  var _a, _b;
5145
5261
  if (typeof options === "string") {
@@ -5289,9 +5405,15 @@ var require_types = __commonJS((exports2) => {
5289
5405
  get isIP() {
5290
5406
  return !!this._def.checks.find((ch) => ch.kind === "ip");
5291
5407
  }
5408
+ get isCIDR() {
5409
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
5410
+ }
5292
5411
  get isBase64() {
5293
5412
  return !!this._def.checks.find((ch) => ch.kind === "base64");
5294
5413
  }
5414
+ get isBase64url() {
5415
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
5416
+ }
5295
5417
  get minLength() {
5296
5418
  let min = null;
5297
5419
  for (const ch of this._def.checks) {
@@ -5573,17 +5695,15 @@ var require_types = __commonJS((exports2) => {
5573
5695
  }
5574
5696
  _parse(input) {
5575
5697
  if (this._def.coerce) {
5576
- input.data = BigInt(input.data);
5698
+ try {
5699
+ input.data = BigInt(input.data);
5700
+ } catch (_a) {
5701
+ return this._getInvalidInput(input);
5702
+ }
5577
5703
  }
5578
5704
  const parsedType = this._getType(input);
5579
5705
  if (parsedType !== util_1.ZodParsedType.bigint) {
5580
- const ctx2 = this._getOrReturnCtx(input);
5581
- (0, parseUtil_1.addIssueToContext)(ctx2, {
5582
- code: ZodError_1.ZodIssueCode.invalid_type,
5583
- expected: util_1.ZodParsedType.bigint,
5584
- received: ctx2.parsedType
5585
- });
5586
- return parseUtil_1.INVALID;
5706
+ return this._getInvalidInput(input);
5587
5707
  }
5588
5708
  let ctx = undefined;
5589
5709
  const status = new parseUtil_1.ParseStatus;
@@ -5630,6 +5750,15 @@ var require_types = __commonJS((exports2) => {
5630
5750
  }
5631
5751
  return { status: status.value, value: input.data };
5632
5752
  }
5753
+ _getInvalidInput(input) {
5754
+ const ctx = this._getOrReturnCtx(input);
5755
+ (0, parseUtil_1.addIssueToContext)(ctx, {
5756
+ code: ZodError_1.ZodIssueCode.invalid_type,
5757
+ expected: util_1.ZodParsedType.bigint,
5758
+ received: ctx.parsedType
5759
+ });
5760
+ return parseUtil_1.INVALID;
5761
+ }
5633
5762
  gte(value, message2) {
5634
5763
  return this.setLimit("min", value, true, errorUtil_1.errorUtil.toString(message2));
5635
5764
  }
@@ -7668,16 +7797,32 @@ var require_types = __commonJS((exports2) => {
7668
7797
  ...processCreateParams2(params)
7669
7798
  });
7670
7799
  };
7671
- function custom2(check2, params = {}, fatal) {
7800
+ function cleanParams(params, data) {
7801
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
7802
+ const p2 = typeof p === "string" ? { message: p } : p;
7803
+ return p2;
7804
+ }
7805
+ function custom2(check2, _params = {}, fatal) {
7672
7806
  if (check2)
7673
7807
  return ZodAny2.create().superRefine((data, ctx) => {
7674
7808
  var _a, _b;
7675
- if (!check2(data)) {
7676
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
7677
- const _fatal = (_b = (_a = p.fatal) !== null && _a !== undefined ? _a : fatal) !== null && _b !== undefined ? _b : true;
7678
- const p2 = typeof p === "string" ? { message: p } : p;
7679
- ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
7809
+ const r = check2(data);
7810
+ if (r instanceof Promise) {
7811
+ return r.then((r2) => {
7812
+ var _a2, _b2;
7813
+ if (!r2) {
7814
+ const params = cleanParams(_params, data);
7815
+ const _fatal = (_b2 = (_a2 = params.fatal) !== null && _a2 !== undefined ? _a2 : fatal) !== null && _b2 !== undefined ? _b2 : true;
7816
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
7817
+ }
7818
+ });
7680
7819
  }
7820
+ if (!r) {
7821
+ const params = cleanParams(_params, data);
7822
+ const _fatal = (_b = (_a = params.fatal) !== null && _a !== undefined ? _a : fatal) !== null && _b !== undefined ? _b : true;
7823
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
7824
+ }
7825
+ return;
7681
7826
  });
7682
7827
  return ZodAny2.create();
7683
7828
  }
@@ -7723,7 +7868,7 @@ var require_types = __commonJS((exports2) => {
7723
7868
  ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
7724
7869
  ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
7725
7870
  ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
7726
- })(ZodFirstPartyTypeKind2 = exports2.ZodFirstPartyTypeKind || (exports2.ZodFirstPartyTypeKind = {}));
7871
+ })(ZodFirstPartyTypeKind2 || (exports2.ZodFirstPartyTypeKind = ZodFirstPartyTypeKind2 = {}));
7727
7872
  var instanceOfType2 = (cls, params = {
7728
7873
  message: `Input not instance of ${cls.name}`
7729
7874
  }) => custom2((data) => data instanceof cls, params);
@@ -7821,9 +7966,13 @@ var require_external = __commonJS((exports2) => {
7821
7966
  var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
7822
7967
  if (k2 === undefined)
7823
7968
  k2 = k;
7824
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
7825
- return m[k];
7826
- } });
7969
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7970
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7971
+ desc = { enumerable: true, get: function() {
7972
+ return m[k];
7973
+ } };
7974
+ }
7975
+ Object.defineProperty(o, k2, desc);
7827
7976
  } : function(o, m, k, k2) {
7828
7977
  if (k2 === undefined)
7829
7978
  k2 = k;
@@ -7848,9 +7997,13 @@ var require_lib = __commonJS((exports2) => {
7848
7997
  var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
7849
7998
  if (k2 === undefined)
7850
7999
  k2 = k;
7851
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
7852
- return m[k];
7853
- } });
8000
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8001
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8002
+ desc = { enumerable: true, get: function() {
8003
+ return m[k];
8004
+ } };
8005
+ }
8006
+ Object.defineProperty(o, k2, desc);
7854
8007
  } : function(o, m, k, k2) {
7855
8008
  if (k2 === undefined)
7856
8009
  k2 = k;
@@ -16513,7 +16666,7 @@ var require_combined_stream = __commonJS((exports2, module2) => {
16513
16666
  };
16514
16667
  });
16515
16668
 
16516
- // node_modules/mime-db/db.json
16669
+ // node_modules/form-data/node_modules/mime-types/node_modules/mime-db/db.json
16517
16670
  var require_db = __commonJS((exports2, module2) => {
16518
16671
  module2.exports = {
16519
16672
  "application/1d-interleaved-parityfec": {
@@ -25036,7 +25189,7 @@ var require_db = __commonJS((exports2, module2) => {
25036
25189
  };
25037
25190
  });
25038
25191
 
25039
- // node_modules/mime-db/index.js
25192
+ // node_modules/form-data/node_modules/mime-types/node_modules/mime-db/index.js
25040
25193
  var require_mime_db = __commonJS((exports2, module2) => {
25041
25194
  /*!
25042
25195
  * mime-db
@@ -25047,7 +25200,7 @@ var require_mime_db = __commonJS((exports2, module2) => {
25047
25200
  module2.exports = require_db();
25048
25201
  });
25049
25202
 
25050
- // node_modules/mime-types/index.js
25203
+ // node_modules/form-data/node_modules/mime-types/index.js
25051
25204
  var require_mime_types = __commonJS((exports2) => {
25052
25205
  /*!
25053
25206
  * mime-types
@@ -41770,7 +41923,7 @@ __export(exports_app, {
41770
41923
  App: () => App
41771
41924
  });
41772
41925
 
41773
- // node_modules/zod/lib/index.mjs
41926
+ // node_modules/@trigger.dev/core/node_modules/zod/lib/index.mjs
41774
41927
  var util;
41775
41928
  (function(util2) {
41776
41929
  util2.assertEqual = (val) => val;
@@ -53947,8 +54100,8 @@ class Strategy {
53947
54100
  return result;
53948
54101
  }
53949
54102
  generateOppositeTrades(payload) {
53950
- const { kind, risk_factor = 0.5 } = payload;
53951
- const entry = this.position[kind].entry;
54103
+ const { kind, risk_factor = 0.5, avg_entry } = payload;
54104
+ const entry = avg_entry || this.position[kind].entry;
53952
54105
  const stop = this.tp(kind);
53953
54106
  const risk = this.pnl(kind) * risk_factor;
53954
54107
  const risk_reward = getRiskReward({
package/dist/index.d.ts CHANGED
@@ -632,6 +632,7 @@ export declare class Strategy {
632
632
  generateOppositeTrades(payload: {
633
633
  kind: "long" | "short";
634
634
  risk_factor?: number;
635
+ avg_entry?: number;
635
636
  }): {
636
637
  avg: {
637
638
  entry: number;