adaptic-backend 1.0.75 → 1.0.76

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 +255 -190
  2. package/Action.cjs +594 -524
  3. package/Alert.cjs +343 -278
  4. package/AlpacaAccount.cjs +1181 -1021
  5. package/Asset.cjs +478 -368
  6. package/Authenticator.cjs +276 -211
  7. package/Customer.cjs +255 -190
  8. package/NewsArticle.cjs +232 -212
  9. package/NewsArticleAssetSentiment.cjs +345 -290
  10. package/Order.cjs +676 -541
  11. package/Position.cjs +603 -488
  12. package/Session.cjs +279 -214
  13. package/Trade.cjs +748 -613
  14. package/User.cjs +394 -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 +255 -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 +343 -278
  25. package/server/AlpacaAccount.d.ts.map +1 -1
  26. package/server/AlpacaAccount.js.map +1 -1
  27. package/server/AlpacaAccount.mjs +1181 -1021
  28. package/server/Asset.d.ts.map +1 -1
  29. package/server/Asset.js.map +1 -1
  30. package/server/Asset.mjs +478 -368
  31. package/server/Authenticator.d.ts.map +1 -1
  32. package/server/Authenticator.js.map +1 -1
  33. package/server/Authenticator.mjs +276 -211
  34. package/server/Customer.d.ts.map +1 -1
  35. package/server/Customer.js.map +1 -1
  36. package/server/Customer.mjs +255 -190
  37. package/server/NewsArticle.d.ts.map +1 -1
  38. package/server/NewsArticle.js.map +1 -1
  39. package/server/NewsArticle.mjs +232 -212
  40. package/server/NewsArticleAssetSentiment.d.ts.map +1 -1
  41. package/server/NewsArticleAssetSentiment.js.map +1 -1
  42. package/server/NewsArticleAssetSentiment.mjs +345 -290
  43. package/server/Order.d.ts.map +1 -1
  44. package/server/Order.js.map +1 -1
  45. package/server/Order.mjs +676 -541
  46. package/server/Position.d.ts.map +1 -1
  47. package/server/Position.js.map +1 -1
  48. package/server/Position.mjs +603 -488
  49. package/server/Session.d.ts.map +1 -1
  50. package/server/Session.js.map +1 -1
  51. package/server/Session.mjs +279 -214
  52. package/server/Trade.d.ts.map +1 -1
  53. package/server/Trade.js.map +1 -1
  54. package/server/Trade.mjs +748 -613
  55. package/server/User.d.ts.map +1 -1
  56. package/server/User.js.map +1 -1
  57. package/server/User.mjs +394 -309
package/Order.cjs CHANGED
@@ -299,249 +299,304 @@ 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
+ typeof props.alpacaAccount.trades[0] === 'object' && Object.keys(props.alpacaAccount.trades).length === 1 && Object.keys(props.alpacaAccount.trades)[0] === 'id'
347
+ ? { connect: props.alpacaAccount.trades.map((item) => ({
348
+ id: item.id
349
+ }))
350
+ }
351
+ : { connectOrCreate: props.alpacaAccount.trades.map((item) => ({
352
+ where: {
353
+ id: item.id !== undefined ? item.id : undefined,
354
+ },
355
+ create: {
356
+ qty: item.qty !== undefined ? item.qty : undefined,
357
+ price: item.price !== undefined ? item.price : undefined,
358
+ total: item.total !== undefined ? item.total : undefined,
359
+ signal: item.signal !== undefined ? item.signal : undefined,
360
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
361
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
362
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
363
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
364
+ status: item.status !== undefined ? item.status : undefined,
365
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
366
+ },
367
+ }))
368
+ } : undefined,
369
+ positions: props.alpacaAccount.positions ?
370
+ typeof props.alpacaAccount.positions[0] === 'object' && Object.keys(props.alpacaAccount.positions).length === 1 && Object.keys(props.alpacaAccount.positions)[0] === 'id'
371
+ ? { connect: props.alpacaAccount.positions.map((item) => ({
372
+ id: item.id
373
+ }))
374
+ }
375
+ : { connectOrCreate: props.alpacaAccount.positions.map((item) => ({
376
+ where: {
377
+ id: item.id !== undefined ? item.id : undefined,
378
+ },
379
+ create: {
380
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
381
+ qty: item.qty !== undefined ? item.qty : undefined,
382
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
383
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
384
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
385
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
386
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
387
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
388
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
389
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
390
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
391
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
392
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
393
+ },
394
+ }))
395
+ } : undefined,
396
+ alerts: props.alpacaAccount.alerts ?
397
+ typeof props.alpacaAccount.alerts[0] === 'object' && Object.keys(props.alpacaAccount.alerts).length === 1 && Object.keys(props.alpacaAccount.alerts)[0] === 'id'
398
+ ? { connect: props.alpacaAccount.alerts.map((item) => ({
399
+ id: item.id
400
+ }))
401
+ }
402
+ : { connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
403
+ where: {
404
+ id: item.id !== undefined ? item.id : undefined,
405
+ },
406
+ create: {
407
+ message: item.message !== undefined ? item.message : undefined,
408
+ type: item.type !== undefined ? item.type : undefined,
409
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
410
+ },
411
+ }))
412
+ } : undefined,
413
+ },
414
+ }
415
+ } : undefined,
416
+ action: props.action ?
417
+ typeof props.action === 'object' && Object.keys(props.action).length === 1 && Object.keys(props.action)[0] === 'id'
418
+ ? { connect: {
419
+ id: props.action.id
420
+ }
421
+ }
422
+ : { connectOrCreate: {
423
+ where: {
424
+ id: props.action.id !== undefined ? props.action.id : undefined,
425
+ },
426
+ create: {
427
+ sequence: props.action.sequence !== undefined ? props.action.sequence : undefined,
428
+ type: props.action.type !== undefined ? props.action.type : undefined,
429
+ note: props.action.note !== undefined ? props.action.note : undefined,
430
+ status: props.action.status !== undefined ? props.action.status : undefined,
431
+ fee: props.action.fee !== undefined ? props.action.fee : undefined,
432
+ trade: props.action.trade ?
433
+ typeof props.action.trade === 'object' && Object.keys(props.action.trade).length === 1 && Object.keys(props.action.trade)[0] === 'id'
434
+ ? { connect: {
435
+ id: props.action.trade.id
436
+ }
437
+ }
438
+ : { connectOrCreate: {
439
+ where: {
440
+ id: props.action.trade.id !== undefined ? props.action.trade.id : undefined,
441
+ },
442
+ create: {
443
+ qty: props.action.trade.qty !== undefined ? props.action.trade.qty : undefined,
444
+ price: props.action.trade.price !== undefined ? props.action.trade.price : undefined,
445
+ total: props.action.trade.total !== undefined ? props.action.trade.total : undefined,
446
+ signal: props.action.trade.signal !== undefined ? props.action.trade.signal : undefined,
447
+ strategy: props.action.trade.strategy !== undefined ? props.action.trade.strategy : undefined,
448
+ analysis: props.action.trade.analysis !== undefined ? props.action.trade.analysis : undefined,
449
+ confidence: props.action.trade.confidence !== undefined ? props.action.trade.confidence : undefined,
450
+ timestamp: props.action.trade.timestamp !== undefined ? props.action.trade.timestamp : undefined,
451
+ status: props.action.trade.status !== undefined ? props.action.trade.status : undefined,
452
+ optionContractType: props.action.trade.optionContractType !== undefined ? props.action.trade.optionContractType : undefined,
453
+ },
454
+ }
455
+ } : undefined,
456
+ },
457
+ }
458
+ } : undefined,
459
+ asset: props.asset ?
460
+ typeof props.asset === 'object' && Object.keys(props.asset).length === 1 && Object.keys(props.asset)[0] === 'id'
461
+ ? { connect: {
462
+ id: props.asset.id
463
+ }
464
+ }
465
+ : { connectOrCreate: {
466
+ where: {
467
+ id: props.asset.id !== undefined ? props.asset.id : undefined,
468
+ symbol: props.asset.symbol !== undefined ? props.asset.symbol : undefined,
469
+ name: props.asset.name !== undefined ? props.asset.name : undefined,
470
+ },
471
+ create: {
472
+ symbol: props.asset.symbol !== undefined ? props.asset.symbol : undefined,
473
+ name: props.asset.name !== undefined ? props.asset.name : undefined,
474
+ type: props.asset.type !== undefined ? props.asset.type : undefined,
475
+ logoUrl: props.asset.logoUrl !== undefined ? props.asset.logoUrl : undefined,
476
+ description: props.asset.description !== undefined ? props.asset.description : undefined,
477
+ cik: props.asset.cik !== undefined ? props.asset.cik : undefined,
478
+ exchange: props.asset.exchange !== undefined ? props.asset.exchange : undefined,
479
+ currency: props.asset.currency !== undefined ? props.asset.currency : undefined,
480
+ country: props.asset.country !== undefined ? props.asset.country : undefined,
481
+ sector: props.asset.sector !== undefined ? props.asset.sector : undefined,
482
+ industry: props.asset.industry !== undefined ? props.asset.industry : undefined,
483
+ address: props.asset.address !== undefined ? props.asset.address : undefined,
484
+ officialSite: props.asset.officialSite !== undefined ? props.asset.officialSite : undefined,
485
+ fiscalYearEnd: props.asset.fiscalYearEnd !== undefined ? props.asset.fiscalYearEnd : undefined,
486
+ latestQuarter: props.asset.latestQuarter !== undefined ? props.asset.latestQuarter : undefined,
487
+ marketCapitalization: props.asset.marketCapitalization !== undefined ? props.asset.marketCapitalization : undefined,
488
+ ebitda: props.asset.ebitda !== undefined ? props.asset.ebitda : undefined,
489
+ peRatio: props.asset.peRatio !== undefined ? props.asset.peRatio : undefined,
490
+ pegRatio: props.asset.pegRatio !== undefined ? props.asset.pegRatio : undefined,
491
+ bookValue: props.asset.bookValue !== undefined ? props.asset.bookValue : undefined,
492
+ dividendPerShare: props.asset.dividendPerShare !== undefined ? props.asset.dividendPerShare : undefined,
493
+ dividendYield: props.asset.dividendYield !== undefined ? props.asset.dividendYield : undefined,
494
+ eps: props.asset.eps !== undefined ? props.asset.eps : undefined,
495
+ revenuePerShareTTM: props.asset.revenuePerShareTTM !== undefined ? props.asset.revenuePerShareTTM : undefined,
496
+ profitMargin: props.asset.profitMargin !== undefined ? props.asset.profitMargin : undefined,
497
+ operatingMarginTTM: props.asset.operatingMarginTTM !== undefined ? props.asset.operatingMarginTTM : undefined,
498
+ returnOnAssetsTTM: props.asset.returnOnAssetsTTM !== undefined ? props.asset.returnOnAssetsTTM : undefined,
499
+ returnOnEquityTTM: props.asset.returnOnEquityTTM !== undefined ? props.asset.returnOnEquityTTM : undefined,
500
+ revenueTTM: props.asset.revenueTTM !== undefined ? props.asset.revenueTTM : undefined,
501
+ grossProfitTTM: props.asset.grossProfitTTM !== undefined ? props.asset.grossProfitTTM : undefined,
502
+ dilutedEPSTTM: props.asset.dilutedEPSTTM !== undefined ? props.asset.dilutedEPSTTM : undefined,
503
+ quarterlyEarningsGrowthYOY: props.asset.quarterlyEarningsGrowthYOY !== undefined ? props.asset.quarterlyEarningsGrowthYOY : undefined,
504
+ quarterlyRevenueGrowthYOY: props.asset.quarterlyRevenueGrowthYOY !== undefined ? props.asset.quarterlyRevenueGrowthYOY : undefined,
505
+ analystTargetPrice: props.asset.analystTargetPrice !== undefined ? props.asset.analystTargetPrice : undefined,
506
+ analystRatingStrongBuy: props.asset.analystRatingStrongBuy !== undefined ? props.asset.analystRatingStrongBuy : undefined,
507
+ analystRatingBuy: props.asset.analystRatingBuy !== undefined ? props.asset.analystRatingBuy : undefined,
508
+ analystRatingHold: props.asset.analystRatingHold !== undefined ? props.asset.analystRatingHold : undefined,
509
+ analystRatingSell: props.asset.analystRatingSell !== undefined ? props.asset.analystRatingSell : undefined,
510
+ analystRatingStrongSell: props.asset.analystRatingStrongSell !== undefined ? props.asset.analystRatingStrongSell : undefined,
511
+ trailingPE: props.asset.trailingPE !== undefined ? props.asset.trailingPE : undefined,
512
+ forwardPE: props.asset.forwardPE !== undefined ? props.asset.forwardPE : undefined,
513
+ priceToSalesRatioTTM: props.asset.priceToSalesRatioTTM !== undefined ? props.asset.priceToSalesRatioTTM : undefined,
514
+ priceToBookRatio: props.asset.priceToBookRatio !== undefined ? props.asset.priceToBookRatio : undefined,
515
+ evToRevenue: props.asset.evToRevenue !== undefined ? props.asset.evToRevenue : undefined,
516
+ evToEbitda: props.asset.evToEbitda !== undefined ? props.asset.evToEbitda : undefined,
517
+ beta: props.asset.beta !== undefined ? props.asset.beta : undefined,
518
+ week52High: props.asset.week52High !== undefined ? props.asset.week52High : undefined,
519
+ week52Low: props.asset.week52Low !== undefined ? props.asset.week52Low : undefined,
520
+ day50MovingAverage: props.asset.day50MovingAverage !== undefined ? props.asset.day50MovingAverage : undefined,
521
+ day200MovingAverage: props.asset.day200MovingAverage !== undefined ? props.asset.day200MovingAverage : undefined,
522
+ sharesOutstanding: props.asset.sharesOutstanding !== undefined ? props.asset.sharesOutstanding : undefined,
523
+ dividendDate: props.asset.dividendDate !== undefined ? props.asset.dividendDate : undefined,
524
+ exDividendDate: props.asset.exDividendDate !== undefined ? props.asset.exDividendDate : undefined,
525
+ sellPrice: props.asset.sellPrice !== undefined ? props.asset.sellPrice : undefined,
526
+ buyPrice: props.asset.buyPrice !== undefined ? props.asset.buyPrice : undefined,
527
+ trades: props.asset.trades ?
528
+ typeof props.asset.trades[0] === 'object' && Object.keys(props.asset.trades).length === 1 && Object.keys(props.asset.trades)[0] === 'id'
529
+ ? { connect: props.asset.trades.map((item) => ({
530
+ id: item.id
531
+ }))
532
+ }
533
+ : { connectOrCreate: props.asset.trades.map((item) => ({
534
+ where: {
535
+ id: item.id !== undefined ? item.id : undefined,
536
+ },
537
+ create: {
538
+ qty: item.qty !== undefined ? item.qty : undefined,
539
+ price: item.price !== undefined ? item.price : undefined,
540
+ total: item.total !== undefined ? item.total : undefined,
541
+ signal: item.signal !== undefined ? item.signal : undefined,
542
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
543
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
544
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
545
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
546
+ status: item.status !== undefined ? item.status : undefined,
547
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
548
+ },
549
+ }))
550
+ } : undefined,
551
+ positions: props.asset.positions ?
552
+ typeof props.asset.positions[0] === 'object' && Object.keys(props.asset.positions).length === 1 && Object.keys(props.asset.positions)[0] === 'id'
553
+ ? { connect: props.asset.positions.map((item) => ({
554
+ id: item.id
555
+ }))
556
+ }
557
+ : { connectOrCreate: props.asset.positions.map((item) => ({
558
+ where: {
559
+ id: item.id !== undefined ? item.id : undefined,
560
+ },
561
+ create: {
562
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
563
+ qty: item.qty !== undefined ? item.qty : undefined,
564
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
565
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
566
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
567
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
568
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
569
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
570
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
571
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
572
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
573
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
574
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
575
+ },
576
+ }))
577
+ } : undefined,
578
+ newsMentions: props.asset.newsMentions ?
579
+ typeof props.asset.newsMentions[0] === 'object' && Object.keys(props.asset.newsMentions).length === 1 && Object.keys(props.asset.newsMentions)[0] === 'id'
580
+ ? { connect: props.asset.newsMentions.map((item) => ({
581
+ id: item.id
582
+ }))
583
+ }
584
+ : { connectOrCreate: props.asset.newsMentions.map((item) => ({
585
+ where: {
586
+ id: item.id !== undefined ? item.id : undefined,
587
+ url: item.url !== undefined ? item.url : undefined,
588
+ },
589
+ create: {
590
+ url: item.url !== undefined ? item.url : undefined,
591
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
592
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
593
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
594
+ },
595
+ }))
596
+ } : undefined,
597
+ },
598
+ }
599
+ } : undefined,
545
600
  },
546
601
  };
547
602
  const filteredVariables = (0, utils_1.removeUndefinedProps)(variables);
@@ -1185,81 +1240,101 @@ exports.Order = {
1185
1240
  APISecret: props.alpacaAccount.APISecret !== undefined ? props.alpacaAccount.APISecret : undefined,
1186
1241
  configuration: props.alpacaAccount.configuration !== undefined ? props.alpacaAccount.configuration : undefined,
1187
1242
  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,
1243
+ user: props.alpacaAccount.user ?
1244
+ typeof props.alpacaAccount.user === 'object' && Object.keys(props.alpacaAccount.user).length === 1 && Object.keys(props.alpacaAccount.user)[0] === 'id'
1245
+ ? { connect: {
1246
+ id: props.alpacaAccount.user.id
1247
+ }
1248
+ }
1249
+ : { connectOrCreate: {
1250
+ where: {
1251
+ id: props.alpacaAccount.user.id !== undefined ? props.alpacaAccount.user.id : undefined,
1252
+ email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
1253
+ name: props.alpacaAccount.user.name !== undefined ? {
1254
+ equals: props.alpacaAccount.user.name
1255
+ } : undefined,
1256
+ },
1257
+ create: {
1258
+ name: props.alpacaAccount.user.name !== undefined ? props.alpacaAccount.user.name : undefined,
1259
+ email: props.alpacaAccount.user.email !== undefined ? props.alpacaAccount.user.email : undefined,
1260
+ emailVerified: props.alpacaAccount.user.emailVerified !== undefined ? props.alpacaAccount.user.emailVerified : undefined,
1261
+ image: props.alpacaAccount.user.image !== undefined ? props.alpacaAccount.user.image : undefined,
1262
+ role: props.alpacaAccount.user.role !== undefined ? props.alpacaAccount.user.role : undefined,
1263
+ bio: props.alpacaAccount.user.bio !== undefined ? props.alpacaAccount.user.bio : undefined,
1264
+ jobTitle: props.alpacaAccount.user.jobTitle !== undefined ? props.alpacaAccount.user.jobTitle : undefined,
1265
+ currentAccount: props.alpacaAccount.user.currentAccount !== undefined ? props.alpacaAccount.user.currentAccount : undefined,
1266
+ plan: props.alpacaAccount.user.plan !== undefined ? props.alpacaAccount.user.plan : undefined,
1267
+ },
1268
+ }
1269
+ } : undefined,
1270
+ trades: props.alpacaAccount.trades ?
1271
+ typeof props.alpacaAccount.trades[0] === 'object' && Object.keys(props.alpacaAccount.trades).length === 1 && Object.keys(props.alpacaAccount.trades)[0] === 'id'
1272
+ ? { connect: props.alpacaAccount.trades.map((item) => ({
1273
+ id: item.id
1274
+ }))
1275
+ }
1276
+ : { connectOrCreate: props.alpacaAccount.trades.map((item) => ({
1277
+ where: {
1278
+ id: item.id !== undefined ? item.id : undefined,
1279
+ },
1280
+ create: {
1281
+ qty: item.qty !== undefined ? item.qty : undefined,
1282
+ price: item.price !== undefined ? item.price : undefined,
1283
+ total: item.total !== undefined ? item.total : undefined,
1284
+ signal: item.signal !== undefined ? item.signal : undefined,
1285
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
1286
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
1287
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
1288
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1289
+ status: item.status !== undefined ? item.status : undefined,
1290
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1291
+ },
1292
+ }))
1293
+ } : undefined,
1294
+ positions: props.alpacaAccount.positions ?
1295
+ typeof props.alpacaAccount.positions[0] === 'object' && Object.keys(props.alpacaAccount.positions).length === 1 && Object.keys(props.alpacaAccount.positions)[0] === 'id'
1296
+ ? { connect: props.alpacaAccount.positions.map((item) => ({
1297
+ id: item.id
1298
+ }))
1299
+ }
1300
+ : { connectOrCreate: props.alpacaAccount.positions.map((item) => ({
1301
+ where: {
1302
+ id: item.id !== undefined ? item.id : undefined,
1303
+ },
1304
+ create: {
1305
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
1306
+ qty: item.qty !== undefined ? item.qty : undefined,
1307
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
1308
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
1309
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
1310
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
1311
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
1312
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
1313
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
1314
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
1315
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1316
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1317
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
1318
+ },
1319
+ }))
1320
+ } : undefined,
1321
+ alerts: props.alpacaAccount.alerts ?
1322
+ typeof props.alpacaAccount.alerts[0] === 'object' && Object.keys(props.alpacaAccount.alerts).length === 1 && Object.keys(props.alpacaAccount.alerts)[0] === 'id'
1323
+ ? { connect: props.alpacaAccount.alerts.map((item) => ({
1324
+ id: item.id
1325
+ }))
1326
+ }
1327
+ : { connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
1328
+ where: {
1329
+ id: item.id !== undefined ? item.id : undefined,
1330
+ },
1331
+ create: {
1332
+ message: item.message !== undefined ? item.message : undefined,
1333
+ type: item.type !== undefined ? item.type : undefined,
1334
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
1335
+ },
1336
+ }))
1337
+ } : undefined,
1263
1338
  },
1264
1339
  }
1265
1340
  } : undefined,
@@ -1352,25 +1427,30 @@ exports.Order = {
1352
1427
  note: props.action.note !== undefined ? props.action.note : undefined,
1353
1428
  status: props.action.status !== undefined ? props.action.status : undefined,
1354
1429
  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,
1430
+ trade: props.action.trade ?
1431
+ typeof props.action.trade === 'object' && Object.keys(props.action.trade).length === 1 && Object.keys(props.action.trade)[0] === 'id'
1432
+ ? { connect: {
1433
+ id: props.action.trade.id
1434
+ }
1435
+ }
1436
+ : { connectOrCreate: {
1437
+ where: {
1438
+ id: props.action.trade.id !== undefined ? props.action.trade.id : undefined,
1439
+ },
1440
+ create: {
1441
+ qty: props.action.trade.qty !== undefined ? props.action.trade.qty : undefined,
1442
+ price: props.action.trade.price !== undefined ? props.action.trade.price : undefined,
1443
+ total: props.action.trade.total !== undefined ? props.action.trade.total : undefined,
1444
+ signal: props.action.trade.signal !== undefined ? props.action.trade.signal : undefined,
1445
+ strategy: props.action.trade.strategy !== undefined ? props.action.trade.strategy : undefined,
1446
+ analysis: props.action.trade.analysis !== undefined ? props.action.trade.analysis : undefined,
1447
+ confidence: props.action.trade.confidence !== undefined ? props.action.trade.confidence : undefined,
1448
+ timestamp: props.action.trade.timestamp !== undefined ? props.action.trade.timestamp : undefined,
1449
+ status: props.action.trade.status !== undefined ? props.action.trade.status : undefined,
1450
+ optionContractType: props.action.trade.optionContractType !== undefined ? props.action.trade.optionContractType : undefined,
1451
+ },
1452
+ }
1453
+ } : undefined,
1374
1454
  },
1375
1455
  }
1376
1456
  } : undefined,
@@ -1764,61 +1844,76 @@ exports.Order = {
1764
1844
  exDividendDate: props.asset.exDividendDate !== undefined ? props.asset.exDividendDate : undefined,
1765
1845
  sellPrice: props.asset.sellPrice !== undefined ? props.asset.sellPrice : undefined,
1766
1846
  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,
1847
+ trades: props.asset.trades ?
1848
+ typeof props.asset.trades[0] === 'object' && Object.keys(props.asset.trades).length === 1 && Object.keys(props.asset.trades)[0] === 'id'
1849
+ ? { connect: props.asset.trades.map((item) => ({
1850
+ id: item.id
1851
+ }))
1852
+ }
1853
+ : { connectOrCreate: props.asset.trades.map((item) => ({
1854
+ where: {
1855
+ id: item.id !== undefined ? item.id : undefined,
1856
+ },
1857
+ create: {
1858
+ qty: item.qty !== undefined ? item.qty : undefined,
1859
+ price: item.price !== undefined ? item.price : undefined,
1860
+ total: item.total !== undefined ? item.total : undefined,
1861
+ signal: item.signal !== undefined ? item.signal : undefined,
1862
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
1863
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
1864
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
1865
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
1866
+ status: item.status !== undefined ? item.status : undefined,
1867
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
1868
+ },
1869
+ }))
1870
+ } : undefined,
1871
+ positions: props.asset.positions ?
1872
+ typeof props.asset.positions[0] === 'object' && Object.keys(props.asset.positions).length === 1 && Object.keys(props.asset.positions)[0] === 'id'
1873
+ ? { connect: props.asset.positions.map((item) => ({
1874
+ id: item.id
1875
+ }))
1876
+ }
1877
+ : { connectOrCreate: props.asset.positions.map((item) => ({
1878
+ where: {
1879
+ id: item.id !== undefined ? item.id : undefined,
1880
+ },
1881
+ create: {
1882
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
1883
+ qty: item.qty !== undefined ? item.qty : undefined,
1884
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
1885
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
1886
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
1887
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
1888
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
1889
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
1890
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
1891
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
1892
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
1893
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
1894
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
1895
+ },
1896
+ }))
1897
+ } : undefined,
1898
+ newsMentions: props.asset.newsMentions ?
1899
+ typeof props.asset.newsMentions[0] === 'object' && Object.keys(props.asset.newsMentions).length === 1 && Object.keys(props.asset.newsMentions)[0] === 'id'
1900
+ ? { connect: props.asset.newsMentions.map((item) => ({
1901
+ id: item.id
1902
+ }))
1903
+ }
1904
+ : { connectOrCreate: props.asset.newsMentions.map((item) => ({
1905
+ where: {
1906
+ id: item.id !== undefined ? item.id : undefined,
1907
+ url: item.url !== undefined ? item.url : undefined,
1908
+ },
1909
+ create: {
1910
+ url: item.url !== undefined ? item.url : undefined,
1911
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
1912
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
1913
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
1914
+ },
1915
+ }))
1916
+ } : undefined,
1822
1917
  },
1823
1918
  }
1824
1919
  } : undefined,
@@ -2153,81 +2248,101 @@ exports.Order = {
2153
2248
  APISecret: prop.alpacaAccount.APISecret !== undefined ? prop.alpacaAccount.APISecret : undefined,
2154
2249
  configuration: prop.alpacaAccount.configuration !== undefined ? prop.alpacaAccount.configuration : undefined,
2155
2250
  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,
2251
+ user: prop.alpacaAccount.user ?
2252
+ typeof prop.alpacaAccount.user === 'object' && Object.keys(prop.alpacaAccount.user).length === 1 && Object.keys(prop.alpacaAccount.user)[0] === 'id'
2253
+ ? { connect: {
2254
+ id: prop.alpacaAccount.user.id
2255
+ }
2256
+ }
2257
+ : { connectOrCreate: {
2258
+ where: {
2259
+ id: prop.alpacaAccount.user.id !== undefined ? prop.alpacaAccount.user.id : undefined,
2260
+ email: prop.alpacaAccount.user.email !== undefined ? prop.alpacaAccount.user.email : undefined,
2261
+ name: prop.alpacaAccount.user.name !== undefined ? {
2262
+ equals: prop.alpacaAccount.user.name
2263
+ } : undefined,
2264
+ },
2265
+ create: {
2266
+ name: prop.alpacaAccount.user.name !== undefined ? prop.alpacaAccount.user.name : undefined,
2267
+ email: prop.alpacaAccount.user.email !== undefined ? prop.alpacaAccount.user.email : undefined,
2268
+ emailVerified: prop.alpacaAccount.user.emailVerified !== undefined ? prop.alpacaAccount.user.emailVerified : undefined,
2269
+ image: prop.alpacaAccount.user.image !== undefined ? prop.alpacaAccount.user.image : undefined,
2270
+ role: prop.alpacaAccount.user.role !== undefined ? prop.alpacaAccount.user.role : undefined,
2271
+ bio: prop.alpacaAccount.user.bio !== undefined ? prop.alpacaAccount.user.bio : undefined,
2272
+ jobTitle: prop.alpacaAccount.user.jobTitle !== undefined ? prop.alpacaAccount.user.jobTitle : undefined,
2273
+ currentAccount: prop.alpacaAccount.user.currentAccount !== undefined ? prop.alpacaAccount.user.currentAccount : undefined,
2274
+ plan: prop.alpacaAccount.user.plan !== undefined ? prop.alpacaAccount.user.plan : undefined,
2275
+ },
2276
+ }
2277
+ } : undefined,
2278
+ trades: prop.alpacaAccount.trades ?
2279
+ typeof prop.alpacaAccount.trades[0] === 'object' && Object.keys(prop.alpacaAccount.trades).length === 1 && Object.keys(prop.alpacaAccount.trades)[0] === 'id'
2280
+ ? { connect: prop.alpacaAccount.trades.map((item) => ({
2281
+ id: item.id
2282
+ }))
2283
+ }
2284
+ : { connectOrCreate: prop.alpacaAccount.trades.map((item) => ({
2285
+ where: {
2286
+ id: item.id !== undefined ? item.id : undefined,
2287
+ },
2288
+ create: {
2289
+ qty: item.qty !== undefined ? item.qty : undefined,
2290
+ price: item.price !== undefined ? item.price : undefined,
2291
+ total: item.total !== undefined ? item.total : undefined,
2292
+ signal: item.signal !== undefined ? item.signal : undefined,
2293
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
2294
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
2295
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
2296
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2297
+ status: item.status !== undefined ? item.status : undefined,
2298
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
2299
+ },
2300
+ }))
2301
+ } : undefined,
2302
+ positions: prop.alpacaAccount.positions ?
2303
+ typeof prop.alpacaAccount.positions[0] === 'object' && Object.keys(prop.alpacaAccount.positions).length === 1 && Object.keys(prop.alpacaAccount.positions)[0] === 'id'
2304
+ ? { connect: prop.alpacaAccount.positions.map((item) => ({
2305
+ id: item.id
2306
+ }))
2307
+ }
2308
+ : { connectOrCreate: prop.alpacaAccount.positions.map((item) => ({
2309
+ where: {
2310
+ id: item.id !== undefined ? item.id : undefined,
2311
+ },
2312
+ create: {
2313
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2314
+ qty: item.qty !== undefined ? item.qty : undefined,
2315
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2316
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2317
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2318
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2319
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2320
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2321
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2322
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2323
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2324
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2325
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2326
+ },
2327
+ }))
2328
+ } : undefined,
2329
+ alerts: prop.alpacaAccount.alerts ?
2330
+ typeof prop.alpacaAccount.alerts[0] === 'object' && Object.keys(prop.alpacaAccount.alerts).length === 1 && Object.keys(prop.alpacaAccount.alerts)[0] === 'id'
2331
+ ? { connect: prop.alpacaAccount.alerts.map((item) => ({
2332
+ id: item.id
2333
+ }))
2334
+ }
2335
+ : { connectOrCreate: prop.alpacaAccount.alerts.map((item) => ({
2336
+ where: {
2337
+ id: item.id !== undefined ? item.id : undefined,
2338
+ },
2339
+ create: {
2340
+ message: item.message !== undefined ? item.message : undefined,
2341
+ type: item.type !== undefined ? item.type : undefined,
2342
+ isRead: item.isRead !== undefined ? item.isRead : undefined,
2343
+ },
2344
+ }))
2345
+ } : undefined,
2231
2346
  },
2232
2347
  }
2233
2348
  } : undefined,
@@ -2320,25 +2435,30 @@ exports.Order = {
2320
2435
  note: prop.action.note !== undefined ? prop.action.note : undefined,
2321
2436
  status: prop.action.status !== undefined ? prop.action.status : undefined,
2322
2437
  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,
2438
+ trade: prop.action.trade ?
2439
+ typeof prop.action.trade === 'object' && Object.keys(prop.action.trade).length === 1 && Object.keys(prop.action.trade)[0] === 'id'
2440
+ ? { connect: {
2441
+ id: prop.action.trade.id
2442
+ }
2443
+ }
2444
+ : { connectOrCreate: {
2445
+ where: {
2446
+ id: prop.action.trade.id !== undefined ? prop.action.trade.id : undefined,
2447
+ },
2448
+ create: {
2449
+ qty: prop.action.trade.qty !== undefined ? prop.action.trade.qty : undefined,
2450
+ price: prop.action.trade.price !== undefined ? prop.action.trade.price : undefined,
2451
+ total: prop.action.trade.total !== undefined ? prop.action.trade.total : undefined,
2452
+ signal: prop.action.trade.signal !== undefined ? prop.action.trade.signal : undefined,
2453
+ strategy: prop.action.trade.strategy !== undefined ? prop.action.trade.strategy : undefined,
2454
+ analysis: prop.action.trade.analysis !== undefined ? prop.action.trade.analysis : undefined,
2455
+ confidence: prop.action.trade.confidence !== undefined ? prop.action.trade.confidence : undefined,
2456
+ timestamp: prop.action.trade.timestamp !== undefined ? prop.action.trade.timestamp : undefined,
2457
+ status: prop.action.trade.status !== undefined ? prop.action.trade.status : undefined,
2458
+ optionContractType: prop.action.trade.optionContractType !== undefined ? prop.action.trade.optionContractType : undefined,
2459
+ },
2460
+ }
2461
+ } : undefined,
2342
2462
  },
2343
2463
  }
2344
2464
  } : undefined,
@@ -2732,61 +2852,76 @@ exports.Order = {
2732
2852
  exDividendDate: prop.asset.exDividendDate !== undefined ? prop.asset.exDividendDate : undefined,
2733
2853
  sellPrice: prop.asset.sellPrice !== undefined ? prop.asset.sellPrice : undefined,
2734
2854
  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,
2855
+ trades: prop.asset.trades ?
2856
+ typeof prop.asset.trades[0] === 'object' && Object.keys(prop.asset.trades).length === 1 && Object.keys(prop.asset.trades)[0] === 'id'
2857
+ ? { connect: prop.asset.trades.map((item) => ({
2858
+ id: item.id
2859
+ }))
2860
+ }
2861
+ : { connectOrCreate: prop.asset.trades.map((item) => ({
2862
+ where: {
2863
+ id: item.id !== undefined ? item.id : undefined,
2864
+ },
2865
+ create: {
2866
+ qty: item.qty !== undefined ? item.qty : undefined,
2867
+ price: item.price !== undefined ? item.price : undefined,
2868
+ total: item.total !== undefined ? item.total : undefined,
2869
+ signal: item.signal !== undefined ? item.signal : undefined,
2870
+ strategy: item.strategy !== undefined ? item.strategy : undefined,
2871
+ analysis: item.analysis !== undefined ? item.analysis : undefined,
2872
+ confidence: item.confidence !== undefined ? item.confidence : undefined,
2873
+ timestamp: item.timestamp !== undefined ? item.timestamp : undefined,
2874
+ status: item.status !== undefined ? item.status : undefined,
2875
+ optionContractType: item.optionContractType !== undefined ? item.optionContractType : undefined,
2876
+ },
2877
+ }))
2878
+ } : undefined,
2879
+ positions: prop.asset.positions ?
2880
+ typeof prop.asset.positions[0] === 'object' && Object.keys(prop.asset.positions).length === 1 && Object.keys(prop.asset.positions)[0] === 'id'
2881
+ ? { connect: prop.asset.positions.map((item) => ({
2882
+ id: item.id
2883
+ }))
2884
+ }
2885
+ : { connectOrCreate: prop.asset.positions.map((item) => ({
2886
+ where: {
2887
+ id: item.id !== undefined ? item.id : undefined,
2888
+ },
2889
+ create: {
2890
+ averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
2891
+ qty: item.qty !== undefined ? item.qty : undefined,
2892
+ qtyAvailable: item.qtyAvailable !== undefined ? item.qtyAvailable : undefined,
2893
+ marketValue: item.marketValue !== undefined ? item.marketValue : undefined,
2894
+ costBasis: item.costBasis !== undefined ? item.costBasis : undefined,
2895
+ unrealizedPL: item.unrealizedPL !== undefined ? item.unrealizedPL : undefined,
2896
+ unrealizedPLPC: item.unrealizedPLPC !== undefined ? item.unrealizedPLPC : undefined,
2897
+ unrealisedIntradayPL: item.unrealisedIntradayPL !== undefined ? item.unrealisedIntradayPL : undefined,
2898
+ unrealisedIntradayPLPC: item.unrealisedIntradayPLPC !== undefined ? item.unrealisedIntradayPLPC : undefined,
2899
+ currentPrice: item.currentPrice !== undefined ? item.currentPrice : undefined,
2900
+ lastTradePrice: item.lastTradePrice !== undefined ? item.lastTradePrice : undefined,
2901
+ changeToday: item.changeToday !== undefined ? item.changeToday : undefined,
2902
+ assetMarginable: item.assetMarginable !== undefined ? item.assetMarginable : undefined,
2903
+ },
2904
+ }))
2905
+ } : undefined,
2906
+ newsMentions: prop.asset.newsMentions ?
2907
+ typeof prop.asset.newsMentions[0] === 'object' && Object.keys(prop.asset.newsMentions).length === 1 && Object.keys(prop.asset.newsMentions)[0] === 'id'
2908
+ ? { connect: prop.asset.newsMentions.map((item) => ({
2909
+ id: item.id
2910
+ }))
2911
+ }
2912
+ : { connectOrCreate: prop.asset.newsMentions.map((item) => ({
2913
+ where: {
2914
+ id: item.id !== undefined ? item.id : undefined,
2915
+ url: item.url !== undefined ? item.url : undefined,
2916
+ },
2917
+ create: {
2918
+ url: item.url !== undefined ? item.url : undefined,
2919
+ relevancyScore: item.relevancyScore !== undefined ? item.relevancyScore : undefined,
2920
+ sentimentScore: item.sentimentScore !== undefined ? item.sentimentScore : undefined,
2921
+ sentimentLabel: item.sentimentLabel !== undefined ? item.sentimentLabel : undefined,
2922
+ },
2923
+ }))
2924
+ } : undefined,
2790
2925
  },
2791
2926
  }
2792
2927
  } : undefined,