adaptic-backend 1.0.75 → 1.0.77

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.
Files changed (57) hide show
  1. package/Account.cjs +264 -190
  2. package/Action.cjs +594 -524
  3. package/Alert.cjs +352 -278
  4. package/AlpacaAccount.cjs +1197 -1021
  5. package/Asset.cjs +485 -368
  6. package/Authenticator.cjs +285 -211
  7. package/Customer.cjs +268 -190
  8. package/NewsArticle.cjs +233 -212
  9. package/NewsArticleAssetSentiment.cjs +354 -290
  10. package/Order.cjs +694 -541
  11. package/Position.cjs +621 -488
  12. package/Session.cjs +288 -214
  13. package/Trade.cjs +767 -613
  14. package/User.cjs +410 -309
  15. package/package.json +1 -1
  16. package/server/Account.d.ts.map +1 -1
  17. package/server/Account.js.map +1 -1
  18. package/server/Account.mjs +264 -190
  19. package/server/Action.d.ts.map +1 -1
  20. package/server/Action.js.map +1 -1
  21. package/server/Action.mjs +594 -524
  22. package/server/Alert.d.ts.map +1 -1
  23. package/server/Alert.js.map +1 -1
  24. package/server/Alert.mjs +352 -278
  25. package/server/AlpacaAccount.d.ts.map +1 -1
  26. package/server/AlpacaAccount.js.map +1 -1
  27. package/server/AlpacaAccount.mjs +1197 -1021
  28. package/server/Asset.d.ts.map +1 -1
  29. package/server/Asset.js.map +1 -1
  30. package/server/Asset.mjs +485 -368
  31. package/server/Authenticator.d.ts.map +1 -1
  32. package/server/Authenticator.js.map +1 -1
  33. package/server/Authenticator.mjs +285 -211
  34. package/server/Customer.d.ts.map +1 -1
  35. package/server/Customer.js.map +1 -1
  36. package/server/Customer.mjs +268 -190
  37. package/server/NewsArticle.d.ts.map +1 -1
  38. package/server/NewsArticle.js.map +1 -1
  39. package/server/NewsArticle.mjs +233 -212
  40. package/server/NewsArticleAssetSentiment.d.ts.map +1 -1
  41. package/server/NewsArticleAssetSentiment.js.map +1 -1
  42. package/server/NewsArticleAssetSentiment.mjs +354 -290
  43. package/server/Order.d.ts.map +1 -1
  44. package/server/Order.js.map +1 -1
  45. package/server/Order.mjs +694 -541
  46. package/server/Position.d.ts.map +1 -1
  47. package/server/Position.js.map +1 -1
  48. package/server/Position.mjs +621 -488
  49. package/server/Session.d.ts.map +1 -1
  50. package/server/Session.js.map +1 -1
  51. package/server/Session.mjs +288 -214
  52. package/server/Trade.d.ts.map +1 -1
  53. package/server/Trade.js.map +1 -1
  54. package/server/Trade.mjs +767 -613
  55. package/server/User.d.ts.map +1 -1
  56. package/server/User.js.map +1 -1
  57. package/server/User.mjs +410 -309
package/Order.cjs CHANGED
@@ -299,249 +299,310 @@ exports.Order = {
299
299
  filledAt: props.filledAt !== undefined ? props.filledAt : undefined,
300
300
  filledAvgPrice: props.filledAvgPrice !== undefined ? props.filledAvgPrice : undefined,
301
301
  fee: props.fee !== undefined ? props.fee : undefined,
302
- alpacaAccount: props.alpacaAccount ? {
303
- connectOrCreate: {
304
- where: {
305
- id: props.alpacaAccount.id !== undefined ? props.alpacaAccount.id : undefined,
306
- },
307
- create: {
308
- type: props.alpacaAccount.type !== undefined ? props.alpacaAccount.type : undefined,
309
- APIKey: props.alpacaAccount.APIKey !== undefined ? props.alpacaAccount.APIKey : undefined,
310
- APISecret: props.alpacaAccount.APISecret !== undefined ? props.alpacaAccount.APISecret : undefined,
311
- configuration: props.alpacaAccount.configuration !== undefined ? props.alpacaAccount.configuration : undefined,
312
- marketOpen: props.alpacaAccount.marketOpen !== undefined ? props.alpacaAccount.marketOpen : undefined,
313
- user: props.alpacaAccount.user ? {
314
- connectOrCreate: {
315
- where: {
316
- id: props.alpacaAccount.user.id !== undefined ? props.alpacaAccount.user.id : undefined,
317
- email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
318
- name: props.alpacaAccount.user.name !== undefined ? {
319
- equals: props.alpacaAccount.user.name
320
- } : undefined,
321
- },
322
- create: {
323
- name: props.alpacaAccount.user.name !== undefined ? props.alpacaAccount.user.name : undefined,
324
- email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
325
- emailVerified: props.alpacaAccount.user.emailVerified !== undefined ? props.alpacaAccount.user.emailVerified : undefined,
326
- image: props.alpacaAccount.user.image !== undefined ? props.alpacaAccount.user.image : undefined,
327
- role: props.alpacaAccount.user.role !== undefined ? props.alpacaAccount.user.role : undefined,
328
- bio: props.alpacaAccount.user.bio !== undefined ? props.alpacaAccount.user.bio : undefined,
329
- jobTitle: props.alpacaAccount.user.jobTitle !== undefined ? props.alpacaAccount.user.jobTitle : undefined,
330
- currentAccount: props.alpacaAccount.user.currentAccount !== undefined ? props.alpacaAccount.user.currentAccount : undefined,
331
- plan: props.alpacaAccount.user.plan !== undefined ? props.alpacaAccount.user.plan : undefined,
332
- },
333
- }
334
- } : undefined,
335
- trades: props.alpacaAccount.trades ? {
336
- connectOrCreate: props.alpacaAccount.trades.map((item) => ({
337
- where: {
338
- id: item.id !== undefined ? item.id : undefined,
339
- },
340
- create: {
341
- qty: item.qty !== undefined ? item.qty : undefined,
342
- price: item.price !== undefined ? item.price : undefined,
343
- total: item.total !== undefined ? item.total : undefined,
344
- signal: item.signal !== undefined ? item.signal : undefined,
345
- strategy: item.strategy !== undefined ? item.strategy : undefined,
346
- analysis: item.analysis !== undefined ? item.analysis : undefined,
347
- confidence: item.confidence !== undefined ? item.confidence : undefined,
348
- timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
349
- status: item.status !== undefined ? item.status : undefined,
350
- optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
351
- },
352
- }))
353
- } : undefined,
354
- positions: props.alpacaAccount.positions ? {
355
- connectOrCreate: props.alpacaAccount.positions.map((item) => ({
356
- where: {
357
- id: item.id !== undefined ? item.id : undefined,
358
- },
359
- create: {
360
- averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
361
- qty: item.qty !== undefined ? item.qty : undefined,
362
- qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
363
- marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
364
- costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
365
- unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
366
- unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
367
- unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
368
- unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
369
- currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
370
- lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
371
- changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
372
- assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
373
- },
374
- }))
375
- } : undefined,
376
- alerts: props.alpacaAccount.alerts ? {
377
- connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
378
- where: {
379
- id: item.id !== undefined ? item.id : undefined,
380
- },
381
- create: {
382
- message: item.message !== undefined ? item.message : undefined,
383
- type: item.type !== undefined ? item.type : undefined,
384
- isRead: item.isRead !== undefined ? item.isRead : undefined,
385
- },
386
- }))
387
- } : undefined,
388
- },
389
- }
390
- } : undefined,
391
- action: props.action ? {
392
- connectOrCreate: {
393
- where: {
394
- id: props.action.id !== undefined ? props.action.id : undefined,
395
- },
396
- create: {
397
- sequence: props.action.sequence !== undefined ? props.action.sequence : undefined,
398
- type: props.action.type !== undefined ? props.action.type : undefined,
399
- note: props.action.note !== undefined ? props.action.note : undefined,
400
- status: props.action.status !== undefined ? props.action.status : undefined,
401
- fee: props.action.fee !== undefined ? props.action.fee : undefined,
402
- trade: props.action.trade ? {
403
- connectOrCreate: {
404
- where: {
405
- id: props.action.trade.id !== undefined ? props.action.trade.id : undefined,
406
- },
407
- create: {
408
- qty: props.action.trade.qty !== undefined ? props.action.trade.qty : undefined,
409
- price: props.action.trade.price !== undefined ? props.action.trade.price : undefined,
410
- total: props.action.trade.total !== undefined ? props.action.trade.total : undefined,
411
- signal: props.action.trade.signal !== undefined ? props.action.trade.signal : undefined,
412
- strategy: props.action.trade.strategy !== undefined ? props.action.trade.strategy : undefined,
413
- analysis: props.action.trade.analysis !== undefined ? props.action.trade.analysis : undefined,
414
- confidence: props.action.trade.confidence !== undefined ? props.action.trade.confidence : undefined,
415
- timestamp: props.action.trade.timestamp !== undefined ? props.action.trade.timestamp : undefined,
416
- status: props.action.trade.status !== undefined ? props.action.trade.status : undefined,
417
- optionContractType: props.action.trade.optionContractType !== undefined ? props.action.trade.optionContractType : undefined,
418
- },
419
- }
420
- } : undefined,
421
- },
422
- }
423
- } : undefined,
424
- asset: props.asset ? {
425
- connectOrCreate: {
426
- where: {
427
- id: props.asset.id !== undefined ? props.asset.id : undefined,
428
- symbol: props.asset.symbol !== undefined ? props.asset.symbol : undefined,
429
- name: props.asset.name !== undefined ? props.asset.name : undefined,
430
- },
431
- create: {
432
- symbol: props.asset.symbol !== undefined ? props.asset.symbol : undefined,
433
- name: props.asset.name !== undefined ? props.asset.name : undefined,
434
- type: props.asset.type !== undefined ? props.asset.type : undefined,
435
- logoUrl: props.asset.logoUrl !== undefined ? props.asset.logoUrl : undefined,
436
- description: props.asset.description !== undefined ? props.asset.description : undefined,
437
- cik: props.asset.cik !== undefined ? props.asset.cik : undefined,
438
- exchange: props.asset.exchange !== undefined ? props.asset.exchange : undefined,
439
- currency: props.asset.currency !== undefined ? props.asset.currency : undefined,
440
- country: props.asset.country !== undefined ? props.asset.country : undefined,
441
- sector: props.asset.sector !== undefined ? props.asset.sector : undefined,
442
- industry: props.asset.industry !== undefined ? props.asset.industry : undefined,
443
- address: props.asset.address !== undefined ? props.asset.address : undefined,
444
- officialSite: props.asset.officialSite !== undefined ? props.asset.officialSite : undefined,
445
- fiscalYearEnd: props.asset.fiscalYearEnd !== undefined ? props.asset.fiscalYearEnd : undefined,
446
- latestQuarter: props.asset.latestQuarter !== undefined ? props.asset.latestQuarter : undefined,
447
- marketCapitalization: props.asset.marketCapitalization !== undefined ? props.asset.marketCapitalization : undefined,
448
- ebitda: props.asset.ebitda !== undefined ? props.asset.ebitda : undefined,
449
- peRatio: props.asset.peRatio !== undefined ? props.asset.peRatio : undefined,
450
- pegRatio: props.asset.pegRatio !== undefined ? props.asset.pegRatio : undefined,
451
- bookValue: props.asset.bookValue !== undefined ? props.asset.bookValue : undefined,
452
- dividendPerShare: props.asset.dividendPerShare !== undefined ? props.asset.dividendPerShare : undefined,
453
- dividendYield: props.asset.dividendYield !== undefined ? props.asset.dividendYield : undefined,
454
- eps: props.asset.eps !== undefined ? props.asset.eps : undefined,
455
- revenuePerShareTTM: props.asset.revenuePerShareTTM !== undefined ? props.asset.revenuePerShareTTM : undefined,
456
- profitMargin: props.asset.profitMargin !== undefined ? props.asset.profitMargin : undefined,
457
- operatingMarginTTM: props.asset.operatingMarginTTM !== undefined ? props.asset.operatingMarginTTM : undefined,
458
- returnOnAssetsTTM: props.asset.returnOnAssetsTTM !== undefined ? props.asset.returnOnAssetsTTM : undefined,
459
- returnOnEquityTTM: props.asset.returnOnEquityTTM !== undefined ? props.asset.returnOnEquityTTM : undefined,
460
- revenueTTM: props.asset.revenueTTM !== undefined ? props.asset.revenueTTM : undefined,
461
- grossProfitTTM: props.asset.grossProfitTTM !== undefined ? props.asset.grossProfitTTM : undefined,
462
- dilutedEPSTTM: props.asset.dilutedEPSTTM !== undefined ? props.asset.dilutedEPSTTM : undefined,
463
- quarterlyEarningsGrowthYOY: props.asset.quarterlyEarningsGrowthYOY !== undefined ? props.asset.quarterlyEarningsGrowthYOY : undefined,
464
- quarterlyRevenueGrowthYOY: props.asset.quarterlyRevenueGrowthYOY !== undefined ? props.asset.quarterlyRevenueGrowthYOY : undefined,
465
- analystTargetPrice: props.asset.analystTargetPrice !== undefined ? props.asset.analystTargetPrice : undefined,
466
- analystRatingStrongBuy: props.asset.analystRatingStrongBuy !== undefined ? props.asset.analystRatingStrongBuy : undefined,
467
- analystRatingBuy: props.asset.analystRatingBuy !== undefined ? props.asset.analystRatingBuy : undefined,
468
- analystRatingHold: props.asset.analystRatingHold !== undefined ? props.asset.analystRatingHold : undefined,
469
- analystRatingSell: props.asset.analystRatingSell !== undefined ? props.asset.analystRatingSell : undefined,
470
- analystRatingStrongSell: props.asset.analystRatingStrongSell !== undefined ? props.asset.analystRatingStrongSell : undefined,
471
- trailingPE: props.asset.trailingPE !== undefined ? props.asset.trailingPE : undefined,
472
- forwardPE: props.asset.forwardPE !== undefined ? props.asset.forwardPE : undefined,
473
- priceToSalesRatioTTM: props.asset.priceToSalesRatioTTM !== undefined ? props.asset.priceToSalesRatioTTM : undefined,
474
- priceToBookRatio: props.asset.priceToBookRatio !== undefined ? props.asset.priceToBookRatio : undefined,
475
- evToRevenue: props.asset.evToRevenue !== undefined ? props.asset.evToRevenue : undefined,
476
- evToEbitda: props.asset.evToEbitda !== undefined ? props.asset.evToEbitda : undefined,
477
- beta: props.asset.beta !== undefined ? props.asset.beta : undefined,
478
- week52High: props.asset.week52High !== undefined ? props.asset.week52High : undefined,
479
- week52Low: props.asset.week52Low !== undefined ? props.asset.week52Low : undefined,
480
- day50MovingAverage: props.asset.day50MovingAverage !== undefined ? props.asset.day50MovingAverage : undefined,
481
- day200MovingAverage: props.asset.day200MovingAverage !== undefined ? props.asset.day200MovingAverage : undefined,
482
- sharesOutstanding: props.asset.sharesOutstanding !== undefined ? props.asset.sharesOutstanding : undefined,
483
- dividendDate: props.asset.dividendDate !== undefined ? props.asset.dividendDate : undefined,
484
- exDividendDate: props.asset.exDividendDate !== undefined ? props.asset.exDividendDate : undefined,
485
- sellPrice: props.asset.sellPrice !== undefined ? props.asset.sellPrice : undefined,
486
- buyPrice: props.asset.buyPrice !== undefined ? props.asset.buyPrice : undefined,
487
- trades: props.asset.trades ? {
488
- connectOrCreate: props.asset.trades.map((item) => ({
489
- where: {
490
- id: item.id !== undefined ? item.id : undefined,
491
- },
492
- create: {
493
- qty: item.qty !== undefined ? item.qty : undefined,
494
- price: item.price !== undefined ? item.price : undefined,
495
- total: item.total !== undefined ? item.total : undefined,
496
- signal: item.signal !== undefined ? item.signal : undefined,
497
- strategy: item.strategy !== undefined ? item.strategy : undefined,
498
- analysis: item.analysis !== undefined ? item.analysis : undefined,
499
- confidence: item.confidence !== undefined ? item.confidence : undefined,
500
- timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
501
- status: item.status !== undefined ? item.status : undefined,
502
- optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
503
- },
504
- }))
505
- } : undefined,
506
- positions: props.asset.positions ? {
507
- connectOrCreate: props.asset.positions.map((item) => ({
508
- where: {
509
- id: item.id !== undefined ? item.id : undefined,
510
- },
511
- create: {
512
- averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
513
- qty: item.qty !== undefined ? item.qty : undefined,
514
- qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
515
- marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
516
- costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
517
- unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
518
- unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
519
- unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
520
- unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
521
- currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
522
- lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
523
- changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
524
- assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
525
- },
526
- }))
527
- } : undefined,
528
- newsMentions: props.asset.newsMentions ? {
529
- connectOrCreate: props.asset.newsMentions.map((item) => ({
530
- where: {
531
- id: item.id !== undefined ? item.id : undefined,
532
- url: item.url !== undefined ? item.url : undefined,
533
- },
534
- create: {
535
- url: item.url !== undefined ? item.url : undefined,
536
- relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
537
- sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
538
- sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
539
- },
540
- }))
541
- } : undefined,
542
- },
543
- }
544
- } : undefined,
302
+ alpacaAccount: props.alpacaAccount ?
303
+ typeof props.alpacaAccount === 'object' && Object.keys(props.alpacaAccount).length === 1 && Object.keys(props.alpacaAccount)[0] === 'id'
304
+ ? { connect: {
305
+ id: props.alpacaAccount.id
306
+ }
307
+ }
308
+ : { connectOrCreate: {
309
+ where: {
310
+ id: props.alpacaAccount.id !== undefined ? props.alpacaAccount.id : undefined,
311
+ },
312
+ create: {
313
+ type: props.alpacaAccount.type !== undefined ? props.alpacaAccount.type : undefined,
314
+ APIKey: props.alpacaAccount.APIKey !== undefined ? props.alpacaAccount.APIKey : undefined,
315
+ APISecret: props.alpacaAccount.APISecret !== undefined ? props.alpacaAccount.APISecret : undefined,
316
+ configuration: props.alpacaAccount.configuration !== undefined ? props.alpacaAccount.configuration : undefined,
317
+ marketOpen: props.alpacaAccount.marketOpen !== undefined ? props.alpacaAccount.marketOpen : undefined,
318
+ user: props.alpacaAccount.user ?
319
+ typeof props.alpacaAccount.user === 'object' && Object.keys(props.alpacaAccount.user).length === 1 && Object.keys(props.alpacaAccount.user)[0] === 'id'
320
+ ? { connect: {
321
+ id: props.alpacaAccount.user.id
322
+ }
323
+ }
324
+ : { connectOrCreate: {
325
+ where: {
326
+ id: props.alpacaAccount.user.id !== undefined ? props.alpacaAccount.user.id : undefined,
327
+ email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
328
+ name: props.alpacaAccount.user.name !== undefined ? {
329
+ equals: props.alpacaAccount.user.name
330
+ } : undefined,
331
+ },
332
+ create: {
333
+ name: props.alpacaAccount.user.name !== undefined ? props.alpacaAccount.user.name : undefined,
334
+ email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
335
+ emailVerified: props.alpacaAccount.user.emailVerified !== undefined ? props.alpacaAccount.user.emailVerified : undefined,
336
+ image: props.alpacaAccount.user.image !== undefined ? props.alpacaAccount.user.image : undefined,
337
+ role: props.alpacaAccount.user.role !== undefined ? props.alpacaAccount.user.role : undefined,
338
+ bio: props.alpacaAccount.user.bio !== undefined ? props.alpacaAccount.user.bio : undefined,
339
+ jobTitle: props.alpacaAccount.user.jobTitle !== undefined ? props.alpacaAccount.user.jobTitle : undefined,
340
+ currentAccount: props.alpacaAccount.user.currentAccount !== undefined ? props.alpacaAccount.user.currentAccount : undefined,
341
+ plan: props.alpacaAccount.user.plan !== undefined ? props.alpacaAccount.user.plan : undefined,
342
+ },
343
+ }
344
+ } : undefined,
345
+ trades: props.alpacaAccount.trades ?
346
+ Array.isArray(props.alpacaAccount.trades) && props.alpacaAccount.trades.length > 0
347
+ ? props.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
348
+ connect: props.alpacaAccount.trades.map((item) => ({
349
+ id: item.id
350
+ }))
351
+ }
352
+ : { connectOrCreate: props.alpacaAccount.trades.map((item) => ({
353
+ where: {
354
+ id: item.id !== undefined ? item.id : undefined,
355
+ },
356
+ create: {
357
+ qty: item.qty !== undefined ? item.qty : undefined,
358
+ price: item.price !== undefined ? item.price : undefined,
359
+ total: item.total !== undefined ? item.total : undefined,
360
+ signal: item.signal !== undefined ? item.signal : undefined,
361
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
362
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
363
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
364
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
365
+ status: item.status !== undefined ? item.status : undefined,
366
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
367
+ },
368
+ }))
369
+ } : undefined,
370
+ positions: props.alpacaAccount.positions ?
371
+ Array.isArray(props.alpacaAccount.positions) && props.alpacaAccount.positions.length > 0
372
+ ? props.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
373
+ connect: props.alpacaAccount.positions.map((item) => ({
374
+ id: item.id
375
+ }))
376
+ }
377
+ : { connectOrCreate: props.alpacaAccount.positions.map((item) => ({
378
+ where: {
379
+ id: item.id !== undefined ? item.id : undefined,
380
+ },
381
+ create: {
382
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
383
+ qty: item.qty !== undefined ? item.qty : undefined,
384
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
385
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
386
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
387
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
388
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
389
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
390
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
391
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
392
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
393
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
394
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
395
+ },
396
+ }))
397
+ } : undefined,
398
+ alerts: props.alpacaAccount.alerts ?
399
+ Array.isArray(props.alpacaAccount.alerts) && props.alpacaAccount.alerts.length > 0
400
+ ? props.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
401
+ connect: props.alpacaAccount.alerts.map((item) => ({
402
+ id: item.id
403
+ }))
404
+ }
405
+ : { connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
406
+ where: {
407
+ id: item.id !== undefined ? item.id : undefined,
408
+ },
409
+ create: {
410
+ message: item.message !== undefined ? item.message : undefined,
411
+ type: item.type !== undefined ? item.type : undefined,
412
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
413
+ },
414
+ }))
415
+ } : undefined,
416
+ },
417
+ }
418
+ } : undefined,
419
+ action: props.action ?
420
+ typeof props.action === 'object' && Object.keys(props.action).length === 1 && Object.keys(props.action)[0] === 'id'
421
+ ? { connect: {
422
+ id: props.action.id
423
+ }
424
+ }
425
+ : { connectOrCreate: {
426
+ where: {
427
+ id: props.action.id !== undefined ? props.action.id : undefined,
428
+ },
429
+ create: {
430
+ sequence: props.action.sequence !== undefined ? props.action.sequence : undefined,
431
+ type: props.action.type !== undefined ? props.action.type : undefined,
432
+ note: props.action.note !== undefined ? props.action.note : undefined,
433
+ status: props.action.status !== undefined ? props.action.status : undefined,
434
+ fee: props.action.fee !== undefined ? props.action.fee : undefined,
435
+ trade: props.action.trade ?
436
+ typeof props.action.trade === 'object' && Object.keys(props.action.trade).length === 1 && Object.keys(props.action.trade)[0] === 'id'
437
+ ? { connect: {
438
+ id: props.action.trade.id
439
+ }
440
+ }
441
+ : { connectOrCreate: {
442
+ where: {
443
+ id: props.action.trade.id !== undefined ? props.action.trade.id : undefined,
444
+ },
445
+ create: {
446
+ qty: props.action.trade.qty !== undefined ? props.action.trade.qty : undefined,
447
+ price: props.action.trade.price !== undefined ? props.action.trade.price : undefined,
448
+ total: props.action.trade.total !== undefined ? props.action.trade.total : undefined,
449
+ signal: props.action.trade.signal !== undefined ? props.action.trade.signal : undefined,
450
+ strategy: props.action.trade.strategy !== undefined ? props.action.trade.strategy : undefined,
451
+ analysis: props.action.trade.analysis !== undefined ? props.action.trade.analysis : undefined,
452
+ confidence: props.action.trade.confidence !== undefined ? props.action.trade.confidence : undefined,
453
+ timestamp: props.action.trade.timestamp !== undefined ? props.action.trade.timestamp : undefined,
454
+ status: props.action.trade.status !== undefined ? props.action.trade.status : undefined,
455
+ optionContractType: props.action.trade.optionContractType !== undefined ? props.action.trade.optionContractType : undefined,
456
+ },
457
+ }
458
+ } : undefined,
459
+ },
460
+ }
461
+ } : undefined,
462
+ asset: props.asset ?
463
+ typeof props.asset === 'object' && Object.keys(props.asset).length === 1 && Object.keys(props.asset)[0] === 'id'
464
+ ? { connect: {
465
+ id: props.asset.id
466
+ }
467
+ }
468
+ : { connectOrCreate: {
469
+ where: {
470
+ id: props.asset.id !== undefined ? props.asset.id : undefined,
471
+ symbol: props.asset.symbol !== undefined ? props.asset.symbol : undefined,
472
+ name: props.asset.name !== undefined ? props.asset.name : undefined,
473
+ },
474
+ create: {
475
+ symbol: props.asset.symbol !== undefined ? props.asset.symbol : undefined,
476
+ name: props.asset.name !== undefined ? props.asset.name : undefined,
477
+ type: props.asset.type !== undefined ? props.asset.type : undefined,
478
+ logoUrl: props.asset.logoUrl !== undefined ? props.asset.logoUrl : undefined,
479
+ description: props.asset.description !== undefined ? props.asset.description : undefined,
480
+ cik: props.asset.cik !== undefined ? props.asset.cik : undefined,
481
+ exchange: props.asset.exchange !== undefined ? props.asset.exchange : undefined,
482
+ currency: props.asset.currency !== undefined ? props.asset.currency : undefined,
483
+ country: props.asset.country !== undefined ? props.asset.country : undefined,
484
+ sector: props.asset.sector !== undefined ? props.asset.sector : undefined,
485
+ industry: props.asset.industry !== undefined ? props.asset.industry : undefined,
486
+ address: props.asset.address !== undefined ? props.asset.address : undefined,
487
+ officialSite: props.asset.officialSite !== undefined ? props.asset.officialSite : undefined,
488
+ fiscalYearEnd: props.asset.fiscalYearEnd !== undefined ? props.asset.fiscalYearEnd : undefined,
489
+ latestQuarter: props.asset.latestQuarter !== undefined ? props.asset.latestQuarter : undefined,
490
+ marketCapitalization: props.asset.marketCapitalization !== undefined ? props.asset.marketCapitalization : undefined,
491
+ ebitda: props.asset.ebitda !== undefined ? props.asset.ebitda : undefined,
492
+ peRatio: props.asset.peRatio !== undefined ? props.asset.peRatio : undefined,
493
+ pegRatio: props.asset.pegRatio !== undefined ? props.asset.pegRatio : undefined,
494
+ bookValue: props.asset.bookValue !== undefined ? props.asset.bookValue : undefined,
495
+ dividendPerShare: props.asset.dividendPerShare !== undefined ? props.asset.dividendPerShare : undefined,
496
+ dividendYield: props.asset.dividendYield !== undefined ? props.asset.dividendYield : undefined,
497
+ eps: props.asset.eps !== undefined ? props.asset.eps : undefined,
498
+ revenuePerShareTTM: props.asset.revenuePerShareTTM !== undefined ? props.asset.revenuePerShareTTM : undefined,
499
+ profitMargin: props.asset.profitMargin !== undefined ? props.asset.profitMargin : undefined,
500
+ operatingMarginTTM: props.asset.operatingMarginTTM !== undefined ? props.asset.operatingMarginTTM : undefined,
501
+ returnOnAssetsTTM: props.asset.returnOnAssetsTTM !== undefined ? props.asset.returnOnAssetsTTM : undefined,
502
+ returnOnEquityTTM: props.asset.returnOnEquityTTM !== undefined ? props.asset.returnOnEquityTTM : undefined,
503
+ revenueTTM: props.asset.revenueTTM !== undefined ? props.asset.revenueTTM : undefined,
504
+ grossProfitTTM: props.asset.grossProfitTTM !== undefined ? props.asset.grossProfitTTM : undefined,
505
+ dilutedEPSTTM: props.asset.dilutedEPSTTM !== undefined ? props.asset.dilutedEPSTTM : undefined,
506
+ quarterlyEarningsGrowthYOY: props.asset.quarterlyEarningsGrowthYOY !== undefined ? props.asset.quarterlyEarningsGrowthYOY : undefined,
507
+ quarterlyRevenueGrowthYOY: props.asset.quarterlyRevenueGrowthYOY !== undefined ? props.asset.quarterlyRevenueGrowthYOY : undefined,
508
+ analystTargetPrice: props.asset.analystTargetPrice !== undefined ? props.asset.analystTargetPrice : undefined,
509
+ analystRatingStrongBuy: props.asset.analystRatingStrongBuy !== undefined ? props.asset.analystRatingStrongBuy : undefined,
510
+ analystRatingBuy: props.asset.analystRatingBuy !== undefined ? props.asset.analystRatingBuy : undefined,
511
+ analystRatingHold: props.asset.analystRatingHold !== undefined ? props.asset.analystRatingHold : undefined,
512
+ analystRatingSell: props.asset.analystRatingSell !== undefined ? props.asset.analystRatingSell : undefined,
513
+ analystRatingStrongSell: props.asset.analystRatingStrongSell !== undefined ? props.asset.analystRatingStrongSell : undefined,
514
+ trailingPE: props.asset.trailingPE !== undefined ? props.asset.trailingPE : undefined,
515
+ forwardPE: props.asset.forwardPE !== undefined ? props.asset.forwardPE : undefined,
516
+ priceToSalesRatioTTM: props.asset.priceToSalesRatioTTM !== undefined ? props.asset.priceToSalesRatioTTM : undefined,
517
+ priceToBookRatio: props.asset.priceToBookRatio !== undefined ? props.asset.priceToBookRatio : undefined,
518
+ evToRevenue: props.asset.evToRevenue !== undefined ? props.asset.evToRevenue : undefined,
519
+ evToEbitda: props.asset.evToEbitda !== undefined ? props.asset.evToEbitda : undefined,
520
+ beta: props.asset.beta !== undefined ? props.asset.beta : undefined,
521
+ week52High: props.asset.week52High !== undefined ? props.asset.week52High : undefined,
522
+ week52Low: props.asset.week52Low !== undefined ? props.asset.week52Low : undefined,
523
+ day50MovingAverage: props.asset.day50MovingAverage !== undefined ? props.asset.day50MovingAverage : undefined,
524
+ day200MovingAverage: props.asset.day200MovingAverage !== undefined ? props.asset.day200MovingAverage : undefined,
525
+ sharesOutstanding: props.asset.sharesOutstanding !== undefined ? props.asset.sharesOutstanding : undefined,
526
+ dividendDate: props.asset.dividendDate !== undefined ? props.asset.dividendDate : undefined,
527
+ exDividendDate: props.asset.exDividendDate !== undefined ? props.asset.exDividendDate : undefined,
528
+ sellPrice: props.asset.sellPrice !== undefined ? props.asset.sellPrice : undefined,
529
+ buyPrice: props.asset.buyPrice !== undefined ? props.asset.buyPrice : undefined,
530
+ trades: props.asset.trades ?
531
+ Array.isArray(props.asset.trades) && props.asset.trades.length > 0
532
+ ? props.asset.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
533
+ connect: props.asset.trades.map((item) => ({
534
+ id: item.id
535
+ }))
536
+ }
537
+ : { connectOrCreate: props.asset.trades.map((item) => ({
538
+ where: {
539
+ id: item.id !== undefined ? item.id : undefined,
540
+ },
541
+ create: {
542
+ qty: item.qty !== undefined ? item.qty : undefined,
543
+ price: item.price !== undefined ? item.price : undefined,
544
+ total: item.total !== undefined ? item.total : undefined,
545
+ signal: item.signal !== undefined ? item.signal : undefined,
546
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
547
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
548
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
549
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
550
+ status: item.status !== undefined ? item.status : undefined,
551
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
552
+ },
553
+ }))
554
+ } : undefined,
555
+ positions: props.asset.positions ?
556
+ Array.isArray(props.asset.positions) && props.asset.positions.length > 0
557
+ ? props.asset.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
558
+ connect: props.asset.positions.map((item) => ({
559
+ id: item.id
560
+ }))
561
+ }
562
+ : { connectOrCreate: props.asset.positions.map((item) => ({
563
+ where: {
564
+ id: item.id !== undefined ? item.id : undefined,
565
+ },
566
+ create: {
567
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
568
+ qty: item.qty !== undefined ? item.qty : undefined,
569
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
570
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
571
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
572
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
573
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
574
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
575
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
576
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
577
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
578
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
579
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
580
+ },
581
+ }))
582
+ } : undefined,
583
+ newsMentions: props.asset.newsMentions ?
584
+ Array.isArray(props.asset.newsMentions) && props.asset.newsMentions.length > 0
585
+ ? props.asset.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
586
+ connect: props.asset.newsMentions.map((item) => ({
587
+ id: item.id
588
+ }))
589
+ }
590
+ : { connectOrCreate: props.asset.newsMentions.map((item) => ({
591
+ where: {
592
+ id: item.id !== undefined ? item.id : undefined,
593
+ url: item.url !== undefined ? item.url : undefined,
594
+ },
595
+ create: {
596
+ url: item.url !== undefined ? item.url : undefined,
597
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
598
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
599
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
600
+ },
601
+ }))
602
+ } : undefined,
603
+ },
604
+ }
605
+ } : undefined,
545
606
  },
546
607
  };
547
608
  const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
@@ -1185,81 +1246,104 @@ exports.Order = {
1185
1246
  APISecret: props.alpacaAccount.APISecret !== undefined ? props.alpacaAccount.APISecret : undefined,
1186
1247
  configuration: props.alpacaAccount.configuration !== undefined ? props.alpacaAccount.configuration : undefined,
1187
1248
  marketOpen: props.alpacaAccount.marketOpen !== undefined ? props.alpacaAccount.marketOpen : undefined,
1188
- user: props.alpacaAccount.user ? {
1189
- connectOrCreate: {
1190
- where: {
1191
- id: props.alpacaAccount.user.id !== undefined ? props.alpacaAccount.user.id : undefined,
1192
- email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
1193
- name: props.alpacaAccount.user.name !== undefined ? {
1194
- equals: props.alpacaAccount.user.name
1195
- } : undefined,
1196
- },
1197
- create: {
1198
- name: props.alpacaAccount.user.name !== undefined ? props.alpacaAccount.user.name : undefined,
1199
- email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
1200
- emailVerified: props.alpacaAccount.user.emailVerified !== undefined ? props.alpacaAccount.user.emailVerified : undefined,
1201
- image: props.alpacaAccount.user.image !== undefined ? props.alpacaAccount.user.image : undefined,
1202
- role: props.alpacaAccount.user.role !== undefined ? props.alpacaAccount.user.role : undefined,
1203
- bio: props.alpacaAccount.user.bio !== undefined ? props.alpacaAccount.user.bio : undefined,
1204
- jobTitle: props.alpacaAccount.user.jobTitle !== undefined ? props.alpacaAccount.user.jobTitle : undefined,
1205
- currentAccount: props.alpacaAccount.user.currentAccount !== undefined ? props.alpacaAccount.user.currentAccount : undefined,
1206
- plan: props.alpacaAccount.user.plan !== undefined ? props.alpacaAccount.user.plan : undefined,
1207
- },
1208
- }
1209
- } : undefined,
1210
- trades: props.alpacaAccount.trades ? {
1211
- connectOrCreate: props.alpacaAccount.trades.map((item) => ({
1212
- where: {
1213
- id: item.id !== undefined ? item.id : undefined,
1214
- },
1215
- create: {
1216
- qty: item.qty !== undefined ? item.qty : undefined,
1217
- price: item.price !== undefined ? item.price : undefined,
1218
- total: item.total !== undefined ? item.total : undefined,
1219
- signal: item.signal !== undefined ? item.signal : undefined,
1220
- strategy: item.strategy !== undefined ? item.strategy : undefined,
1221
- analysis: item.analysis !== undefined ? item.analysis : undefined,
1222
- confidence: item.confidence !== undefined ? item.confidence : undefined,
1223
- timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1224
- status: item.status !== undefined ? item.status : undefined,
1225
- optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1226
- },
1227
- }))
1228
- } : undefined,
1229
- positions: props.alpacaAccount.positions ? {
1230
- connectOrCreate: props.alpacaAccount.positions.map((item) => ({
1231
- where: {
1232
- id: item.id !== undefined ? item.id : undefined,
1233
- },
1234
- create: {
1235
- averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
1236
- qty: item.qty !== undefined ? item.qty : undefined,
1237
- qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
1238
- marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
1239
- costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
1240
- unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
1241
- unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
1242
- unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
1243
- unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
1244
- currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
1245
- lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1246
- changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1247
- assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
1248
- },
1249
- }))
1250
- } : undefined,
1251
- alerts: props.alpacaAccount.alerts ? {
1252
- connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
1253
- where: {
1254
- id: item.id !== undefined ? item.id : undefined,
1255
- },
1256
- create: {
1257
- message: item.message !== undefined ? item.message : undefined,
1258
- type: item.type !== undefined ? item.type : undefined,
1259
- isRead: item.isRead !== undefined ? item.isRead : undefined,
1260
- },
1261
- }))
1262
- } : undefined,
1249
+ user: props.alpacaAccount.user ?
1250
+ typeof props.alpacaAccount.user === 'object' && Object.keys(props.alpacaAccount.user).length === 1 && Object.keys(props.alpacaAccount.user)[0] === 'id'
1251
+ ? { connect: {
1252
+ id: props.alpacaAccount.user.id
1253
+ }
1254
+ }
1255
+ : { connectOrCreate: {
1256
+ where: {
1257
+ id: props.alpacaAccount.user.id !== undefined ? props.alpacaAccount.user.id : undefined,
1258
+ email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
1259
+ name: props.alpacaAccount.user.name !== undefined ? {
1260
+ equals: props.alpacaAccount.user.name
1261
+ } : undefined,
1262
+ },
1263
+ create: {
1264
+ name: props.alpacaAccount.user.name !== undefined ? props.alpacaAccount.user.name : undefined,
1265
+ email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
1266
+ emailVerified: props.alpacaAccount.user.emailVerified !== undefined ? props.alpacaAccount.user.emailVerified : undefined,
1267
+ image: props.alpacaAccount.user.image !== undefined ? props.alpacaAccount.user.image : undefined,
1268
+ role: props.alpacaAccount.user.role !== undefined ? props.alpacaAccount.user.role : undefined,
1269
+ bio: props.alpacaAccount.user.bio !== undefined ? props.alpacaAccount.user.bio : undefined,
1270
+ jobTitle: props.alpacaAccount.user.jobTitle !== undefined ? props.alpacaAccount.user.jobTitle : undefined,
1271
+ currentAccount: props.alpacaAccount.user.currentAccount !== undefined ? props.alpacaAccount.user.currentAccount : undefined,
1272
+ plan: props.alpacaAccount.user.plan !== undefined ? props.alpacaAccount.user.plan : undefined,
1273
+ },
1274
+ }
1275
+ } : undefined,
1276
+ trades: props.alpacaAccount.trades ?
1277
+ Array.isArray(props.alpacaAccount.trades) && props.alpacaAccount.trades.length > 0
1278
+ ? props.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1279
+ connect: props.alpacaAccount.trades.map((item) => ({
1280
+ id: item.id
1281
+ }))
1282
+ }
1283
+ : { connectOrCreate: props.alpacaAccount.trades.map((item) => ({
1284
+ where: {
1285
+ id: item.id !== undefined ? item.id : undefined,
1286
+ },
1287
+ create: {
1288
+ qty: item.qty !== undefined ? item.qty : undefined,
1289
+ price: item.price !== undefined ? item.price : undefined,
1290
+ total: item.total !== undefined ? item.total : undefined,
1291
+ signal: item.signal !== undefined ? item.signal : undefined,
1292
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
1293
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
1294
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
1295
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1296
+ status: item.status !== undefined ? item.status : undefined,
1297
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1298
+ },
1299
+ }))
1300
+ } : undefined,
1301
+ positions: props.alpacaAccount.positions ?
1302
+ Array.isArray(props.alpacaAccount.positions) && props.alpacaAccount.positions.length > 0
1303
+ ? props.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1304
+ connect: props.alpacaAccount.positions.map((item) => ({
1305
+ id: item.id
1306
+ }))
1307
+ }
1308
+ : { connectOrCreate: props.alpacaAccount.positions.map((item) => ({
1309
+ where: {
1310
+ id: item.id !== undefined ? item.id : undefined,
1311
+ },
1312
+ create: {
1313
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
1314
+ qty: item.qty !== undefined ? item.qty : undefined,
1315
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
1316
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
1317
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
1318
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
1319
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
1320
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
1321
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
1322
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
1323
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1324
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1325
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
1326
+ },
1327
+ }))
1328
+ } : undefined,
1329
+ alerts: props.alpacaAccount.alerts ?
1330
+ Array.isArray(props.alpacaAccount.alerts) && props.alpacaAccount.alerts.length > 0
1331
+ ? props.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1332
+ connect: props.alpacaAccount.alerts.map((item) => ({
1333
+ id: item.id
1334
+ }))
1335
+ }
1336
+ : { connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
1337
+ where: {
1338
+ id: item.id !== undefined ? item.id : undefined,
1339
+ },
1340
+ create: {
1341
+ message: item.message !== undefined ? item.message : undefined,
1342
+ type: item.type !== undefined ? item.type : undefined,
1343
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
1344
+ },
1345
+ }))
1346
+ } : undefined,
1263
1347
  },
1264
1348
  }
1265
1349
  } : undefined,
@@ -1352,25 +1436,30 @@ exports.Order = {
1352
1436
  note: props.action.note !== undefined ? props.action.note : undefined,
1353
1437
  status: props.action.status !== undefined ? props.action.status : undefined,
1354
1438
  fee: props.action.fee !== undefined ? props.action.fee : undefined,
1355
- trade: props.action.trade ? {
1356
- connectOrCreate: {
1357
- where: {
1358
- id: props.action.trade.id !== undefined ? props.action.trade.id : undefined,
1359
- },
1360
- create: {
1361
- qty: props.action.trade.qty !== undefined ? props.action.trade.qty : undefined,
1362
- price: props.action.trade.price !== undefined ? props.action.trade.price : undefined,
1363
- total: props.action.trade.total !== undefined ? props.action.trade.total : undefined,
1364
- signal: props.action.trade.signal !== undefined ? props.action.trade.signal : undefined,
1365
- strategy: props.action.trade.strategy !== undefined ? props.action.trade.strategy : undefined,
1366
- analysis: props.action.trade.analysis !== undefined ? props.action.trade.analysis : undefined,
1367
- confidence: props.action.trade.confidence !== undefined ? props.action.trade.confidence : undefined,
1368
- timestamp: props.action.trade.timestamp !== undefined ? props.action.trade.timestamp : undefined,
1369
- status: props.action.trade.status !== undefined ? props.action.trade.status : undefined,
1370
- optionContractType: props.action.trade.optionContractType !== undefined ? props.action.trade.optionContractType : undefined,
1371
- },
1372
- }
1373
- } : undefined,
1439
+ trade: props.action.trade ?
1440
+ typeof props.action.trade === 'object' && Object.keys(props.action.trade).length === 1 && Object.keys(props.action.trade)[0] === 'id'
1441
+ ? { connect: {
1442
+ id: props.action.trade.id
1443
+ }
1444
+ }
1445
+ : { connectOrCreate: {
1446
+ where: {
1447
+ id: props.action.trade.id !== undefined ? props.action.trade.id : undefined,
1448
+ },
1449
+ create: {
1450
+ qty: props.action.trade.qty !== undefined ? props.action.trade.qty : undefined,
1451
+ price: props.action.trade.price !== undefined ? props.action.trade.price : undefined,
1452
+ total: props.action.trade.total !== undefined ? props.action.trade.total : undefined,
1453
+ signal: props.action.trade.signal !== undefined ? props.action.trade.signal : undefined,
1454
+ strategy: props.action.trade.strategy !== undefined ? props.action.trade.strategy : undefined,
1455
+ analysis: props.action.trade.analysis !== undefined ? props.action.trade.analysis : undefined,
1456
+ confidence: props.action.trade.confidence !== undefined ? props.action.trade.confidence : undefined,
1457
+ timestamp: props.action.trade.timestamp !== undefined ? props.action.trade.timestamp : undefined,
1458
+ status: props.action.trade.status !== undefined ? props.action.trade.status : undefined,
1459
+ optionContractType: props.action.trade.optionContractType !== undefined ? props.action.trade.optionContractType : undefined,
1460
+ },
1461
+ }
1462
+ } : undefined,
1374
1463
  },
1375
1464
  }
1376
1465
  } : undefined,
@@ -1764,61 +1853,79 @@ exports.Order = {
1764
1853
  exDividendDate: props.asset.exDividendDate !== undefined ? props.asset.exDividendDate : undefined,
1765
1854
  sellPrice: props.asset.sellPrice !== undefined ? props.asset.sellPrice : undefined,
1766
1855
  buyPrice: props.asset.buyPrice !== undefined ? props.asset.buyPrice : undefined,
1767
- trades: props.asset.trades ? {
1768
- connectOrCreate: props.asset.trades.map((item) => ({
1769
- where: {
1770
- id: item.id !== undefined ? item.id : undefined,
1771
- },
1772
- create: {
1773
- qty: item.qty !== undefined ? item.qty : undefined,
1774
- price: item.price !== undefined ? item.price : undefined,
1775
- total: item.total !== undefined ? item.total : undefined,
1776
- signal: item.signal !== undefined ? item.signal : undefined,
1777
- strategy: item.strategy !== undefined ? item.strategy : undefined,
1778
- analysis: item.analysis !== undefined ? item.analysis : undefined,
1779
- confidence: item.confidence !== undefined ? item.confidence : undefined,
1780
- timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1781
- status: item.status !== undefined ? item.status : undefined,
1782
- optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1783
- },
1784
- }))
1785
- } : undefined,
1786
- positions: props.asset.positions ? {
1787
- connectOrCreate: props.asset.positions.map((item) => ({
1788
- where: {
1789
- id: item.id !== undefined ? item.id : undefined,
1790
- },
1791
- create: {
1792
- averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
1793
- qty: item.qty !== undefined ? item.qty : undefined,
1794
- qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
1795
- marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
1796
- costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
1797
- unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
1798
- unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
1799
- unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
1800
- unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
1801
- currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
1802
- lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1803
- changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1804
- assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
1805
- },
1806
- }))
1807
- } : undefined,
1808
- newsMentions: props.asset.newsMentions ? {
1809
- connectOrCreate: props.asset.newsMentions.map((item) => ({
1810
- where: {
1811
- id: item.id !== undefined ? item.id : undefined,
1812
- url: item.url !== undefined ? item.url : undefined,
1813
- },
1814
- create: {
1815
- url: item.url !== undefined ? item.url : undefined,
1816
- relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1817
- sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1818
- sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1819
- },
1820
- }))
1821
- } : undefined,
1856
+ trades: props.asset.trades ?
1857
+ Array.isArray(props.asset.trades) && props.asset.trades.length > 0
1858
+ ? props.asset.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1859
+ connect: props.asset.trades.map((item) => ({
1860
+ id: item.id
1861
+ }))
1862
+ }
1863
+ : { connectOrCreate: props.asset.trades.map((item) => ({
1864
+ where: {
1865
+ id: item.id !== undefined ? item.id : undefined,
1866
+ },
1867
+ create: {
1868
+ qty: item.qty !== undefined ? item.qty : undefined,
1869
+ price: item.price !== undefined ? item.price : undefined,
1870
+ total: item.total !== undefined ? item.total : undefined,
1871
+ signal: item.signal !== undefined ? item.signal : undefined,
1872
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
1873
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
1874
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
1875
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1876
+ status: item.status !== undefined ? item.status : undefined,
1877
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1878
+ },
1879
+ }))
1880
+ } : undefined,
1881
+ positions: props.asset.positions ?
1882
+ Array.isArray(props.asset.positions) && props.asset.positions.length > 0
1883
+ ? props.asset.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1884
+ connect: props.asset.positions.map((item) => ({
1885
+ id: item.id
1886
+ }))
1887
+ }
1888
+ : { connectOrCreate: props.asset.positions.map((item) => ({
1889
+ where: {
1890
+ id: item.id !== undefined ? item.id : undefined,
1891
+ },
1892
+ create: {
1893
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
1894
+ qty: item.qty !== undefined ? item.qty : undefined,
1895
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
1896
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
1897
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
1898
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
1899
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
1900
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
1901
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
1902
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
1903
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1904
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1905
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
1906
+ },
1907
+ }))
1908
+ } : undefined,
1909
+ newsMentions: props.asset.newsMentions ?
1910
+ Array.isArray(props.asset.newsMentions) && props.asset.newsMentions.length > 0
1911
+ ? props.asset.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
1912
+ connect: props.asset.newsMentions.map((item) => ({
1913
+ id: item.id
1914
+ }))
1915
+ }
1916
+ : { connectOrCreate: props.asset.newsMentions.map((item) => ({
1917
+ where: {
1918
+ id: item.id !== undefined ? item.id : undefined,
1919
+ url: item.url !== undefined ? item.url : undefined,
1920
+ },
1921
+ create: {
1922
+ url: item.url !== undefined ? item.url : undefined,
1923
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1924
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1925
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1926
+ },
1927
+ }))
1928
+ } : undefined,
1822
1929
  },
1823
1930
  }
1824
1931
  } : undefined,
@@ -2153,81 +2260,104 @@ exports.Order = {
2153
2260
  APISecret: prop.alpacaAccount.APISecret !== undefined ? prop.alpacaAccount.APISecret : undefined,
2154
2261
  configuration: prop.alpacaAccount.configuration !== undefined ? prop.alpacaAccount.configuration : undefined,
2155
2262
  marketOpen: prop.alpacaAccount.marketOpen !== undefined ? prop.alpacaAccount.marketOpen : undefined,
2156
- user: prop.alpacaAccount.user ? {
2157
- connectOrCreate: {
2158
- where: {
2159
- id: prop.alpacaAccount.user.id !== undefined ? prop.alpacaAccount.user.id : undefined,
2160
- email: prop.alpacaAccount.user.email !== undefined ? prop.alpacaAccount.user.email : undefined,
2161
- name: prop.alpacaAccount.user.name !== undefined ? {
2162
- equals: prop.alpacaAccount.user.name
2163
- } : undefined,
2164
- },
2165
- create: {
2166
- name: prop.alpacaAccount.user.name !== undefined ? prop.alpacaAccount.user.name : undefined,
2167
- email: prop.alpacaAccount.user.email !== undefined ? prop.alpacaAccount.user.email : undefined,
2168
- emailVerified: prop.alpacaAccount.user.emailVerified !== undefined ? prop.alpacaAccount.user.emailVerified : undefined,
2169
- image: prop.alpacaAccount.user.image !== undefined ? prop.alpacaAccount.user.image : undefined,
2170
- role: prop.alpacaAccount.user.role !== undefined ? prop.alpacaAccount.user.role : undefined,
2171
- bio: prop.alpacaAccount.user.bio !== undefined ? prop.alpacaAccount.user.bio : undefined,
2172
- jobTitle: prop.alpacaAccount.user.jobTitle !== undefined ? prop.alpacaAccount.user.jobTitle : undefined,
2173
- currentAccount: prop.alpacaAccount.user.currentAccount !== undefined ? prop.alpacaAccount.user.currentAccount : undefined,
2174
- plan: prop.alpacaAccount.user.plan !== undefined ? prop.alpacaAccount.user.plan : undefined,
2175
- },
2176
- }
2177
- } : undefined,
2178
- trades: prop.alpacaAccount.trades ? {
2179
- connectOrCreate: prop.alpacaAccount.trades.map((item) => ({
2180
- where: {
2181
- id: item.id !== undefined ? item.id : undefined,
2182
- },
2183
- create: {
2184
- qty: item.qty !== undefined ? item.qty : undefined,
2185
- price: item.price !== undefined ? item.price : undefined,
2186
- total: item.total !== undefined ? item.total : undefined,
2187
- signal: item.signal !== undefined ? item.signal : undefined,
2188
- strategy: item.strategy !== undefined ? item.strategy : undefined,
2189
- analysis: item.analysis !== undefined ? item.analysis : undefined,
2190
- confidence: item.confidence !== undefined ? item.confidence : undefined,
2191
- timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2192
- status: item.status !== undefined ? item.status : undefined,
2193
- optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
2194
- },
2195
- }))
2196
- } : undefined,
2197
- positions: prop.alpacaAccount.positions ? {
2198
- connectOrCreate: prop.alpacaAccount.positions.map((item) => ({
2199
- where: {
2200
- id: item.id !== undefined ? item.id : undefined,
2201
- },
2202
- create: {
2203
- averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2204
- qty: item.qty !== undefined ? item.qty : undefined,
2205
- qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2206
- marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2207
- costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2208
- unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2209
- unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2210
- unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2211
- unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2212
- currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2213
- lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2214
- changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2215
- assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2216
- },
2217
- }))
2218
- } : undefined,
2219
- alerts: prop.alpacaAccount.alerts ? {
2220
- connectOrCreate: prop.alpacaAccount.alerts.map((item) => ({
2221
- where: {
2222
- id: item.id !== undefined ? item.id : undefined,
2223
- },
2224
- create: {
2225
- message: item.message !== undefined ? item.message : undefined,
2226
- type: item.type !== undefined ? item.type : undefined,
2227
- isRead: item.isRead !== undefined ? item.isRead : undefined,
2228
- },
2229
- }))
2230
- } : undefined,
2263
+ user: prop.alpacaAccount.user ?
2264
+ typeof prop.alpacaAccount.user === 'object' && Object.keys(prop.alpacaAccount.user).length === 1 && Object.keys(prop.alpacaAccount.user)[0] === 'id'
2265
+ ? { connect: {
2266
+ id: prop.alpacaAccount.user.id
2267
+ }
2268
+ }
2269
+ : { connectOrCreate: {
2270
+ where: {
2271
+ id: prop.alpacaAccount.user.id !== undefined ? prop.alpacaAccount.user.id : undefined,
2272
+ email: prop.alpacaAccount.user.email !== undefined ? prop.alpacaAccount.user.email : undefined,
2273
+ name: prop.alpacaAccount.user.name !== undefined ? {
2274
+ equals: prop.alpacaAccount.user.name
2275
+ } : undefined,
2276
+ },
2277
+ create: {
2278
+ name: prop.alpacaAccount.user.name !== undefined ? prop.alpacaAccount.user.name : undefined,
2279
+ email: prop.alpacaAccount.user.email !== undefined ? prop.alpacaAccount.user.email : undefined,
2280
+ emailVerified: prop.alpacaAccount.user.emailVerified !== undefined ? prop.alpacaAccount.user.emailVerified : undefined,
2281
+ image: prop.alpacaAccount.user.image !== undefined ? prop.alpacaAccount.user.image : undefined,
2282
+ role: prop.alpacaAccount.user.role !== undefined ? prop.alpacaAccount.user.role : undefined,
2283
+ bio: prop.alpacaAccount.user.bio !== undefined ? prop.alpacaAccount.user.bio : undefined,
2284
+ jobTitle: prop.alpacaAccount.user.jobTitle !== undefined ? prop.alpacaAccount.user.jobTitle : undefined,
2285
+ currentAccount: prop.alpacaAccount.user.currentAccount !== undefined ? prop.alpacaAccount.user.currentAccount : undefined,
2286
+ plan: prop.alpacaAccount.user.plan !== undefined ? prop.alpacaAccount.user.plan : undefined,
2287
+ },
2288
+ }
2289
+ } : undefined,
2290
+ trades: prop.alpacaAccount.trades ?
2291
+ Array.isArray(prop.alpacaAccount.trades) && prop.alpacaAccount.trades.length > 0
2292
+ ? prop.alpacaAccount.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2293
+ connect: prop.alpacaAccount.trades.map((item) => ({
2294
+ id: item.id
2295
+ }))
2296
+ }
2297
+ : { connectOrCreate: prop.alpacaAccount.trades.map((item) => ({
2298
+ where: {
2299
+ id: item.id !== undefined ? item.id : undefined,
2300
+ },
2301
+ create: {
2302
+ qty: item.qty !== undefined ? item.qty : undefined,
2303
+ price: item.price !== undefined ? item.price : undefined,
2304
+ total: item.total !== undefined ? item.total : undefined,
2305
+ signal: item.signal !== undefined ? item.signal : undefined,
2306
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
2307
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
2308
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
2309
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2310
+ status: item.status !== undefined ? item.status : undefined,
2311
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
2312
+ },
2313
+ }))
2314
+ } : undefined,
2315
+ positions: prop.alpacaAccount.positions ?
2316
+ Array.isArray(prop.alpacaAccount.positions) && prop.alpacaAccount.positions.length > 0
2317
+ ? prop.alpacaAccount.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2318
+ connect: prop.alpacaAccount.positions.map((item) => ({
2319
+ id: item.id
2320
+ }))
2321
+ }
2322
+ : { connectOrCreate: prop.alpacaAccount.positions.map((item) => ({
2323
+ where: {
2324
+ id: item.id !== undefined ? item.id : undefined,
2325
+ },
2326
+ create: {
2327
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2328
+ qty: item.qty !== undefined ? item.qty : undefined,
2329
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2330
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2331
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2332
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2333
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2334
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2335
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2336
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2337
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2338
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2339
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2340
+ },
2341
+ }))
2342
+ } : undefined,
2343
+ alerts: prop.alpacaAccount.alerts ?
2344
+ Array.isArray(prop.alpacaAccount.alerts) && prop.alpacaAccount.alerts.length > 0
2345
+ ? prop.alpacaAccount.alerts.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2346
+ connect: prop.alpacaAccount.alerts.map((item) => ({
2347
+ id: item.id
2348
+ }))
2349
+ }
2350
+ : { connectOrCreate: prop.alpacaAccount.alerts.map((item) => ({
2351
+ where: {
2352
+ id: item.id !== undefined ? item.id : undefined,
2353
+ },
2354
+ create: {
2355
+ message: item.message !== undefined ? item.message : undefined,
2356
+ type: item.type !== undefined ? item.type : undefined,
2357
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
2358
+ },
2359
+ }))
2360
+ } : undefined,
2231
2361
  },
2232
2362
  }
2233
2363
  } : undefined,
@@ -2320,25 +2450,30 @@ exports.Order = {
2320
2450
  note: prop.action.note !== undefined ? prop.action.note : undefined,
2321
2451
  status: prop.action.status !== undefined ? prop.action.status : undefined,
2322
2452
  fee: prop.action.fee !== undefined ? prop.action.fee : undefined,
2323
- trade: prop.action.trade ? {
2324
- connectOrCreate: {
2325
- where: {
2326
- id: prop.action.trade.id !== undefined ? prop.action.trade.id : undefined,
2327
- },
2328
- create: {
2329
- qty: prop.action.trade.qty !== undefined ? prop.action.trade.qty : undefined,
2330
- price: prop.action.trade.price !== undefined ? prop.action.trade.price : undefined,
2331
- total: prop.action.trade.total !== undefined ? prop.action.trade.total : undefined,
2332
- signal: prop.action.trade.signal !== undefined ? prop.action.trade.signal : undefined,
2333
- strategy: prop.action.trade.strategy !== undefined ? prop.action.trade.strategy : undefined,
2334
- analysis: prop.action.trade.analysis !== undefined ? prop.action.trade.analysis : undefined,
2335
- confidence: prop.action.trade.confidence !== undefined ? prop.action.trade.confidence : undefined,
2336
- timestamp: prop.action.trade.timestamp !== undefined ? prop.action.trade.timestamp : undefined,
2337
- status: prop.action.trade.status !== undefined ? prop.action.trade.status : undefined,
2338
- optionContractType: prop.action.trade.optionContractType !== undefined ? prop.action.trade.optionContractType : undefined,
2339
- },
2340
- }
2341
- } : undefined,
2453
+ trade: prop.action.trade ?
2454
+ typeof prop.action.trade === 'object' && Object.keys(prop.action.trade).length === 1 && Object.keys(prop.action.trade)[0] === 'id'
2455
+ ? { connect: {
2456
+ id: prop.action.trade.id
2457
+ }
2458
+ }
2459
+ : { connectOrCreate: {
2460
+ where: {
2461
+ id: prop.action.trade.id !== undefined ? prop.action.trade.id : undefined,
2462
+ },
2463
+ create: {
2464
+ qty: prop.action.trade.qty !== undefined ? prop.action.trade.qty : undefined,
2465
+ price: prop.action.trade.price !== undefined ? prop.action.trade.price : undefined,
2466
+ total: prop.action.trade.total !== undefined ? prop.action.trade.total : undefined,
2467
+ signal: prop.action.trade.signal !== undefined ? prop.action.trade.signal : undefined,
2468
+ strategy: prop.action.trade.strategy !== undefined ? prop.action.trade.strategy : undefined,
2469
+ analysis: prop.action.trade.analysis !== undefined ? prop.action.trade.analysis : undefined,
2470
+ confidence: prop.action.trade.confidence !== undefined ? prop.action.trade.confidence : undefined,
2471
+ timestamp: prop.action.trade.timestamp !== undefined ? prop.action.trade.timestamp : undefined,
2472
+ status: prop.action.trade.status !== undefined ? prop.action.trade.status : undefined,
2473
+ optionContractType: prop.action.trade.optionContractType !== undefined ? prop.action.trade.optionContractType : undefined,
2474
+ },
2475
+ }
2476
+ } : undefined,
2342
2477
  },
2343
2478
  }
2344
2479
  } : undefined,
@@ -2732,61 +2867,79 @@ exports.Order = {
2732
2867
  exDividendDate: prop.asset.exDividendDate !== undefined ? prop.asset.exDividendDate : undefined,
2733
2868
  sellPrice: prop.asset.sellPrice !== undefined ? prop.asset.sellPrice : undefined,
2734
2869
  buyPrice: prop.asset.buyPrice !== undefined ? prop.asset.buyPrice : undefined,
2735
- trades: prop.asset.trades ? {
2736
- connectOrCreate: prop.asset.trades.map((item) => ({
2737
- where: {
2738
- id: item.id !== undefined ? item.id : undefined,
2739
- },
2740
- create: {
2741
- qty: item.qty !== undefined ? item.qty : undefined,
2742
- price: item.price !== undefined ? item.price : undefined,
2743
- total: item.total !== undefined ? item.total : undefined,
2744
- signal: item.signal !== undefined ? item.signal : undefined,
2745
- strategy: item.strategy !== undefined ? item.strategy : undefined,
2746
- analysis: item.analysis !== undefined ? item.analysis : undefined,
2747
- confidence: item.confidence !== undefined ? item.confidence : undefined,
2748
- timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2749
- status: item.status !== undefined ? item.status : undefined,
2750
- optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
2751
- },
2752
- }))
2753
- } : undefined,
2754
- positions: prop.asset.positions ? {
2755
- connectOrCreate: prop.asset.positions.map((item) => ({
2756
- where: {
2757
- id: item.id !== undefined ? item.id : undefined,
2758
- },
2759
- create: {
2760
- averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2761
- qty: item.qty !== undefined ? item.qty : undefined,
2762
- qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2763
- marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2764
- costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2765
- unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2766
- unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2767
- unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2768
- unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2769
- currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2770
- lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2771
- changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2772
- assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2773
- },
2774
- }))
2775
- } : undefined,
2776
- newsMentions: prop.asset.newsMentions ? {
2777
- connectOrCreate: prop.asset.newsMentions.map((item) => ({
2778
- where: {
2779
- id: item.id !== undefined ? item.id : undefined,
2780
- url: item.url !== undefined ? item.url : undefined,
2781
- },
2782
- create: {
2783
- url: item.url !== undefined ? item.url : undefined,
2784
- relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
2785
- sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
2786
- sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
2787
- },
2788
- }))
2789
- } : undefined,
2870
+ trades: prop.asset.trades ?
2871
+ Array.isArray(prop.asset.trades) && prop.asset.trades.length > 0
2872
+ ? prop.asset.trades.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2873
+ connect: prop.asset.trades.map((item) => ({
2874
+ id: item.id
2875
+ }))
2876
+ }
2877
+ : { connectOrCreate: prop.asset.trades.map((item) => ({
2878
+ where: {
2879
+ id: item.id !== undefined ? item.id : undefined,
2880
+ },
2881
+ create: {
2882
+ qty: item.qty !== undefined ? item.qty : undefined,
2883
+ price: item.price !== undefined ? item.price : undefined,
2884
+ total: item.total !== undefined ? item.total : undefined,
2885
+ signal: item.signal !== undefined ? item.signal : undefined,
2886
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
2887
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
2888
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
2889
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2890
+ status: item.status !== undefined ? item.status : undefined,
2891
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
2892
+ },
2893
+ }))
2894
+ } : undefined,
2895
+ positions: prop.asset.positions ?
2896
+ Array.isArray(prop.asset.positions) && prop.asset.positions.length > 0
2897
+ ? prop.asset.positions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2898
+ connect: prop.asset.positions.map((item) => ({
2899
+ id: item.id
2900
+ }))
2901
+ }
2902
+ : { connectOrCreate: prop.asset.positions.map((item) => ({
2903
+ where: {
2904
+ id: item.id !== undefined ? item.id : undefined,
2905
+ },
2906
+ create: {
2907
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2908
+ qty: item.qty !== undefined ? item.qty : undefined,
2909
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2910
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2911
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2912
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2913
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2914
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2915
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2916
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2917
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2918
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2919
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2920
+ },
2921
+ }))
2922
+ } : undefined,
2923
+ newsMentions: prop.asset.newsMentions ?
2924
+ Array.isArray(prop.asset.newsMentions) && prop.asset.newsMentions.length > 0
2925
+ ? prop.asset.newsMentions.every((item) => typeof item === 'object' && 'id' in item && Object.keys(item).length === 1) && {
2926
+ connect: prop.asset.newsMentions.map((item) => ({
2927
+ id: item.id
2928
+ }))
2929
+ }
2930
+ : { connectOrCreate: prop.asset.newsMentions.map((item) => ({
2931
+ where: {
2932
+ id: item.id !== undefined ? item.id : undefined,
2933
+ url: item.url !== undefined ? item.url : undefined,
2934
+ },
2935
+ create: {
2936
+ url: item.url !== undefined ? item.url : undefined,
2937
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
2938
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
2939
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
2940
+ },
2941
+ }))
2942
+ } : undefined,
2790
2943
  },
2791
2944
  }
2792
2945
  } : undefined,