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