hedgequantx 2.9.183 → 2.9.185

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.9.183",
3
+ "version": "2.9.185",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -112,12 +112,18 @@ const connections = {
112
112
  },
113
113
 
114
114
  /**
115
- * Sanitize account data
115
+ * Sanitize account data for caching
116
+ * IMPORTANT: Keep rithmicAccountId for PnL lookups
116
117
  */
117
118
  _sanitizeAccount(acc) {
118
- if (!acc || typeof acc !== 'object' || !acc.accountId) return null;
119
+ if (!acc || typeof acc !== 'object') return null;
120
+
121
+ // Get the real Rithmic account ID (text like "APEX-130042-63")
122
+ const rithmicId = acc.rithmicAccountId || acc.accountId;
123
+ if (!rithmicId) return null;
124
+
119
125
  return {
120
- accountId: String(acc.accountId),
126
+ accountId: rithmicId, // Use the real Rithmic ID, not the hash
121
127
  fcmId: acc.fcmId ? String(acc.fcmId) : undefined,
122
128
  ibId: acc.ibId ? String(acc.ibId) : undefined,
123
129
  accountName: acc.accountName ? String(acc.accountName) : undefined,
@@ -152,9 +158,10 @@ const connections = {
152
158
  */
153
159
  async restoreFromStorage() {
154
160
  const sessions = storage.load();
155
- const rithmicSessions = sessions.filter(s => s.type === 'rithmic');
161
+ const rithmicSessions = sessions.filter(s => s.type === 'rithmic' && s.credentials);
156
162
 
157
163
  if (!rithmicSessions.length) {
164
+ log.debug('No saved sessions to restore');
158
165
  return false;
159
166
  }
160
167
 
@@ -162,9 +169,12 @@ const connections = {
162
169
 
163
170
  for (const session of rithmicSessions) {
164
171
  try {
165
- await this._restoreSession(session);
172
+ const success = await this._restoreSession(session);
173
+ if (!success) {
174
+ log.warn('Session restore returned false', { propfirm: session.propfirm });
175
+ }
166
176
  } catch (err) {
167
- log.warn('Failed to restore session', { error: err.message });
177
+ log.error('Failed to restore session', { propfirm: session.propfirm, error: err.message });
168
178
  }
169
179
  }
170
180
 
@@ -173,12 +183,13 @@ const connections = {
173
183
 
174
184
  /**
175
185
  * Restore a single session using direct RithmicService
186
+ * @returns {boolean} true if restore succeeded
176
187
  */
177
188
  async _restoreSession(session) {
178
189
  const { type, propfirm, propfirmKey } = session;
179
190
 
180
191
  if (type !== 'rithmic' || !session.credentials) {
181
- return;
192
+ return false;
182
193
  }
183
194
 
184
195
  const Service = loadRithmicService();
@@ -193,6 +204,13 @@ const connections = {
193
204
  if (validAccounts.length === 0) validAccounts = null;
194
205
  }
195
206
 
207
+ log.debug('Restoring session', {
208
+ propfirm,
209
+ propfirmKey,
210
+ hasCredentials: !!session.credentials,
211
+ cachedAccounts: validAccounts?.length || 0
212
+ });
213
+
196
214
  // Login with cached accounts to avoid Rithmic API limit
197
215
  const loginOptions = validAccounts
198
216
  ? { skipFetchAccounts: true, cachedAccounts: validAccounts }
@@ -212,9 +230,16 @@ const connections = {
212
230
  propfirmKey,
213
231
  connectedAt: new Date(),
214
232
  });
215
- log.info('Session restored', { propfirm, accounts: service.accounts?.length || 0 });
233
+ log.info('Session restored', {
234
+ propfirm,
235
+ accounts: service.accounts?.length || 0,
236
+ hasPnL: !!service.pnlConn,
237
+ hasOrder: !!service.orderConn
238
+ });
239
+ return true;
216
240
  } else {
217
241
  log.warn('Session restore failed', { propfirm, error: result.error });
242
+ return false;
218
243
  }
219
244
  },
220
245