@polymarbot/shared 0.5.1 → 0.5.3
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/package.json
CHANGED
|
@@ -120,6 +120,10 @@ function normalizeStrategy(config, options = {}) {
|
|
|
120
120
|
if (!config || !Array.isArray(config) || config.length === 0) {
|
|
121
121
|
return [];
|
|
122
122
|
}
|
|
123
|
+
const totalBuySize = config.filter((step) => step.side === "BUY" /* BUY */).reduce((sum, step) => sum + step.size, 0);
|
|
124
|
+
if (totalBuySize <= 0) {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
123
127
|
const normalizeOptions = {
|
|
124
128
|
minPrice: options.minPrice ?? 0.01,
|
|
125
129
|
minSize: options.minSize ?? 5
|
|
@@ -138,6 +142,11 @@ function normalizeStrategy(config, options = {}) {
|
|
|
138
142
|
normalized.push(normalizedStep);
|
|
139
143
|
}
|
|
140
144
|
});
|
|
145
|
+
for (const step of normalized) {
|
|
146
|
+
if (step.side === "SELL" /* SELL */ && step.size > totalBuySize) {
|
|
147
|
+
step.size = totalBuySize;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
141
150
|
return normalized;
|
|
142
151
|
}
|
|
143
152
|
function hasTradeStepsBuy(config) {
|
|
@@ -96,6 +96,10 @@ function normalizeStrategy(config, options = {}) {
|
|
|
96
96
|
if (!config || !Array.isArray(config) || config.length === 0) {
|
|
97
97
|
return [];
|
|
98
98
|
}
|
|
99
|
+
const totalBuySize = config.filter((step) => step.side === "BUY" /* BUY */).reduce((sum, step) => sum + step.size, 0);
|
|
100
|
+
if (totalBuySize <= 0) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
99
103
|
const normalizeOptions = {
|
|
100
104
|
minPrice: options.minPrice ?? 0.01,
|
|
101
105
|
minSize: options.minSize ?? 5
|
|
@@ -114,6 +118,11 @@ function normalizeStrategy(config, options = {}) {
|
|
|
114
118
|
normalized.push(normalizedStep);
|
|
115
119
|
}
|
|
116
120
|
});
|
|
121
|
+
for (const step of normalized) {
|
|
122
|
+
if (step.side === "SELL" /* SELL */ && step.size > totalBuySize) {
|
|
123
|
+
step.size = totalBuySize;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
117
126
|
return normalized;
|
|
118
127
|
}
|
|
119
128
|
function hasTradeStepsBuy(config) {
|