hedgequantx 1.8.7 → 1.8.8
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
|
@@ -149,7 +149,12 @@ const getContractsFromAPI = async () => {
|
|
|
149
149
|
if (projectxConn && typeof projectxConn.service.getContracts === 'function') {
|
|
150
150
|
const result = await projectxConn.service.getContracts();
|
|
151
151
|
if (result.success && result.contracts?.length > 0) {
|
|
152
|
-
|
|
152
|
+
// Normalize contract structure - API returns { name: "ESH6", description: "E-mini S&P 500..." }
|
|
153
|
+
cachedContracts = result.contracts.map(c => ({
|
|
154
|
+
...c,
|
|
155
|
+
symbol: c.name || c.symbol,
|
|
156
|
+
name: c.description || c.name || c.symbol
|
|
157
|
+
}));
|
|
153
158
|
return cachedContracts;
|
|
154
159
|
}
|
|
155
160
|
}
|
|
@@ -162,6 +167,8 @@ const getContractsFromAPI = async () => {
|
|
|
162
167
|
*/
|
|
163
168
|
const selectSymbol = async (service, label) => {
|
|
164
169
|
try {
|
|
170
|
+
const spinner = ora({ text: 'Loading symbols...', color: 'yellow' }).start();
|
|
171
|
+
|
|
165
172
|
// Always use contracts from ProjectX API for consistency
|
|
166
173
|
let contracts = await getContractsFromAPI();
|
|
167
174
|
|
|
@@ -174,15 +181,18 @@ const selectSymbol = async (service, label) => {
|
|
|
174
181
|
}
|
|
175
182
|
|
|
176
183
|
if (!contracts || contracts.length === 0) {
|
|
177
|
-
|
|
184
|
+
spinner.fail('No contracts available');
|
|
178
185
|
return null;
|
|
179
186
|
}
|
|
180
187
|
|
|
188
|
+
spinner.succeed(`Found ${contracts.length} contracts`);
|
|
189
|
+
|
|
181
190
|
const options = contracts.map(c => ({ label: c.name || c.symbol, value: c }));
|
|
182
191
|
options.push({ label: '< Cancel', value: null });
|
|
183
192
|
|
|
184
193
|
return await prompts.selectOption(`${label} Symbol:`, options);
|
|
185
194
|
} catch (e) {
|
|
195
|
+
console.log(chalk.red(' Error loading contracts'));
|
|
186
196
|
return null;
|
|
187
197
|
}
|
|
188
198
|
};
|
package/src/utils/prompts.js
CHANGED
|
@@ -54,16 +54,21 @@ const passwordInput = async (message) => {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* Confirm
|
|
57
|
+
* Confirm - arrow keys selection
|
|
58
58
|
*/
|
|
59
59
|
const confirmPrompt = async (message, defaultVal = true) => {
|
|
60
60
|
prepareStdin();
|
|
61
|
+
const choices = defaultVal
|
|
62
|
+
? [{ name: 'Yes', value: true }, { name: 'No', value: false }]
|
|
63
|
+
: [{ name: 'No', value: false }, { name: 'Yes', value: true }];
|
|
64
|
+
|
|
61
65
|
const { value } = await inquirer.prompt([{
|
|
62
|
-
type: '
|
|
66
|
+
type: 'list',
|
|
63
67
|
name: 'value',
|
|
64
68
|
message,
|
|
65
|
-
|
|
66
|
-
prefix: ''
|
|
69
|
+
choices,
|
|
70
|
+
prefix: '',
|
|
71
|
+
loop: false
|
|
67
72
|
}]);
|
|
68
73
|
return value;
|
|
69
74
|
};
|