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