adaptic-backend 1.0.159 → 1.0.161

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 (65) hide show
  1. package/Account.cjs +285 -8
  2. package/Action.cjs +615 -4
  3. package/Alert.cjs +338 -4
  4. package/AlpacaAccount.cjs +771 -4
  5. package/Asset.cjs +642 -0
  6. package/Authenticator.cjs +288 -4
  7. package/Customer.cjs +273 -10
  8. package/NewsArticle.cjs +165 -0
  9. package/NewsArticleAssetSentiment.cjs +256 -8
  10. package/Order.cjs +510 -10
  11. package/Position.cjs +546 -8
  12. package/Session.cjs +288 -4
  13. package/StopLoss.cjs +348 -1
  14. package/TakeProfit.cjs +348 -1
  15. package/Trade.cjs +607 -8
  16. package/User.cjs +261 -0
  17. package/package.json +1 -1
  18. package/server/Account.d.ts.map +1 -1
  19. package/server/Account.js.map +1 -1
  20. package/server/Account.mjs +285 -8
  21. package/server/Action.d.ts.map +1 -1
  22. package/server/Action.js.map +1 -1
  23. package/server/Action.mjs +615 -4
  24. package/server/Alert.d.ts.map +1 -1
  25. package/server/Alert.js.map +1 -1
  26. package/server/Alert.mjs +338 -4
  27. package/server/AlpacaAccount.d.ts.map +1 -1
  28. package/server/AlpacaAccount.js.map +1 -1
  29. package/server/AlpacaAccount.mjs +771 -4
  30. package/server/Asset.d.ts.map +1 -1
  31. package/server/Asset.js.map +1 -1
  32. package/server/Asset.mjs +642 -0
  33. package/server/Authenticator.d.ts.map +1 -1
  34. package/server/Authenticator.js.map +1 -1
  35. package/server/Authenticator.mjs +288 -4
  36. package/server/Customer.d.ts.map +1 -1
  37. package/server/Customer.js.map +1 -1
  38. package/server/Customer.mjs +273 -10
  39. package/server/NewsArticle.d.ts.map +1 -1
  40. package/server/NewsArticle.js.map +1 -1
  41. package/server/NewsArticle.mjs +165 -0
  42. package/server/NewsArticleAssetSentiment.d.ts.map +1 -1
  43. package/server/NewsArticleAssetSentiment.js.map +1 -1
  44. package/server/NewsArticleAssetSentiment.mjs +256 -8
  45. package/server/Order.d.ts.map +1 -1
  46. package/server/Order.js.map +1 -1
  47. package/server/Order.mjs +510 -10
  48. package/server/Position.d.ts.map +1 -1
  49. package/server/Position.js.map +1 -1
  50. package/server/Position.mjs +546 -8
  51. package/server/Session.d.ts.map +1 -1
  52. package/server/Session.js.map +1 -1
  53. package/server/Session.mjs +288 -4
  54. package/server/StopLoss.d.ts.map +1 -1
  55. package/server/StopLoss.js.map +1 -1
  56. package/server/StopLoss.mjs +348 -1
  57. package/server/TakeProfit.d.ts.map +1 -1
  58. package/server/TakeProfit.js.map +1 -1
  59. package/server/TakeProfit.mjs +348 -1
  60. package/server/Trade.d.ts.map +1 -1
  61. package/server/Trade.js.map +1 -1
  62. package/server/Trade.mjs +607 -8
  63. package/server/User.d.ts.map +1 -1
  64. package/server/User.js.map +1 -1
  65. package/server/User.mjs +261 -0
package/Trade.cjs CHANGED
@@ -296,6 +296,9 @@ exports.Trade = {
296
296
  : { connectOrCreate: {
297
297
  where: {
298
298
  id: props.alpacaAccount.id !== undefined ? props.alpacaAccount.id : undefined,
299
+ userId: props.alpacaAccount.userId !== undefined ? {
300
+ equals: props.alpacaAccount.userId
301
+ } : undefined,
299
302
  },
300
303
  create: {
301
304
  type: props.alpacaAccount.type !== undefined ? props.alpacaAccount.type : undefined,
@@ -342,9 +345,17 @@ exports.Trade = {
342
345
  : { connectOrCreate: {
343
346
  where: {
344
347
  id: props.alpacaAccount.user.customer.id !== undefined ? props.alpacaAccount.user.customer.id : undefined,
348
+ stripeCustomerId: props.alpacaAccount.user.customer.stripeCustomerId !== undefined ? props.alpacaAccount.user.customer.stripeCustomerId : undefined,
349
+ stripeSubscriptionId: props.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? props.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
350
+ authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? {
351
+ equals: props.alpacaAccount.user.customer.authUserId
352
+ } : undefined,
345
353
  name: props.alpacaAccount.user.customer.name !== undefined ? {
346
354
  equals: props.alpacaAccount.user.customer.name
347
355
  } : undefined,
356
+ stripePriceId: props.alpacaAccount.user.customer.stripePriceId !== undefined ? {
357
+ equals: props.alpacaAccount.user.customer.stripePriceId
358
+ } : undefined,
348
359
  },
349
360
  create: {
350
361
  authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? props.alpacaAccount.user.customer.authUserId : undefined,
@@ -366,6 +377,12 @@ exports.Trade = {
366
377
  : { connectOrCreate: props.alpacaAccount.user.accounts.map((item) => ({
367
378
  where: {
368
379
  id: item.id !== undefined ? item.id : undefined,
380
+ userId: item.userId !== undefined ? {
381
+ equals: item.userId
382
+ } : undefined,
383
+ providerAccountId: item.providerAccountId !== undefined ? {
384
+ equals: item.providerAccountId
385
+ } : undefined,
369
386
  },
370
387
  create: {
371
388
  type: item.type !== undefined ? item.type : undefined,
@@ -390,6 +407,9 @@ exports.Trade = {
390
407
  : { connectOrCreate: props.alpacaAccount.user.sessions.map((item) => ({
391
408
  where: {
392
409
  id: item.id !== undefined ? item.id : undefined,
410
+ userId: item.userId !== undefined ? {
411
+ equals: item.userId
412
+ } : undefined,
393
413
  },
394
414
  create: {
395
415
  sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
@@ -406,6 +426,9 @@ exports.Trade = {
406
426
  : { connectOrCreate: props.alpacaAccount.user.authenticators.map((item) => ({
407
427
  where: {
408
428
  id: item.id !== undefined ? item.id : undefined,
429
+ userId: item.userId !== undefined ? {
430
+ equals: item.userId
431
+ } : undefined,
409
432
  },
410
433
  create: {
411
434
  credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
@@ -426,6 +449,15 @@ exports.Trade = {
426
449
  : { connectOrCreate: props.alpacaAccount.orders.map((item) => ({
427
450
  where: {
428
451
  id: item.id !== undefined ? item.id : undefined,
452
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
453
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
454
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
455
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
456
+ equals: item.alpacaAccountId
457
+ } : undefined,
458
+ assetId: item.assetId !== undefined ? {
459
+ equals: item.assetId
460
+ } : undefined,
429
461
  },
430
462
  create: {
431
463
  clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
@@ -459,6 +491,7 @@ exports.Trade = {
459
491
  : { connectOrCreate: {
460
492
  where: {
461
493
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
494
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
462
495
  },
463
496
  create: {
464
497
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -475,6 +508,7 @@ exports.Trade = {
475
508
  : { connectOrCreate: {
476
509
  where: {
477
510
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
511
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
478
512
  },
479
513
  create: {
480
514
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -491,6 +525,9 @@ exports.Trade = {
491
525
  : { connectOrCreate: {
492
526
  where: {
493
527
  id: item.action.id !== undefined ? item.action.id : undefined,
528
+ tradeId: item.action.tradeId !== undefined ? {
529
+ equals: item.action.tradeId
530
+ } : undefined,
494
531
  },
495
532
  create: {
496
533
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -584,6 +621,12 @@ exports.Trade = {
584
621
  : { connectOrCreate: props.alpacaAccount.positions.map((item) => ({
585
622
  where: {
586
623
  id: item.id !== undefined ? item.id : undefined,
624
+ assetId: item.assetId !== undefined ? {
625
+ equals: item.assetId
626
+ } : undefined,
627
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
628
+ equals: item.alpacaAccountId
629
+ } : undefined,
587
630
  },
588
631
  create: {
589
632
  averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
@@ -682,6 +725,9 @@ exports.Trade = {
682
725
  : { connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
683
726
  where: {
684
727
  id: item.id !== undefined ? item.id : undefined,
728
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
729
+ equals: item.alpacaAccountId
730
+ } : undefined,
685
731
  },
686
732
  create: {
687
733
  message: item.message !== undefined ? item.message : undefined,
@@ -770,6 +816,15 @@ exports.Trade = {
770
816
  : { connectOrCreate: props.asset.orders.map((item) => ({
771
817
  where: {
772
818
  id: item.id !== undefined ? item.id : undefined,
819
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
820
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
821
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
822
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
823
+ equals: item.alpacaAccountId
824
+ } : undefined,
825
+ assetId: item.assetId !== undefined ? {
826
+ equals: item.assetId
827
+ } : undefined,
773
828
  },
774
829
  create: {
775
830
  clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
@@ -803,6 +858,7 @@ exports.Trade = {
803
858
  : { connectOrCreate: {
804
859
  where: {
805
860
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
861
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
806
862
  },
807
863
  create: {
808
864
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -819,6 +875,7 @@ exports.Trade = {
819
875
  : { connectOrCreate: {
820
876
  where: {
821
877
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
878
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
822
879
  },
823
880
  create: {
824
881
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -835,6 +892,9 @@ exports.Trade = {
835
892
  : { connectOrCreate: {
836
893
  where: {
837
894
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
895
+ userId: item.alpacaAccount.userId !== undefined ? {
896
+ equals: item.alpacaAccount.userId
897
+ } : undefined,
838
898
  },
839
899
  create: {
840
900
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -858,6 +918,9 @@ exports.Trade = {
858
918
  : { connectOrCreate: {
859
919
  where: {
860
920
  id: item.action.id !== undefined ? item.action.id : undefined,
921
+ tradeId: item.action.tradeId !== undefined ? {
922
+ equals: item.action.tradeId
923
+ } : undefined,
861
924
  },
862
925
  create: {
863
926
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -880,6 +943,12 @@ exports.Trade = {
880
943
  : { connectOrCreate: props.asset.positions.map((item) => ({
881
944
  where: {
882
945
  id: item.id !== undefined ? item.id : undefined,
946
+ assetId: item.assetId !== undefined ? {
947
+ equals: item.assetId
948
+ } : undefined,
949
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
950
+ equals: item.alpacaAccountId
951
+ } : undefined,
883
952
  },
884
953
  create: {
885
954
  averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
@@ -904,6 +973,9 @@ exports.Trade = {
904
973
  : { connectOrCreate: {
905
974
  where: {
906
975
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
976
+ userId: item.alpacaAccount.userId !== undefined ? {
977
+ equals: item.alpacaAccount.userId
978
+ } : undefined,
907
979
  },
908
980
  create: {
909
981
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -931,6 +1003,12 @@ exports.Trade = {
931
1003
  where: {
932
1004
  id: item.id !== undefined ? item.id : undefined,
933
1005
  url: item.url !== undefined ? item.url : undefined,
1006
+ assetId: item.assetId !== undefined ? {
1007
+ equals: item.assetId
1008
+ } : undefined,
1009
+ newsArticleId: item.newsArticleId !== undefined ? {
1010
+ equals: item.newsArticleId
1011
+ } : undefined,
934
1012
  },
935
1013
  create: {
936
1014
  url: item.url !== undefined ? item.url : undefined,
@@ -983,6 +1061,9 @@ exports.Trade = {
983
1061
  : { connectOrCreate: props.actions.map((item) => ({
984
1062
  where: {
985
1063
  id: item.id !== undefined ? item.id : undefined,
1064
+ tradeId: item.tradeId !== undefined ? {
1065
+ equals: item.tradeId
1066
+ } : undefined,
986
1067
  },
987
1068
  create: {
988
1069
  sequence: item.sequence !== undefined ? item.sequence : undefined,
@@ -999,6 +1080,15 @@ exports.Trade = {
999
1080
  : { connectOrCreate: {
1000
1081
  where: {
1001
1082
  id: item.order.id !== undefined ? item.order.id : undefined,
1083
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
1084
+ actionId: item.order.actionId !== undefined ? item.order.actionId : undefined,
1085
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
1086
+ alpacaAccountId: item.order.alpacaAccountId !== undefined ? {
1087
+ equals: item.order.alpacaAccountId
1088
+ } : undefined,
1089
+ assetId: item.order.assetId !== undefined ? {
1090
+ equals: item.order.assetId
1091
+ } : undefined,
1002
1092
  },
1003
1093
  create: {
1004
1094
  clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
@@ -1032,6 +1122,7 @@ exports.Trade = {
1032
1122
  : { connectOrCreate: {
1033
1123
  where: {
1034
1124
  id: item.order.stopLoss.id !== undefined ? item.order.stopLoss.id : undefined,
1125
+ orderId: item.order.stopLoss.orderId !== undefined ? item.order.stopLoss.orderId : undefined,
1035
1126
  },
1036
1127
  create: {
1037
1128
  stopPrice: item.order.stopLoss.stopPrice !== undefined ? item.order.stopLoss.stopPrice : undefined,
@@ -1048,6 +1139,7 @@ exports.Trade = {
1048
1139
  : { connectOrCreate: {
1049
1140
  where: {
1050
1141
  id: item.order.takeProfit.id !== undefined ? item.order.takeProfit.id : undefined,
1142
+ orderId: item.order.takeProfit.orderId !== undefined ? item.order.takeProfit.orderId : undefined,
1051
1143
  },
1052
1144
  create: {
1053
1145
  limitPrice: item.order.takeProfit.limitPrice !== undefined ? item.order.takeProfit.limitPrice : undefined,
@@ -1064,6 +1156,9 @@ exports.Trade = {
1064
1156
  : { connectOrCreate: {
1065
1157
  where: {
1066
1158
  id: item.order.alpacaAccount.id !== undefined ? item.order.alpacaAccount.id : undefined,
1159
+ userId: item.order.alpacaAccount.userId !== undefined ? {
1160
+ equals: item.order.alpacaAccount.userId
1161
+ } : undefined,
1067
1162
  },
1068
1163
  create: {
1069
1164
  type: item.order.alpacaAccount.type !== undefined ? item.order.alpacaAccount.type : undefined,
@@ -1237,8 +1332,12 @@ exports.Trade = {
1237
1332
  const variables = {
1238
1333
  where: {
1239
1334
  id: props.id !== undefined ? props.id : undefined,
1240
- alpacaAccountId: props.alpacaAccountId !== undefined ? props.alpacaAccountId : undefined,
1241
- assetId: props.assetId !== undefined ? props.assetId : undefined,
1335
+ alpacaAccountId: props.alpacaAccountId !== undefined ? {
1336
+ equals: props.alpacaAccountId
1337
+ } : undefined,
1338
+ assetId: props.assetId !== undefined ? {
1339
+ equals: props.assetId
1340
+ } : undefined,
1242
1341
  qty: props.qty !== undefined ? props.qty : undefined,
1243
1342
  price: props.price !== undefined ? props.price : undefined,
1244
1343
  total: props.total !== undefined ? props.total : undefined,
@@ -1302,6 +1401,9 @@ exports.Trade = {
1302
1401
  id: props.alpacaAccount.id !== undefined ? {
1303
1402
  equals: props.alpacaAccount.id
1304
1403
  } : undefined,
1404
+ userId: props.alpacaAccount.userId !== undefined ? {
1405
+ equals: props.alpacaAccount.userId
1406
+ } : undefined,
1305
1407
  },
1306
1408
  update: {
1307
1409
  id: props.alpacaAccount.id !== undefined ? {
@@ -1390,9 +1492,21 @@ exports.Trade = {
1390
1492
  id: props.alpacaAccount.user.customer.id !== undefined ? {
1391
1493
  equals: props.alpacaAccount.user.customer.id
1392
1494
  } : undefined,
1495
+ authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? {
1496
+ equals: props.alpacaAccount.user.customer.authUserId
1497
+ } : undefined,
1393
1498
  name: props.alpacaAccount.user.customer.name !== undefined ? {
1394
1499
  equals: props.alpacaAccount.user.customer.name
1395
1500
  } : undefined,
1501
+ stripeCustomerId: props.alpacaAccount.user.customer.stripeCustomerId !== undefined ? {
1502
+ equals: props.alpacaAccount.user.customer.stripeCustomerId
1503
+ } : undefined,
1504
+ stripeSubscriptionId: props.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? {
1505
+ equals: props.alpacaAccount.user.customer.stripeSubscriptionId
1506
+ } : undefined,
1507
+ stripePriceId: props.alpacaAccount.user.customer.stripePriceId !== undefined ? {
1508
+ equals: props.alpacaAccount.user.customer.stripePriceId
1509
+ } : undefined,
1396
1510
  },
1397
1511
  update: {
1398
1512
  authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? {
@@ -1432,6 +1546,12 @@ exports.Trade = {
1432
1546
  upsert: props.alpacaAccount.user.accounts.map((item) => ({
1433
1547
  where: {
1434
1548
  id: item.id !== undefined ? item.id : undefined,
1549
+ userId: item.userId !== undefined ? {
1550
+ equals: item.userId
1551
+ } : undefined,
1552
+ providerAccountId: item.providerAccountId !== undefined ? {
1553
+ equals: item.providerAccountId
1554
+ } : undefined,
1435
1555
  },
1436
1556
  update: {
1437
1557
  id: item.id !== undefined ? {
@@ -1486,6 +1606,9 @@ exports.Trade = {
1486
1606
  upsert: props.alpacaAccount.user.sessions.map((item) => ({
1487
1607
  where: {
1488
1608
  id: item.id !== undefined ? item.id : undefined,
1609
+ userId: item.userId !== undefined ? {
1610
+ equals: item.userId
1611
+ } : undefined,
1489
1612
  },
1490
1613
  update: {
1491
1614
  id: item.id !== undefined ? {
@@ -1508,6 +1631,9 @@ exports.Trade = {
1508
1631
  upsert: props.alpacaAccount.user.authenticators.map((item) => ({
1509
1632
  where: {
1510
1633
  id: item.id !== undefined ? item.id : undefined,
1634
+ userId: item.userId !== undefined ? {
1635
+ equals: item.userId
1636
+ } : undefined,
1511
1637
  },
1512
1638
  update: {
1513
1639
  id: item.id !== undefined ? {
@@ -1552,9 +1678,17 @@ exports.Trade = {
1552
1678
  : { connectOrCreate: {
1553
1679
  where: {
1554
1680
  id: props.alpacaAccount.user.customer.id !== undefined ? props.alpacaAccount.user.customer.id : undefined,
1681
+ stripeCustomerId: props.alpacaAccount.user.customer.stripeCustomerId !== undefined ? props.alpacaAccount.user.customer.stripeCustomerId : undefined,
1682
+ stripeSubscriptionId: props.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? props.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
1683
+ authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? {
1684
+ equals: props.alpacaAccount.user.customer.authUserId
1685
+ } : undefined,
1555
1686
  name: props.alpacaAccount.user.customer.name !== undefined ? {
1556
1687
  equals: props.alpacaAccount.user.customer.name
1557
1688
  } : undefined,
1689
+ stripePriceId: props.alpacaAccount.user.customer.stripePriceId !== undefined ? {
1690
+ equals: props.alpacaAccount.user.customer.stripePriceId
1691
+ } : undefined,
1558
1692
  },
1559
1693
  create: {
1560
1694
  authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? props.alpacaAccount.user.customer.authUserId : undefined,
@@ -1576,6 +1710,12 @@ exports.Trade = {
1576
1710
  : { connectOrCreate: props.alpacaAccount.user.accounts.map((item) => ({
1577
1711
  where: {
1578
1712
  id: item.id !== undefined ? item.id : undefined,
1713
+ userId: item.userId !== undefined ? {
1714
+ equals: item.userId
1715
+ } : undefined,
1716
+ providerAccountId: item.providerAccountId !== undefined ? {
1717
+ equals: item.providerAccountId
1718
+ } : undefined,
1579
1719
  },
1580
1720
  create: {
1581
1721
  type: item.type !== undefined ? item.type : undefined,
@@ -1600,6 +1740,9 @@ exports.Trade = {
1600
1740
  : { connectOrCreate: props.alpacaAccount.user.sessions.map((item) => ({
1601
1741
  where: {
1602
1742
  id: item.id !== undefined ? item.id : undefined,
1743
+ userId: item.userId !== undefined ? {
1744
+ equals: item.userId
1745
+ } : undefined,
1603
1746
  },
1604
1747
  create: {
1605
1748
  sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
@@ -1616,6 +1759,9 @@ exports.Trade = {
1616
1759
  : { connectOrCreate: props.alpacaAccount.user.authenticators.map((item) => ({
1617
1760
  where: {
1618
1761
  id: item.id !== undefined ? item.id : undefined,
1762
+ userId: item.userId !== undefined ? {
1763
+ equals: item.userId
1764
+ } : undefined,
1619
1765
  },
1620
1766
  create: {
1621
1767
  credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
@@ -1631,6 +1777,15 @@ exports.Trade = {
1631
1777
  upsert: props.alpacaAccount.orders.map((item) => ({
1632
1778
  where: {
1633
1779
  id: item.id !== undefined ? item.id : undefined,
1780
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
1781
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
1782
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
1783
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
1784
+ equals: item.alpacaAccountId
1785
+ } : undefined,
1786
+ assetId: item.assetId !== undefined ? {
1787
+ equals: item.assetId
1788
+ } : undefined,
1634
1789
  },
1635
1790
  update: {
1636
1791
  id: item.id !== undefined ? {
@@ -1708,6 +1863,9 @@ exports.Trade = {
1708
1863
  id: item.stopLoss.id !== undefined ? {
1709
1864
  equals: item.stopLoss.id
1710
1865
  } : undefined,
1866
+ orderId: item.stopLoss.orderId !== undefined ? {
1867
+ equals: item.stopLoss.orderId
1868
+ } : undefined,
1711
1869
  },
1712
1870
  update: {
1713
1871
  id: item.stopLoss.id !== undefined ? {
@@ -1732,6 +1890,9 @@ exports.Trade = {
1732
1890
  id: item.takeProfit.id !== undefined ? {
1733
1891
  equals: item.takeProfit.id
1734
1892
  } : undefined,
1893
+ orderId: item.takeProfit.orderId !== undefined ? {
1894
+ equals: item.takeProfit.orderId
1895
+ } : undefined,
1735
1896
  },
1736
1897
  update: {
1737
1898
  id: item.takeProfit.id !== undefined ? {
@@ -1756,6 +1917,9 @@ exports.Trade = {
1756
1917
  id: item.action.id !== undefined ? {
1757
1918
  equals: item.action.id
1758
1919
  } : undefined,
1920
+ tradeId: item.action.tradeId !== undefined ? {
1921
+ equals: item.action.tradeId
1922
+ } : undefined,
1759
1923
  },
1760
1924
  update: {
1761
1925
  id: item.action.id !== undefined ? {
@@ -2061,6 +2225,7 @@ exports.Trade = {
2061
2225
  : { connectOrCreate: {
2062
2226
  where: {
2063
2227
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
2228
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
2064
2229
  },
2065
2230
  create: {
2066
2231
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -2077,6 +2242,7 @@ exports.Trade = {
2077
2242
  : { connectOrCreate: {
2078
2243
  where: {
2079
2244
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
2245
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
2080
2246
  },
2081
2247
  create: {
2082
2248
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -2093,6 +2259,9 @@ exports.Trade = {
2093
2259
  : { connectOrCreate: {
2094
2260
  where: {
2095
2261
  id: item.action.id !== undefined ? item.action.id : undefined,
2262
+ tradeId: item.action.tradeId !== undefined ? {
2263
+ equals: item.action.tradeId
2264
+ } : undefined,
2096
2265
  },
2097
2266
  create: {
2098
2267
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -2181,6 +2350,12 @@ exports.Trade = {
2181
2350
  upsert: props.alpacaAccount.positions.map((item) => ({
2182
2351
  where: {
2183
2352
  id: item.id !== undefined ? item.id : undefined,
2353
+ assetId: item.assetId !== undefined ? {
2354
+ equals: item.assetId
2355
+ } : undefined,
2356
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
2357
+ equals: item.alpacaAccountId
2358
+ } : undefined,
2184
2359
  },
2185
2360
  update: {
2186
2361
  id: item.id !== undefined ? {
@@ -2560,6 +2735,9 @@ exports.Trade = {
2560
2735
  upsert: props.alpacaAccount.alerts.map((item) => ({
2561
2736
  where: {
2562
2737
  id: item.id !== undefined ? item.id : undefined,
2738
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
2739
+ equals: item.alpacaAccountId
2740
+ } : undefined,
2563
2741
  },
2564
2742
  update: {
2565
2743
  id: item.id !== undefined ? {
@@ -2628,9 +2806,17 @@ exports.Trade = {
2628
2806
  : { connectOrCreate: {
2629
2807
  where: {
2630
2808
  id: props.alpacaAccount.user.customer.id !== undefined ? props.alpacaAccount.user.customer.id : undefined,
2809
+ stripeCustomerId: props.alpacaAccount.user.customer.stripeCustomerId !== undefined ? props.alpacaAccount.user.customer.stripeCustomerId : undefined,
2810
+ stripeSubscriptionId: props.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? props.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
2811
+ authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? {
2812
+ equals: props.alpacaAccount.user.customer.authUserId
2813
+ } : undefined,
2631
2814
  name: props.alpacaAccount.user.customer.name !== undefined ? {
2632
2815
  equals: props.alpacaAccount.user.customer.name
2633
2816
  } : undefined,
2817
+ stripePriceId: props.alpacaAccount.user.customer.stripePriceId !== undefined ? {
2818
+ equals: props.alpacaAccount.user.customer.stripePriceId
2819
+ } : undefined,
2634
2820
  },
2635
2821
  create: {
2636
2822
  authUserId: props.alpacaAccount.user.customer.authUserId !== undefined ? props.alpacaAccount.user.customer.authUserId : undefined,
@@ -2652,6 +2838,12 @@ exports.Trade = {
2652
2838
  : { connectOrCreate: props.alpacaAccount.user.accounts.map((item) => ({
2653
2839
  where: {
2654
2840
  id: item.id !== undefined ? item.id : undefined,
2841
+ userId: item.userId !== undefined ? {
2842
+ equals: item.userId
2843
+ } : undefined,
2844
+ providerAccountId: item.providerAccountId !== undefined ? {
2845
+ equals: item.providerAccountId
2846
+ } : undefined,
2655
2847
  },
2656
2848
  create: {
2657
2849
  type: item.type !== undefined ? item.type : undefined,
@@ -2676,6 +2868,9 @@ exports.Trade = {
2676
2868
  : { connectOrCreate: props.alpacaAccount.user.sessions.map((item) => ({
2677
2869
  where: {
2678
2870
  id: item.id !== undefined ? item.id : undefined,
2871
+ userId: item.userId !== undefined ? {
2872
+ equals: item.userId
2873
+ } : undefined,
2679
2874
  },
2680
2875
  create: {
2681
2876
  sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
@@ -2692,6 +2887,9 @@ exports.Trade = {
2692
2887
  : { connectOrCreate: props.alpacaAccount.user.authenticators.map((item) => ({
2693
2888
  where: {
2694
2889
  id: item.id !== undefined ? item.id : undefined,
2890
+ userId: item.userId !== undefined ? {
2891
+ equals: item.userId
2892
+ } : undefined,
2695
2893
  },
2696
2894
  create: {
2697
2895
  credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
@@ -2712,6 +2910,15 @@ exports.Trade = {
2712
2910
  : { connectOrCreate: props.alpacaAccount.orders.map((item) => ({
2713
2911
  where: {
2714
2912
  id: item.id !== undefined ? item.id : undefined,
2913
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
2914
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
2915
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
2916
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
2917
+ equals: item.alpacaAccountId
2918
+ } : undefined,
2919
+ assetId: item.assetId !== undefined ? {
2920
+ equals: item.assetId
2921
+ } : undefined,
2715
2922
  },
2716
2923
  create: {
2717
2924
  clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
@@ -2745,6 +2952,7 @@ exports.Trade = {
2745
2952
  : { connectOrCreate: {
2746
2953
  where: {
2747
2954
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
2955
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
2748
2956
  },
2749
2957
  create: {
2750
2958
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -2761,6 +2969,7 @@ exports.Trade = {
2761
2969
  : { connectOrCreate: {
2762
2970
  where: {
2763
2971
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
2972
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
2764
2973
  },
2765
2974
  create: {
2766
2975
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -2777,6 +2986,9 @@ exports.Trade = {
2777
2986
  : { connectOrCreate: {
2778
2987
  where: {
2779
2988
  id: item.action.id !== undefined ? item.action.id : undefined,
2989
+ tradeId: item.action.tradeId !== undefined ? {
2990
+ equals: item.action.tradeId
2991
+ } : undefined,
2780
2992
  },
2781
2993
  create: {
2782
2994
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -2870,6 +3082,12 @@ exports.Trade = {
2870
3082
  : { connectOrCreate: props.alpacaAccount.positions.map((item) => ({
2871
3083
  where: {
2872
3084
  id: item.id !== undefined ? item.id : undefined,
3085
+ assetId: item.assetId !== undefined ? {
3086
+ equals: item.assetId
3087
+ } : undefined,
3088
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
3089
+ equals: item.alpacaAccountId
3090
+ } : undefined,
2873
3091
  },
2874
3092
  create: {
2875
3093
  averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
@@ -2968,6 +3186,9 @@ exports.Trade = {
2968
3186
  : { connectOrCreate: props.alpacaAccount.alerts.map((item) => ({
2969
3187
  where: {
2970
3188
  id: item.id !== undefined ? item.id : undefined,
3189
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
3190
+ equals: item.alpacaAccountId
3191
+ } : undefined,
2971
3192
  },
2972
3193
  create: {
2973
3194
  message: item.message !== undefined ? item.message : undefined,
@@ -3165,6 +3386,15 @@ exports.Trade = {
3165
3386
  upsert: props.asset.orders.map((item) => ({
3166
3387
  where: {
3167
3388
  id: item.id !== undefined ? item.id : undefined,
3389
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
3390
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
3391
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
3392
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
3393
+ equals: item.alpacaAccountId
3394
+ } : undefined,
3395
+ assetId: item.assetId !== undefined ? {
3396
+ equals: item.assetId
3397
+ } : undefined,
3168
3398
  },
3169
3399
  update: {
3170
3400
  id: item.id !== undefined ? {
@@ -3242,6 +3472,9 @@ exports.Trade = {
3242
3472
  id: item.stopLoss.id !== undefined ? {
3243
3473
  equals: item.stopLoss.id
3244
3474
  } : undefined,
3475
+ orderId: item.stopLoss.orderId !== undefined ? {
3476
+ equals: item.stopLoss.orderId
3477
+ } : undefined,
3245
3478
  },
3246
3479
  update: {
3247
3480
  id: item.stopLoss.id !== undefined ? {
@@ -3266,6 +3499,9 @@ exports.Trade = {
3266
3499
  id: item.takeProfit.id !== undefined ? {
3267
3500
  equals: item.takeProfit.id
3268
3501
  } : undefined,
3502
+ orderId: item.takeProfit.orderId !== undefined ? {
3503
+ equals: item.takeProfit.orderId
3504
+ } : undefined,
3269
3505
  },
3270
3506
  update: {
3271
3507
  id: item.takeProfit.id !== undefined ? {
@@ -3290,6 +3526,9 @@ exports.Trade = {
3290
3526
  id: item.alpacaAccount.id !== undefined ? {
3291
3527
  equals: item.alpacaAccount.id
3292
3528
  } : undefined,
3529
+ userId: item.alpacaAccount.userId !== undefined ? {
3530
+ equals: item.alpacaAccount.userId
3531
+ } : undefined,
3293
3532
  },
3294
3533
  update: {
3295
3534
  id: item.alpacaAccount.id !== undefined ? {
@@ -3342,6 +3581,9 @@ exports.Trade = {
3342
3581
  id: item.action.id !== undefined ? {
3343
3582
  equals: item.action.id
3344
3583
  } : undefined,
3584
+ tradeId: item.action.tradeId !== undefined ? {
3585
+ equals: item.action.tradeId
3586
+ } : undefined,
3345
3587
  },
3346
3588
  update: {
3347
3589
  id: item.action.id !== undefined ? {
@@ -3405,6 +3647,7 @@ exports.Trade = {
3405
3647
  : { connectOrCreate: {
3406
3648
  where: {
3407
3649
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
3650
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
3408
3651
  },
3409
3652
  create: {
3410
3653
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -3421,6 +3664,7 @@ exports.Trade = {
3421
3664
  : { connectOrCreate: {
3422
3665
  where: {
3423
3666
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
3667
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
3424
3668
  },
3425
3669
  create: {
3426
3670
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -3437,6 +3681,9 @@ exports.Trade = {
3437
3681
  : { connectOrCreate: {
3438
3682
  where: {
3439
3683
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
3684
+ userId: item.alpacaAccount.userId !== undefined ? {
3685
+ equals: item.alpacaAccount.userId
3686
+ } : undefined,
3440
3687
  },
3441
3688
  create: {
3442
3689
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -3460,6 +3707,9 @@ exports.Trade = {
3460
3707
  : { connectOrCreate: {
3461
3708
  where: {
3462
3709
  id: item.action.id !== undefined ? item.action.id : undefined,
3710
+ tradeId: item.action.tradeId !== undefined ? {
3711
+ equals: item.action.tradeId
3712
+ } : undefined,
3463
3713
  },
3464
3714
  create: {
3465
3715
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -3477,6 +3727,12 @@ exports.Trade = {
3477
3727
  upsert: props.asset.positions.map((item) => ({
3478
3728
  where: {
3479
3729
  id: item.id !== undefined ? item.id : undefined,
3730
+ assetId: item.assetId !== undefined ? {
3731
+ equals: item.assetId
3732
+ } : undefined,
3733
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
3734
+ equals: item.alpacaAccountId
3735
+ } : undefined,
3480
3736
  },
3481
3737
  update: {
3482
3738
  id: item.id !== undefined ? {
@@ -3527,6 +3783,9 @@ exports.Trade = {
3527
3783
  id: item.alpacaAccount.id !== undefined ? {
3528
3784
  equals: item.alpacaAccount.id
3529
3785
  } : undefined,
3786
+ userId: item.alpacaAccount.userId !== undefined ? {
3787
+ equals: item.alpacaAccount.userId
3788
+ } : undefined,
3530
3789
  },
3531
3790
  update: {
3532
3791
  id: item.alpacaAccount.id !== undefined ? {
@@ -3597,6 +3856,9 @@ exports.Trade = {
3597
3856
  : { connectOrCreate: {
3598
3857
  where: {
3599
3858
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
3859
+ userId: item.alpacaAccount.userId !== undefined ? {
3860
+ equals: item.alpacaAccount.userId
3861
+ } : undefined,
3600
3862
  },
3601
3863
  create: {
3602
3864
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -3619,6 +3881,12 @@ exports.Trade = {
3619
3881
  where: {
3620
3882
  id: item.id !== undefined ? item.id : undefined,
3621
3883
  url: item.url !== undefined ? item.url : undefined,
3884
+ assetId: item.assetId !== undefined ? {
3885
+ equals: item.assetId
3886
+ } : undefined,
3887
+ newsArticleId: item.newsArticleId !== undefined ? {
3888
+ equals: item.newsArticleId
3889
+ } : undefined,
3622
3890
  },
3623
3891
  update: {
3624
3892
  id: item.id !== undefined ? {
@@ -3816,6 +4084,15 @@ exports.Trade = {
3816
4084
  : { connectOrCreate: props.asset.orders.map((item) => ({
3817
4085
  where: {
3818
4086
  id: item.id !== undefined ? item.id : undefined,
4087
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
4088
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
4089
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
4090
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
4091
+ equals: item.alpacaAccountId
4092
+ } : undefined,
4093
+ assetId: item.assetId !== undefined ? {
4094
+ equals: item.assetId
4095
+ } : undefined,
3819
4096
  },
3820
4097
  create: {
3821
4098
  clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
@@ -3849,6 +4126,7 @@ exports.Trade = {
3849
4126
  : { connectOrCreate: {
3850
4127
  where: {
3851
4128
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
4129
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
3852
4130
  },
3853
4131
  create: {
3854
4132
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -3865,6 +4143,7 @@ exports.Trade = {
3865
4143
  : { connectOrCreate: {
3866
4144
  where: {
3867
4145
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
4146
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
3868
4147
  },
3869
4148
  create: {
3870
4149
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -3881,6 +4160,9 @@ exports.Trade = {
3881
4160
  : { connectOrCreate: {
3882
4161
  where: {
3883
4162
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
4163
+ userId: item.alpacaAccount.userId !== undefined ? {
4164
+ equals: item.alpacaAccount.userId
4165
+ } : undefined,
3884
4166
  },
3885
4167
  create: {
3886
4168
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -3904,6 +4186,9 @@ exports.Trade = {
3904
4186
  : { connectOrCreate: {
3905
4187
  where: {
3906
4188
  id: item.action.id !== undefined ? item.action.id : undefined,
4189
+ tradeId: item.action.tradeId !== undefined ? {
4190
+ equals: item.action.tradeId
4191
+ } : undefined,
3907
4192
  },
3908
4193
  create: {
3909
4194
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -3926,6 +4211,12 @@ exports.Trade = {
3926
4211
  : { connectOrCreate: props.asset.positions.map((item) => ({
3927
4212
  where: {
3928
4213
  id: item.id !== undefined ? item.id : undefined,
4214
+ assetId: item.assetId !== undefined ? {
4215
+ equals: item.assetId
4216
+ } : undefined,
4217
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
4218
+ equals: item.alpacaAccountId
4219
+ } : undefined,
3929
4220
  },
3930
4221
  create: {
3931
4222
  averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
@@ -3950,6 +4241,9 @@ exports.Trade = {
3950
4241
  : { connectOrCreate: {
3951
4242
  where: {
3952
4243
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
4244
+ userId: item.alpacaAccount.userId !== undefined ? {
4245
+ equals: item.alpacaAccount.userId
4246
+ } : undefined,
3953
4247
  },
3954
4248
  create: {
3955
4249
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -3977,6 +4271,12 @@ exports.Trade = {
3977
4271
  where: {
3978
4272
  id: item.id !== undefined ? item.id : undefined,
3979
4273
  url: item.url !== undefined ? item.url : undefined,
4274
+ assetId: item.assetId !== undefined ? {
4275
+ equals: item.assetId
4276
+ } : undefined,
4277
+ newsArticleId: item.newsArticleId !== undefined ? {
4278
+ equals: item.newsArticleId
4279
+ } : undefined,
3980
4280
  },
3981
4281
  create: {
3982
4282
  url: item.url !== undefined ? item.url : undefined,
@@ -4024,6 +4324,9 @@ exports.Trade = {
4024
4324
  upsert: props.actions.map((item) => ({
4025
4325
  where: {
4026
4326
  id: item.id !== undefined ? item.id : undefined,
4327
+ tradeId: item.tradeId !== undefined ? {
4328
+ equals: item.tradeId
4329
+ } : undefined,
4027
4330
  },
4028
4331
  update: {
4029
4332
  id: item.id !== undefined ? {
@@ -4050,6 +4353,18 @@ exports.Trade = {
4050
4353
  id: item.order.id !== undefined ? {
4051
4354
  equals: item.order.id
4052
4355
  } : undefined,
4356
+ clientOrderId: item.order.clientOrderId !== undefined ? {
4357
+ equals: item.order.clientOrderId
4358
+ } : undefined,
4359
+ alpacaAccountId: item.order.alpacaAccountId !== undefined ? {
4360
+ equals: item.order.alpacaAccountId
4361
+ } : undefined,
4362
+ assetId: item.order.assetId !== undefined ? {
4363
+ equals: item.order.assetId
4364
+ } : undefined,
4365
+ actionId: item.order.actionId !== undefined ? {
4366
+ equals: item.order.actionId
4367
+ } : undefined,
4053
4368
  },
4054
4369
  update: {
4055
4370
  id: item.order.id !== undefined ? {
@@ -4127,6 +4442,9 @@ exports.Trade = {
4127
4442
  id: item.order.stopLoss.id !== undefined ? {
4128
4443
  equals: item.order.stopLoss.id
4129
4444
  } : undefined,
4445
+ orderId: item.order.stopLoss.orderId !== undefined ? {
4446
+ equals: item.order.stopLoss.orderId
4447
+ } : undefined,
4130
4448
  },
4131
4449
  update: {
4132
4450
  id: item.order.stopLoss.id !== undefined ? {
@@ -4151,6 +4469,9 @@ exports.Trade = {
4151
4469
  id: item.order.takeProfit.id !== undefined ? {
4152
4470
  equals: item.order.takeProfit.id
4153
4471
  } : undefined,
4472
+ orderId: item.order.takeProfit.orderId !== undefined ? {
4473
+ equals: item.order.takeProfit.orderId
4474
+ } : undefined,
4154
4475
  },
4155
4476
  update: {
4156
4477
  id: item.order.takeProfit.id !== undefined ? {
@@ -4175,6 +4496,9 @@ exports.Trade = {
4175
4496
  id: item.order.alpacaAccount.id !== undefined ? {
4176
4497
  equals: item.order.alpacaAccount.id
4177
4498
  } : undefined,
4499
+ userId: item.order.alpacaAccount.userId !== undefined ? {
4500
+ equals: item.order.alpacaAccount.userId
4501
+ } : undefined,
4178
4502
  },
4179
4503
  update: {
4180
4504
  id: item.order.alpacaAccount.id !== undefined ? {
@@ -4496,6 +4820,7 @@ exports.Trade = {
4496
4820
  : { connectOrCreate: {
4497
4821
  where: {
4498
4822
  id: item.order.stopLoss.id !== undefined ? item.order.stopLoss.id : undefined,
4823
+ orderId: item.order.stopLoss.orderId !== undefined ? item.order.stopLoss.orderId : undefined,
4499
4824
  },
4500
4825
  create: {
4501
4826
  stopPrice: item.order.stopLoss.stopPrice !== undefined ? item.order.stopLoss.stopPrice : undefined,
@@ -4512,6 +4837,7 @@ exports.Trade = {
4512
4837
  : { connectOrCreate: {
4513
4838
  where: {
4514
4839
  id: item.order.takeProfit.id !== undefined ? item.order.takeProfit.id : undefined,
4840
+ orderId: item.order.takeProfit.orderId !== undefined ? item.order.takeProfit.orderId : undefined,
4515
4841
  },
4516
4842
  create: {
4517
4843
  limitPrice: item.order.takeProfit.limitPrice !== undefined ? item.order.takeProfit.limitPrice : undefined,
@@ -4528,6 +4854,9 @@ exports.Trade = {
4528
4854
  : { connectOrCreate: {
4529
4855
  where: {
4530
4856
  id: item.order.alpacaAccount.id !== undefined ? item.order.alpacaAccount.id : undefined,
4857
+ userId: item.order.alpacaAccount.userId !== undefined ? {
4858
+ equals: item.order.alpacaAccount.userId
4859
+ } : undefined,
4531
4860
  },
4532
4861
  create: {
4533
4862
  type: item.order.alpacaAccount.type !== undefined ? item.order.alpacaAccount.type : undefined,
@@ -4632,6 +4961,15 @@ exports.Trade = {
4632
4961
  : { connectOrCreate: {
4633
4962
  where: {
4634
4963
  id: item.order.id !== undefined ? item.order.id : undefined,
4964
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
4965
+ actionId: item.order.actionId !== undefined ? item.order.actionId : undefined,
4966
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
4967
+ alpacaAccountId: item.order.alpacaAccountId !== undefined ? {
4968
+ equals: item.order.alpacaAccountId
4969
+ } : undefined,
4970
+ assetId: item.order.assetId !== undefined ? {
4971
+ equals: item.order.assetId
4972
+ } : undefined,
4635
4973
  },
4636
4974
  create: {
4637
4975
  clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
@@ -4665,6 +5003,7 @@ exports.Trade = {
4665
5003
  : { connectOrCreate: {
4666
5004
  where: {
4667
5005
  id: item.order.stopLoss.id !== undefined ? item.order.stopLoss.id : undefined,
5006
+ orderId: item.order.stopLoss.orderId !== undefined ? item.order.stopLoss.orderId : undefined,
4668
5007
  },
4669
5008
  create: {
4670
5009
  stopPrice: item.order.stopLoss.stopPrice !== undefined ? item.order.stopLoss.stopPrice : undefined,
@@ -4681,6 +5020,7 @@ exports.Trade = {
4681
5020
  : { connectOrCreate: {
4682
5021
  where: {
4683
5022
  id: item.order.takeProfit.id !== undefined ? item.order.takeProfit.id : undefined,
5023
+ orderId: item.order.takeProfit.orderId !== undefined ? item.order.takeProfit.orderId : undefined,
4684
5024
  },
4685
5025
  create: {
4686
5026
  limitPrice: item.order.takeProfit.limitPrice !== undefined ? item.order.takeProfit.limitPrice : undefined,
@@ -4697,6 +5037,9 @@ exports.Trade = {
4697
5037
  : { connectOrCreate: {
4698
5038
  where: {
4699
5039
  id: item.order.alpacaAccount.id !== undefined ? item.order.alpacaAccount.id : undefined,
5040
+ userId: item.order.alpacaAccount.userId !== undefined ? {
5041
+ equals: item.order.alpacaAccount.userId
5042
+ } : undefined,
4700
5043
  },
4701
5044
  create: {
4702
5045
  type: item.order.alpacaAccount.type !== undefined ? item.order.alpacaAccount.type : undefined,
@@ -4823,8 +5166,12 @@ exports.Trade = {
4823
5166
  const variables = props.map(prop => ({
4824
5167
  where: {
4825
5168
  id: prop.id !== undefined ? prop.id : undefined,
4826
- alpacaAccountId: prop.alpacaAccountId !== undefined ? prop.alpacaAccountId : undefined,
4827
- assetId: prop.assetId !== undefined ? prop.assetId : undefined,
5169
+ alpacaAccountId: prop.alpacaAccountId !== undefined ? {
5170
+ equals: prop.alpacaAccountId
5171
+ } : undefined,
5172
+ assetId: prop.assetId !== undefined ? {
5173
+ equals: prop.assetId
5174
+ } : undefined,
4828
5175
  qty: prop.qty !== undefined ? prop.qty : undefined,
4829
5176
  price: prop.price !== undefined ? prop.price : undefined,
4830
5177
  total: prop.total !== undefined ? prop.total : undefined,
@@ -4888,6 +5235,9 @@ exports.Trade = {
4888
5235
  id: prop.alpacaAccount.id !== undefined ? {
4889
5236
  equals: prop.alpacaAccount.id
4890
5237
  } : undefined,
5238
+ userId: prop.alpacaAccount.userId !== undefined ? {
5239
+ equals: prop.alpacaAccount.userId
5240
+ } : undefined,
4891
5241
  },
4892
5242
  update: {
4893
5243
  id: prop.alpacaAccount.id !== undefined ? {
@@ -4976,9 +5326,21 @@ exports.Trade = {
4976
5326
  id: prop.alpacaAccount.user.customer.id !== undefined ? {
4977
5327
  equals: prop.alpacaAccount.user.customer.id
4978
5328
  } : undefined,
5329
+ authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? {
5330
+ equals: prop.alpacaAccount.user.customer.authUserId
5331
+ } : undefined,
4979
5332
  name: prop.alpacaAccount.user.customer.name !== undefined ? {
4980
5333
  equals: prop.alpacaAccount.user.customer.name
4981
5334
  } : undefined,
5335
+ stripeCustomerId: prop.alpacaAccount.user.customer.stripeCustomerId !== undefined ? {
5336
+ equals: prop.alpacaAccount.user.customer.stripeCustomerId
5337
+ } : undefined,
5338
+ stripeSubscriptionId: prop.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? {
5339
+ equals: prop.alpacaAccount.user.customer.stripeSubscriptionId
5340
+ } : undefined,
5341
+ stripePriceId: prop.alpacaAccount.user.customer.stripePriceId !== undefined ? {
5342
+ equals: prop.alpacaAccount.user.customer.stripePriceId
5343
+ } : undefined,
4982
5344
  },
4983
5345
  update: {
4984
5346
  authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? {
@@ -5018,6 +5380,12 @@ exports.Trade = {
5018
5380
  upsert: prop.alpacaAccount.user.accounts.map((item) => ({
5019
5381
  where: {
5020
5382
  id: item.id !== undefined ? item.id : undefined,
5383
+ userId: item.userId !== undefined ? {
5384
+ equals: item.userId
5385
+ } : undefined,
5386
+ providerAccountId: item.providerAccountId !== undefined ? {
5387
+ equals: item.providerAccountId
5388
+ } : undefined,
5021
5389
  },
5022
5390
  update: {
5023
5391
  id: item.id !== undefined ? {
@@ -5072,6 +5440,9 @@ exports.Trade = {
5072
5440
  upsert: prop.alpacaAccount.user.sessions.map((item) => ({
5073
5441
  where: {
5074
5442
  id: item.id !== undefined ? item.id : undefined,
5443
+ userId: item.userId !== undefined ? {
5444
+ equals: item.userId
5445
+ } : undefined,
5075
5446
  },
5076
5447
  update: {
5077
5448
  id: item.id !== undefined ? {
@@ -5094,6 +5465,9 @@ exports.Trade = {
5094
5465
  upsert: prop.alpacaAccount.user.authenticators.map((item) => ({
5095
5466
  where: {
5096
5467
  id: item.id !== undefined ? item.id : undefined,
5468
+ userId: item.userId !== undefined ? {
5469
+ equals: item.userId
5470
+ } : undefined,
5097
5471
  },
5098
5472
  update: {
5099
5473
  id: item.id !== undefined ? {
@@ -5138,9 +5512,17 @@ exports.Trade = {
5138
5512
  : { connectOrCreate: {
5139
5513
  where: {
5140
5514
  id: prop.alpacaAccount.user.customer.id !== undefined ? prop.alpacaAccount.user.customer.id : undefined,
5515
+ stripeCustomerId: prop.alpacaAccount.user.customer.stripeCustomerId !== undefined ? prop.alpacaAccount.user.customer.stripeCustomerId : undefined,
5516
+ stripeSubscriptionId: prop.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? prop.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
5517
+ authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? {
5518
+ equals: prop.alpacaAccount.user.customer.authUserId
5519
+ } : undefined,
5141
5520
  name: prop.alpacaAccount.user.customer.name !== undefined ? {
5142
5521
  equals: prop.alpacaAccount.user.customer.name
5143
5522
  } : undefined,
5523
+ stripePriceId: prop.alpacaAccount.user.customer.stripePriceId !== undefined ? {
5524
+ equals: prop.alpacaAccount.user.customer.stripePriceId
5525
+ } : undefined,
5144
5526
  },
5145
5527
  create: {
5146
5528
  authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? prop.alpacaAccount.user.customer.authUserId : undefined,
@@ -5162,6 +5544,12 @@ exports.Trade = {
5162
5544
  : { connectOrCreate: prop.alpacaAccount.user.accounts.map((item) => ({
5163
5545
  where: {
5164
5546
  id: item.id !== undefined ? item.id : undefined,
5547
+ userId: item.userId !== undefined ? {
5548
+ equals: item.userId
5549
+ } : undefined,
5550
+ providerAccountId: item.providerAccountId !== undefined ? {
5551
+ equals: item.providerAccountId
5552
+ } : undefined,
5165
5553
  },
5166
5554
  create: {
5167
5555
  type: item.type !== undefined ? item.type : undefined,
@@ -5186,6 +5574,9 @@ exports.Trade = {
5186
5574
  : { connectOrCreate: prop.alpacaAccount.user.sessions.map((item) => ({
5187
5575
  where: {
5188
5576
  id: item.id !== undefined ? item.id : undefined,
5577
+ userId: item.userId !== undefined ? {
5578
+ equals: item.userId
5579
+ } : undefined,
5189
5580
  },
5190
5581
  create: {
5191
5582
  sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
@@ -5202,6 +5593,9 @@ exports.Trade = {
5202
5593
  : { connectOrCreate: prop.alpacaAccount.user.authenticators.map((item) => ({
5203
5594
  where: {
5204
5595
  id: item.id !== undefined ? item.id : undefined,
5596
+ userId: item.userId !== undefined ? {
5597
+ equals: item.userId
5598
+ } : undefined,
5205
5599
  },
5206
5600
  create: {
5207
5601
  credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
@@ -5217,6 +5611,15 @@ exports.Trade = {
5217
5611
  upsert: prop.alpacaAccount.orders.map((item) => ({
5218
5612
  where: {
5219
5613
  id: item.id !== undefined ? item.id : undefined,
5614
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
5615
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
5616
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
5617
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
5618
+ equals: item.alpacaAccountId
5619
+ } : undefined,
5620
+ assetId: item.assetId !== undefined ? {
5621
+ equals: item.assetId
5622
+ } : undefined,
5220
5623
  },
5221
5624
  update: {
5222
5625
  id: item.id !== undefined ? {
@@ -5294,6 +5697,9 @@ exports.Trade = {
5294
5697
  id: item.stopLoss.id !== undefined ? {
5295
5698
  equals: item.stopLoss.id
5296
5699
  } : undefined,
5700
+ orderId: item.stopLoss.orderId !== undefined ? {
5701
+ equals: item.stopLoss.orderId
5702
+ } : undefined,
5297
5703
  },
5298
5704
  update: {
5299
5705
  id: item.stopLoss.id !== undefined ? {
@@ -5318,6 +5724,9 @@ exports.Trade = {
5318
5724
  id: item.takeProfit.id !== undefined ? {
5319
5725
  equals: item.takeProfit.id
5320
5726
  } : undefined,
5727
+ orderId: item.takeProfit.orderId !== undefined ? {
5728
+ equals: item.takeProfit.orderId
5729
+ } : undefined,
5321
5730
  },
5322
5731
  update: {
5323
5732
  id: item.takeProfit.id !== undefined ? {
@@ -5342,6 +5751,9 @@ exports.Trade = {
5342
5751
  id: item.action.id !== undefined ? {
5343
5752
  equals: item.action.id
5344
5753
  } : undefined,
5754
+ tradeId: item.action.tradeId !== undefined ? {
5755
+ equals: item.action.tradeId
5756
+ } : undefined,
5345
5757
  },
5346
5758
  update: {
5347
5759
  id: item.action.id !== undefined ? {
@@ -5647,6 +6059,7 @@ exports.Trade = {
5647
6059
  : { connectOrCreate: {
5648
6060
  where: {
5649
6061
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
6062
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
5650
6063
  },
5651
6064
  create: {
5652
6065
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -5663,6 +6076,7 @@ exports.Trade = {
5663
6076
  : { connectOrCreate: {
5664
6077
  where: {
5665
6078
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
6079
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
5666
6080
  },
5667
6081
  create: {
5668
6082
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -5679,6 +6093,9 @@ exports.Trade = {
5679
6093
  : { connectOrCreate: {
5680
6094
  where: {
5681
6095
  id: item.action.id !== undefined ? item.action.id : undefined,
6096
+ tradeId: item.action.tradeId !== undefined ? {
6097
+ equals: item.action.tradeId
6098
+ } : undefined,
5682
6099
  },
5683
6100
  create: {
5684
6101
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -5767,6 +6184,12 @@ exports.Trade = {
5767
6184
  upsert: prop.alpacaAccount.positions.map((item) => ({
5768
6185
  where: {
5769
6186
  id: item.id !== undefined ? item.id : undefined,
6187
+ assetId: item.assetId !== undefined ? {
6188
+ equals: item.assetId
6189
+ } : undefined,
6190
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
6191
+ equals: item.alpacaAccountId
6192
+ } : undefined,
5770
6193
  },
5771
6194
  update: {
5772
6195
  id: item.id !== undefined ? {
@@ -6146,6 +6569,9 @@ exports.Trade = {
6146
6569
  upsert: prop.alpacaAccount.alerts.map((item) => ({
6147
6570
  where: {
6148
6571
  id: item.id !== undefined ? item.id : undefined,
6572
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
6573
+ equals: item.alpacaAccountId
6574
+ } : undefined,
6149
6575
  },
6150
6576
  update: {
6151
6577
  id: item.id !== undefined ? {
@@ -6214,9 +6640,17 @@ exports.Trade = {
6214
6640
  : { connectOrCreate: {
6215
6641
  where: {
6216
6642
  id: prop.alpacaAccount.user.customer.id !== undefined ? prop.alpacaAccount.user.customer.id : undefined,
6643
+ stripeCustomerId: prop.alpacaAccount.user.customer.stripeCustomerId !== undefined ? prop.alpacaAccount.user.customer.stripeCustomerId : undefined,
6644
+ stripeSubscriptionId: prop.alpacaAccount.user.customer.stripeSubscriptionId !== undefined ? prop.alpacaAccount.user.customer.stripeSubscriptionId : undefined,
6645
+ authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? {
6646
+ equals: prop.alpacaAccount.user.customer.authUserId
6647
+ } : undefined,
6217
6648
  name: prop.alpacaAccount.user.customer.name !== undefined ? {
6218
6649
  equals: prop.alpacaAccount.user.customer.name
6219
6650
  } : undefined,
6651
+ stripePriceId: prop.alpacaAccount.user.customer.stripePriceId !== undefined ? {
6652
+ equals: prop.alpacaAccount.user.customer.stripePriceId
6653
+ } : undefined,
6220
6654
  },
6221
6655
  create: {
6222
6656
  authUserId: prop.alpacaAccount.user.customer.authUserId !== undefined ? prop.alpacaAccount.user.customer.authUserId : undefined,
@@ -6238,6 +6672,12 @@ exports.Trade = {
6238
6672
  : { connectOrCreate: prop.alpacaAccount.user.accounts.map((item) => ({
6239
6673
  where: {
6240
6674
  id: item.id !== undefined ? item.id : undefined,
6675
+ userId: item.userId !== undefined ? {
6676
+ equals: item.userId
6677
+ } : undefined,
6678
+ providerAccountId: item.providerAccountId !== undefined ? {
6679
+ equals: item.providerAccountId
6680
+ } : undefined,
6241
6681
  },
6242
6682
  create: {
6243
6683
  type: item.type !== undefined ? item.type : undefined,
@@ -6262,6 +6702,9 @@ exports.Trade = {
6262
6702
  : { connectOrCreate: prop.alpacaAccount.user.sessions.map((item) => ({
6263
6703
  where: {
6264
6704
  id: item.id !== undefined ? item.id : undefined,
6705
+ userId: item.userId !== undefined ? {
6706
+ equals: item.userId
6707
+ } : undefined,
6265
6708
  },
6266
6709
  create: {
6267
6710
  sessionToken: item.sessionToken !== undefined ? item.sessionToken : undefined,
@@ -6278,6 +6721,9 @@ exports.Trade = {
6278
6721
  : { connectOrCreate: prop.alpacaAccount.user.authenticators.map((item) => ({
6279
6722
  where: {
6280
6723
  id: item.id !== undefined ? item.id : undefined,
6724
+ userId: item.userId !== undefined ? {
6725
+ equals: item.userId
6726
+ } : undefined,
6281
6727
  },
6282
6728
  create: {
6283
6729
  credentialID: item.credentialID !== undefined ? item.credentialID : undefined,
@@ -6298,6 +6744,15 @@ exports.Trade = {
6298
6744
  : { connectOrCreate: prop.alpacaAccount.orders.map((item) => ({
6299
6745
  where: {
6300
6746
  id: item.id !== undefined ? item.id : undefined,
6747
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
6748
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
6749
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
6750
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
6751
+ equals: item.alpacaAccountId
6752
+ } : undefined,
6753
+ assetId: item.assetId !== undefined ? {
6754
+ equals: item.assetId
6755
+ } : undefined,
6301
6756
  },
6302
6757
  create: {
6303
6758
  clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
@@ -6331,6 +6786,7 @@ exports.Trade = {
6331
6786
  : { connectOrCreate: {
6332
6787
  where: {
6333
6788
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
6789
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
6334
6790
  },
6335
6791
  create: {
6336
6792
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -6347,6 +6803,7 @@ exports.Trade = {
6347
6803
  : { connectOrCreate: {
6348
6804
  where: {
6349
6805
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
6806
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
6350
6807
  },
6351
6808
  create: {
6352
6809
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -6363,6 +6820,9 @@ exports.Trade = {
6363
6820
  : { connectOrCreate: {
6364
6821
  where: {
6365
6822
  id: item.action.id !== undefined ? item.action.id : undefined,
6823
+ tradeId: item.action.tradeId !== undefined ? {
6824
+ equals: item.action.tradeId
6825
+ } : undefined,
6366
6826
  },
6367
6827
  create: {
6368
6828
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -6456,6 +6916,12 @@ exports.Trade = {
6456
6916
  : { connectOrCreate: prop.alpacaAccount.positions.map((item) => ({
6457
6917
  where: {
6458
6918
  id: item.id !== undefined ? item.id : undefined,
6919
+ assetId: item.assetId !== undefined ? {
6920
+ equals: item.assetId
6921
+ } : undefined,
6922
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
6923
+ equals: item.alpacaAccountId
6924
+ } : undefined,
6459
6925
  },
6460
6926
  create: {
6461
6927
  averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
@@ -6554,6 +7020,9 @@ exports.Trade = {
6554
7020
  : { connectOrCreate: prop.alpacaAccount.alerts.map((item) => ({
6555
7021
  where: {
6556
7022
  id: item.id !== undefined ? item.id : undefined,
7023
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
7024
+ equals: item.alpacaAccountId
7025
+ } : undefined,
6557
7026
  },
6558
7027
  create: {
6559
7028
  message: item.message !== undefined ? item.message : undefined,
@@ -6751,6 +7220,15 @@ exports.Trade = {
6751
7220
  upsert: prop.asset.orders.map((item) => ({
6752
7221
  where: {
6753
7222
  id: item.id !== undefined ? item.id : undefined,
7223
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
7224
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
7225
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
7226
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
7227
+ equals: item.alpacaAccountId
7228
+ } : undefined,
7229
+ assetId: item.assetId !== undefined ? {
7230
+ equals: item.assetId
7231
+ } : undefined,
6754
7232
  },
6755
7233
  update: {
6756
7234
  id: item.id !== undefined ? {
@@ -6828,6 +7306,9 @@ exports.Trade = {
6828
7306
  id: item.stopLoss.id !== undefined ? {
6829
7307
  equals: item.stopLoss.id
6830
7308
  } : undefined,
7309
+ orderId: item.stopLoss.orderId !== undefined ? {
7310
+ equals: item.stopLoss.orderId
7311
+ } : undefined,
6831
7312
  },
6832
7313
  update: {
6833
7314
  id: item.stopLoss.id !== undefined ? {
@@ -6852,6 +7333,9 @@ exports.Trade = {
6852
7333
  id: item.takeProfit.id !== undefined ? {
6853
7334
  equals: item.takeProfit.id
6854
7335
  } : undefined,
7336
+ orderId: item.takeProfit.orderId !== undefined ? {
7337
+ equals: item.takeProfit.orderId
7338
+ } : undefined,
6855
7339
  },
6856
7340
  update: {
6857
7341
  id: item.takeProfit.id !== undefined ? {
@@ -6876,6 +7360,9 @@ exports.Trade = {
6876
7360
  id: item.alpacaAccount.id !== undefined ? {
6877
7361
  equals: item.alpacaAccount.id
6878
7362
  } : undefined,
7363
+ userId: item.alpacaAccount.userId !== undefined ? {
7364
+ equals: item.alpacaAccount.userId
7365
+ } : undefined,
6879
7366
  },
6880
7367
  update: {
6881
7368
  id: item.alpacaAccount.id !== undefined ? {
@@ -6928,6 +7415,9 @@ exports.Trade = {
6928
7415
  id: item.action.id !== undefined ? {
6929
7416
  equals: item.action.id
6930
7417
  } : undefined,
7418
+ tradeId: item.action.tradeId !== undefined ? {
7419
+ equals: item.action.tradeId
7420
+ } : undefined,
6931
7421
  },
6932
7422
  update: {
6933
7423
  id: item.action.id !== undefined ? {
@@ -6991,6 +7481,7 @@ exports.Trade = {
6991
7481
  : { connectOrCreate: {
6992
7482
  where: {
6993
7483
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
7484
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
6994
7485
  },
6995
7486
  create: {
6996
7487
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -7007,6 +7498,7 @@ exports.Trade = {
7007
7498
  : { connectOrCreate: {
7008
7499
  where: {
7009
7500
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
7501
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
7010
7502
  },
7011
7503
  create: {
7012
7504
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -7023,6 +7515,9 @@ exports.Trade = {
7023
7515
  : { connectOrCreate: {
7024
7516
  where: {
7025
7517
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
7518
+ userId: item.alpacaAccount.userId !== undefined ? {
7519
+ equals: item.alpacaAccount.userId
7520
+ } : undefined,
7026
7521
  },
7027
7522
  create: {
7028
7523
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -7046,6 +7541,9 @@ exports.Trade = {
7046
7541
  : { connectOrCreate: {
7047
7542
  where: {
7048
7543
  id: item.action.id !== undefined ? item.action.id : undefined,
7544
+ tradeId: item.action.tradeId !== undefined ? {
7545
+ equals: item.action.tradeId
7546
+ } : undefined,
7049
7547
  },
7050
7548
  create: {
7051
7549
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -7063,6 +7561,12 @@ exports.Trade = {
7063
7561
  upsert: prop.asset.positions.map((item) => ({
7064
7562
  where: {
7065
7563
  id: item.id !== undefined ? item.id : undefined,
7564
+ assetId: item.assetId !== undefined ? {
7565
+ equals: item.assetId
7566
+ } : undefined,
7567
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
7568
+ equals: item.alpacaAccountId
7569
+ } : undefined,
7066
7570
  },
7067
7571
  update: {
7068
7572
  id: item.id !== undefined ? {
@@ -7113,6 +7617,9 @@ exports.Trade = {
7113
7617
  id: item.alpacaAccount.id !== undefined ? {
7114
7618
  equals: item.alpacaAccount.id
7115
7619
  } : undefined,
7620
+ userId: item.alpacaAccount.userId !== undefined ? {
7621
+ equals: item.alpacaAccount.userId
7622
+ } : undefined,
7116
7623
  },
7117
7624
  update: {
7118
7625
  id: item.alpacaAccount.id !== undefined ? {
@@ -7183,6 +7690,9 @@ exports.Trade = {
7183
7690
  : { connectOrCreate: {
7184
7691
  where: {
7185
7692
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
7693
+ userId: item.alpacaAccount.userId !== undefined ? {
7694
+ equals: item.alpacaAccount.userId
7695
+ } : undefined,
7186
7696
  },
7187
7697
  create: {
7188
7698
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -7205,6 +7715,12 @@ exports.Trade = {
7205
7715
  where: {
7206
7716
  id: item.id !== undefined ? item.id : undefined,
7207
7717
  url: item.url !== undefined ? item.url : undefined,
7718
+ assetId: item.assetId !== undefined ? {
7719
+ equals: item.assetId
7720
+ } : undefined,
7721
+ newsArticleId: item.newsArticleId !== undefined ? {
7722
+ equals: item.newsArticleId
7723
+ } : undefined,
7208
7724
  },
7209
7725
  update: {
7210
7726
  id: item.id !== undefined ? {
@@ -7402,6 +7918,15 @@ exports.Trade = {
7402
7918
  : { connectOrCreate: prop.asset.orders.map((item) => ({
7403
7919
  where: {
7404
7920
  id: item.id !== undefined ? item.id : undefined,
7921
+ clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
7922
+ actionId: item.actionId !== undefined ? item.actionId : undefined,
7923
+ stopLossId: item.stopLossId !== undefined ? item.stopLossId : undefined,
7924
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
7925
+ equals: item.alpacaAccountId
7926
+ } : undefined,
7927
+ assetId: item.assetId !== undefined ? {
7928
+ equals: item.assetId
7929
+ } : undefined,
7405
7930
  },
7406
7931
  create: {
7407
7932
  clientOrderId: item.clientOrderId !== undefined ? item.clientOrderId : undefined,
@@ -7435,6 +7960,7 @@ exports.Trade = {
7435
7960
  : { connectOrCreate: {
7436
7961
  where: {
7437
7962
  id: item.stopLoss.id !== undefined ? item.stopLoss.id : undefined,
7963
+ orderId: item.stopLoss.orderId !== undefined ? item.stopLoss.orderId : undefined,
7438
7964
  },
7439
7965
  create: {
7440
7966
  stopPrice: item.stopLoss.stopPrice !== undefined ? item.stopLoss.stopPrice : undefined,
@@ -7451,6 +7977,7 @@ exports.Trade = {
7451
7977
  : { connectOrCreate: {
7452
7978
  where: {
7453
7979
  id: item.takeProfit.id !== undefined ? item.takeProfit.id : undefined,
7980
+ orderId: item.takeProfit.orderId !== undefined ? item.takeProfit.orderId : undefined,
7454
7981
  },
7455
7982
  create: {
7456
7983
  limitPrice: item.takeProfit.limitPrice !== undefined ? item.takeProfit.limitPrice : undefined,
@@ -7467,6 +7994,9 @@ exports.Trade = {
7467
7994
  : { connectOrCreate: {
7468
7995
  where: {
7469
7996
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
7997
+ userId: item.alpacaAccount.userId !== undefined ? {
7998
+ equals: item.alpacaAccount.userId
7999
+ } : undefined,
7470
8000
  },
7471
8001
  create: {
7472
8002
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -7490,6 +8020,9 @@ exports.Trade = {
7490
8020
  : { connectOrCreate: {
7491
8021
  where: {
7492
8022
  id: item.action.id !== undefined ? item.action.id : undefined,
8023
+ tradeId: item.action.tradeId !== undefined ? {
8024
+ equals: item.action.tradeId
8025
+ } : undefined,
7493
8026
  },
7494
8027
  create: {
7495
8028
  sequence: item.action.sequence !== undefined ? item.action.sequence : undefined,
@@ -7512,6 +8045,12 @@ exports.Trade = {
7512
8045
  : { connectOrCreate: prop.asset.positions.map((item) => ({
7513
8046
  where: {
7514
8047
  id: item.id !== undefined ? item.id : undefined,
8048
+ assetId: item.assetId !== undefined ? {
8049
+ equals: item.assetId
8050
+ } : undefined,
8051
+ alpacaAccountId: item.alpacaAccountId !== undefined ? {
8052
+ equals: item.alpacaAccountId
8053
+ } : undefined,
7515
8054
  },
7516
8055
  create: {
7517
8056
  averageEntryPrice: item.averageEntryPrice !== undefined ? item.averageEntryPrice : undefined,
@@ -7536,6 +8075,9 @@ exports.Trade = {
7536
8075
  : { connectOrCreate: {
7537
8076
  where: {
7538
8077
  id: item.alpacaAccount.id !== undefined ? item.alpacaAccount.id : undefined,
8078
+ userId: item.alpacaAccount.userId !== undefined ? {
8079
+ equals: item.alpacaAccount.userId
8080
+ } : undefined,
7539
8081
  },
7540
8082
  create: {
7541
8083
  type: item.alpacaAccount.type !== undefined ? item.alpacaAccount.type : undefined,
@@ -7563,6 +8105,12 @@ exports.Trade = {
7563
8105
  where: {
7564
8106
  id: item.id !== undefined ? item.id : undefined,
7565
8107
  url: item.url !== undefined ? item.url : undefined,
8108
+ assetId: item.assetId !== undefined ? {
8109
+ equals: item.assetId
8110
+ } : undefined,
8111
+ newsArticleId: item.newsArticleId !== undefined ? {
8112
+ equals: item.newsArticleId
8113
+ } : undefined,
7566
8114
  },
7567
8115
  create: {
7568
8116
  url: item.url !== undefined ? item.url : undefined,
@@ -7610,6 +8158,9 @@ exports.Trade = {
7610
8158
  upsert: prop.actions.map((item) => ({
7611
8159
  where: {
7612
8160
  id: item.id !== undefined ? item.id : undefined,
8161
+ tradeId: item.tradeId !== undefined ? {
8162
+ equals: item.tradeId
8163
+ } : undefined,
7613
8164
  },
7614
8165
  update: {
7615
8166
  id: item.id !== undefined ? {
@@ -7636,6 +8187,18 @@ exports.Trade = {
7636
8187
  id: item.order.id !== undefined ? {
7637
8188
  equals: item.order.id
7638
8189
  } : undefined,
8190
+ clientOrderId: item.order.clientOrderId !== undefined ? {
8191
+ equals: item.order.clientOrderId
8192
+ } : undefined,
8193
+ alpacaAccountId: item.order.alpacaAccountId !== undefined ? {
8194
+ equals: item.order.alpacaAccountId
8195
+ } : undefined,
8196
+ assetId: item.order.assetId !== undefined ? {
8197
+ equals: item.order.assetId
8198
+ } : undefined,
8199
+ actionId: item.order.actionId !== undefined ? {
8200
+ equals: item.order.actionId
8201
+ } : undefined,
7639
8202
  },
7640
8203
  update: {
7641
8204
  id: item.order.id !== undefined ? {
@@ -7713,6 +8276,9 @@ exports.Trade = {
7713
8276
  id: item.order.stopLoss.id !== undefined ? {
7714
8277
  equals: item.order.stopLoss.id
7715
8278
  } : undefined,
8279
+ orderId: item.order.stopLoss.orderId !== undefined ? {
8280
+ equals: item.order.stopLoss.orderId
8281
+ } : undefined,
7716
8282
  },
7717
8283
  update: {
7718
8284
  id: item.order.stopLoss.id !== undefined ? {
@@ -7737,6 +8303,9 @@ exports.Trade = {
7737
8303
  id: item.order.takeProfit.id !== undefined ? {
7738
8304
  equals: item.order.takeProfit.id
7739
8305
  } : undefined,
8306
+ orderId: item.order.takeProfit.orderId !== undefined ? {
8307
+ equals: item.order.takeProfit.orderId
8308
+ } : undefined,
7740
8309
  },
7741
8310
  update: {
7742
8311
  id: item.order.takeProfit.id !== undefined ? {
@@ -7761,6 +8330,9 @@ exports.Trade = {
7761
8330
  id: item.order.alpacaAccount.id !== undefined ? {
7762
8331
  equals: item.order.alpacaAccount.id
7763
8332
  } : undefined,
8333
+ userId: item.order.alpacaAccount.userId !== undefined ? {
8334
+ equals: item.order.alpacaAccount.userId
8335
+ } : undefined,
7764
8336
  },
7765
8337
  update: {
7766
8338
  id: item.order.alpacaAccount.id !== undefined ? {
@@ -8082,6 +8654,7 @@ exports.Trade = {
8082
8654
  : { connectOrCreate: {
8083
8655
  where: {
8084
8656
  id: item.order.stopLoss.id !== undefined ? item.order.stopLoss.id : undefined,
8657
+ orderId: item.order.stopLoss.orderId !== undefined ? item.order.stopLoss.orderId : undefined,
8085
8658
  },
8086
8659
  create: {
8087
8660
  stopPrice: item.order.stopLoss.stopPrice !== undefined ? item.order.stopLoss.stopPrice : undefined,
@@ -8098,6 +8671,7 @@ exports.Trade = {
8098
8671
  : { connectOrCreate: {
8099
8672
  where: {
8100
8673
  id: item.order.takeProfit.id !== undefined ? item.order.takeProfit.id : undefined,
8674
+ orderId: item.order.takeProfit.orderId !== undefined ? item.order.takeProfit.orderId : undefined,
8101
8675
  },
8102
8676
  create: {
8103
8677
  limitPrice: item.order.takeProfit.limitPrice !== undefined ? item.order.takeProfit.limitPrice : undefined,
@@ -8114,6 +8688,9 @@ exports.Trade = {
8114
8688
  : { connectOrCreate: {
8115
8689
  where: {
8116
8690
  id: item.order.alpacaAccount.id !== undefined ? item.order.alpacaAccount.id : undefined,
8691
+ userId: item.order.alpacaAccount.userId !== undefined ? {
8692
+ equals: item.order.alpacaAccount.userId
8693
+ } : undefined,
8117
8694
  },
8118
8695
  create: {
8119
8696
  type: item.order.alpacaAccount.type !== undefined ? item.order.alpacaAccount.type : undefined,
@@ -8218,6 +8795,15 @@ exports.Trade = {
8218
8795
  : { connectOrCreate: {
8219
8796
  where: {
8220
8797
  id: item.order.id !== undefined ? item.order.id : undefined,
8798
+ clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
8799
+ actionId: item.order.actionId !== undefined ? item.order.actionId : undefined,
8800
+ stopLossId: item.order.stopLossId !== undefined ? item.order.stopLossId : undefined,
8801
+ alpacaAccountId: item.order.alpacaAccountId !== undefined ? {
8802
+ equals: item.order.alpacaAccountId
8803
+ } : undefined,
8804
+ assetId: item.order.assetId !== undefined ? {
8805
+ equals: item.order.assetId
8806
+ } : undefined,
8221
8807
  },
8222
8808
  create: {
8223
8809
  clientOrderId: item.order.clientOrderId !== undefined ? item.order.clientOrderId : undefined,
@@ -8251,6 +8837,7 @@ exports.Trade = {
8251
8837
  : { connectOrCreate: {
8252
8838
  where: {
8253
8839
  id: item.order.stopLoss.id !== undefined ? item.order.stopLoss.id : undefined,
8840
+ orderId: item.order.stopLoss.orderId !== undefined ? item.order.stopLoss.orderId : undefined,
8254
8841
  },
8255
8842
  create: {
8256
8843
  stopPrice: item.order.stopLoss.stopPrice !== undefined ? item.order.stopLoss.stopPrice : undefined,
@@ -8267,6 +8854,7 @@ exports.Trade = {
8267
8854
  : { connectOrCreate: {
8268
8855
  where: {
8269
8856
  id: item.order.takeProfit.id !== undefined ? item.order.takeProfit.id : undefined,
8857
+ orderId: item.order.takeProfit.orderId !== undefined ? item.order.takeProfit.orderId : undefined,
8270
8858
  },
8271
8859
  create: {
8272
8860
  limitPrice: item.order.takeProfit.limitPrice !== undefined ? item.order.takeProfit.limitPrice : undefined,
@@ -8283,6 +8871,9 @@ exports.Trade = {
8283
8871
  : { connectOrCreate: {
8284
8872
  where: {
8285
8873
  id: item.order.alpacaAccount.id !== undefined ? item.order.alpacaAccount.id : undefined,
8874
+ userId: item.order.alpacaAccount.userId !== undefined ? {
8875
+ equals: item.order.alpacaAccount.userId
8876
+ } : undefined,
8286
8877
  },
8287
8878
  create: {
8288
8879
  type: item.order.alpacaAccount.type !== undefined ? item.order.alpacaAccount.type : undefined,
@@ -8445,8 +9036,12 @@ exports.Trade = {
8445
9036
  const variables = {
8446
9037
  where: {
8447
9038
  id: props.id !== undefined ? props.id : undefined,
8448
- alpacaAccountId: props.alpacaAccountId !== undefined ? props.alpacaAccountId : undefined,
8449
- assetId: props.assetId !== undefined ? props.assetId : undefined,
9039
+ alpacaAccountId: props.alpacaAccountId !== undefined ? {
9040
+ equals: props.alpacaAccountId
9041
+ } : undefined,
9042
+ assetId: props.assetId !== undefined ? {
9043
+ equals: props.assetId
9044
+ } : undefined,
8450
9045
  qty: props.qty !== undefined ? props.qty : undefined,
8451
9046
  price: props.price !== undefined ? props.price : undefined,
8452
9047
  total: props.total !== undefined ? props.total : undefined,
@@ -8526,8 +9121,12 @@ exports.Trade = {
8526
9121
  id: props.id !== undefined ? {
8527
9122
  equals: props.id
8528
9123
  } : undefined,
8529
- alpacaAccountId: props.alpacaAccountId !== undefined ? props.alpacaAccountId : undefined,
8530
- assetId: props.assetId !== undefined ? props.assetId : undefined,
9124
+ alpacaAccountId: props.alpacaAccountId !== undefined ? {
9125
+ equals: props.alpacaAccountId
9126
+ } : undefined,
9127
+ assetId: props.assetId !== undefined ? {
9128
+ equals: props.assetId
9129
+ } : undefined,
8531
9130
  qty: props.qty !== undefined ? props.qty : undefined,
8532
9131
  price: props.price !== undefined ? props.price : undefined,
8533
9132
  total: props.total !== undefined ? props.total : undefined,