hedgequantx 1.2.36 → 1.2.38

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": "1.2.36",
3
+ "version": "1.2.38",
4
4
  "description": "Prop Futures Algo Trading CLI - Connect to Topstep, Alpha Futures, and other prop firms",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -70,21 +70,22 @@ class RithmicService extends EventEmitter {
70
70
  // Login
71
71
  return new Promise((resolve, reject) => {
72
72
  const timeout = setTimeout(() => {
73
- reject(new Error('Login timeout'));
74
- }, 15000);
73
+ resolve({ success: false, error: 'Login timeout - server did not respond' });
74
+ }, 30000);
75
75
 
76
76
  this.orderConn.once('loggedIn', async (data) => {
77
77
  clearTimeout(timeout);
78
78
  this.loginInfo = data;
79
- this.user = { userName: username };
79
+ this.user = { userName: username, fcmId: data.fcmId, ibId: data.ibId };
80
80
 
81
+ // Try to get accounts but don't fail if it doesn't work
81
82
  try {
82
- // Get accounts
83
83
  await this.fetchAccounts();
84
- resolve({ success: true });
85
84
  } catch (e) {
86
- resolve({ success: false, error: e.message });
85
+ // Accounts fetch failed, but login succeeded
86
+ console.log('Note: Could not fetch accounts');
87
87
  }
88
+ resolve({ success: true });
88
89
  });
89
90
 
90
91
  this.orderConn.once('loginFailed', (data) => {
@@ -215,7 +216,7 @@ class RithmicService extends EventEmitter {
215
216
  await this.fetchAccounts();
216
217
  }
217
218
 
218
- const tradingAccounts = this.accounts.map((acc, index) => {
219
+ let tradingAccounts = this.accounts.map((acc, index) => {
219
220
  const pnl = this.accountPnL.get(acc.accountId) || {};
220
221
  const balance = parseFloat(pnl.accountBalance || pnl.marginBalance || pnl.cashOnHand || 0) || this.propfirm.defaultBalance;
221
222
  const startingBalance = this.propfirm.defaultBalance;
@@ -235,6 +236,23 @@ class RithmicService extends EventEmitter {
235
236
  };
236
237
  });
237
238
 
239
+ // If no accounts but user is logged in, create a default account from login info
240
+ if (tradingAccounts.length === 0 && this.user) {
241
+ const userName = this.user.userName || 'Unknown';
242
+ tradingAccounts = [{
243
+ accountId: this.hashAccountId(userName),
244
+ rithmicAccountId: userName,
245
+ accountName: userName,
246
+ name: userName,
247
+ balance: this.propfirm.defaultBalance,
248
+ startingBalance: this.propfirm.defaultBalance,
249
+ profitAndLoss: 0,
250
+ status: 0, // Active
251
+ platform: 'Rithmic',
252
+ propfirm: this.propfirm.name,
253
+ }];
254
+ }
255
+
238
256
  return { success: true, accounts: tradingAccounts };
239
257
  }
240
258