boosted.api.graphql_queries

  1GET_SEC_INFO_QRY = """
  2query GetSecurities($ids: [Int!]) {
  3  securities(ids: $ids) {
  4    gbiId
  5    symbol
  6    name
  7    isin
  8    currency
  9    country
 10    sector {
 11      name
 12      topParentName
 13    }
 14  }
 15}
 16"""
 17
 18# watch for changes here:
 19# https://github.com/GBI-Core/boosted-insights-web-server/blob/master/src/main/resources/graphql/watchlist.graphqls#L1 # noqa
 20WATCHLIST_ANALYSIS_QRY = """
 21query WatchlistAnalysis(
 22  $modelIds: [ID!]
 23  $portfolioIds: [ID!]
 24  $gbiIds: [Int]
 25  $date: String!
 26) {
 27  watchlistAnalysis(
 28    modelIds: $modelIds
 29    portfolioIds: $portfolioIds
 30    gbiIds: $gbiIds
 31    minDate: $date
 32    maxDate: $date
 33  ) {
 34    ...AnalysisFragment
 35    ...ExplainWeightsFragment
 36  }
 37}
 38
 39fragment AnalysisFragment on WatchlistAnalysis {
 40  gbiId
 41  analysisDates {
 42    date
 43    aggregateSignal {
 44      rating
 45      ratingDelta
 46    }
 47    portfoliosSignals {
 48      portfolioId
 49      rank
 50      signalDelta
 51      rating
 52      ratingDelta
 53    }
 54  }
 55}
 56
 57
 58fragment ExplainWeightsFragment on WatchlistAnalysis {
 59  gbiId
 60  analysisDates {
 61    date
 62    portfoliosSignals {
 63      explainWeightNeg
 64      explainWeightPos
 65    }
 66  }
 67}
 68"""
 69
 70GET_MODELS_FOR_PORTFOLIOS_QRY = """
 71query GetPortfoliosAndModels($ids: [ID!]) {
 72  portfolios(ids: $ids) {
 73    id
 74    name
 75    modelId
 76    modelName
 77  }
 78}
 79"""
 80
 81GET_EXCESS_RETURN_QRY = """
 82query GetExcessReturn($modelIds: [ID!], $gbiIds: [Int], $date: String!) {
 83  models(ids: $modelIds) {
 84    id
 85    equityExplorerData(date: $date, gbiIds: $gbiIds) {
 86      equityExplorerSummaryStatistics {
 87        gbiId
 88        ER {
 89          SP {
 90            sixMonthWindowOneMonthHorizon
 91          }
 92        }
 93      }
 94    }
 95  }
 96}
 97"""
 98
 99
100GET_IDEAS_QUERY = """
101query GetRecommendations(
102    $modelId: ID!
103    $portfolioId: ID!
104    $horizon: String!
105    $deltaHorizon: String!
106    $startDate: String!
107    $endDate: String!
108    $marketDataDate: String!
109  ) {
110    recommendations(
111      modelId: $modelId
112      portfolioId: $portfolioId
113      horizon: $horizon
114      deltaHorizon: $deltaHorizon
115      startDate: $startDate
116      endDate: $endDate
117      marketDataDate: $marketDataDate
118    ) {
119      mainCategories
120      missingRecommendations {
121        category
122        missingReason
123      }
124      recommendations {
125        category
126        dividendYield
127        reason
128        rating
129        ratingDelta
130        risk {
131          text
132        }
133        reward {
134          text
135        }
136        ER {
137          oneMonth
138          threeMonth
139          oneYear
140        }
141        security {
142          symbol
143          gbiId
144        }
145      }
146    }
147  }
148"""
149
150"""
151reasons {
152    type
153    text
154}"""
155
156STOCK_RECOMMENDATION_QUERY = """
157  query StockRecommendation(
158    $modelId: ID!
159    $portfolioId: ID!
160    $gbiId: Int!
161    $horizon: String!
162    $date: String!
163  ) {
164    stockRecommendation(
165      modelId: $modelId
166      portfolioId: $portfolioId
167      gbiId: $gbiId
168      horizon: $horizon
169      date: $date
170    ) {
171      ER {
172        oneMonth
173        threeMonth
174        oneYear
175      }
176      rewardCategories {
177        rank
178        category
179      }
180      riskCategories {
181        rank
182        category
183      }
184      reasons {
185        type
186        text
187        arrows
188      }
189      recommendation
190      rewardCategory
191      riskCategory
192    }
193  }
194"""
195
196MULTI_STOCK_RECOMMENDATION_QUERY = """
197  query StocksRecommendations(
198    $gbiIds: [Int!]
199    $strategyId: ID!
200  ) {
201    currentRecommendationsFull(
202      strategyId: $strategyId
203      gbiIds: $gbiIds
204    ) {
205      gbiId
206      recommendation1M {
207        currentCategory
208        ER {
209          oneMonth
210          threeMonth
211          oneYear
212        }
213        reward {
214          text
215        }
216        risk {
217          text
218        }
219        reasons {
220          type
221          text
222        }
223      }
224      recommendation3M {
225        currentCategory
226        ER {
227          oneMonth
228          threeMonth
229          oneYear
230        }
231        reward {
232          text
233        }
234        risk {
235          text
236        }
237        reasons {
238          type
239          text
240        }
241      }
242      recommendation1Y {
243        currentCategory
244        ER {
245          oneMonth
246          threeMonth
247          oneYear
248        }
249        reward {
250          text
251        }
252        risk {
253          text
254        }
255        reasons {
256          type
257          text
258        }
259      }
260    }
261  }
262"""
263
264PF_HOLDING_QUERY = """
265query getPortfolioHoldings(
266    $date: String!
267    $modelId: ID!
268    $portfolioId: ID!
269) {
270    portfolioHoldings (
271        date: $date
272        modelId: $modelId
273        portfolioId: $portfolioId
274    ) {
275        security {
276            symbol
277        }
278        gbiId
279    }
280}
281"""
282
283GET_PORTFOLIO_RELATIVE_DATES_QUERY = """
284query GetPortfolioRelativeDates(
285    $portfolioId: ID!
286    $relativePeriods: [String!]
287  ) {
288    portfolio(id: $portfolioId) {
289      relativeDates(relativePeriods: $relativePeriods) {
290        period
291        date
292      }
293    }
294  }
295"""
296
297GET_PORTFOLIO_FACTOR_ATTRIBUTION_QUERY = """
298query getPortfolioFactorAttribution($portfolioId: ID!, $startDate: String, $endDate: String) {
299    portfolio(id: $portfolioId) {
300      factorAttribution(startDate: $startDate, endDate: $endDate) {
301          dates
302          portfolioFactorPerformance {
303              name
304              data
305          }
306          factorBetas {
307              name
308              data
309          }
310          factorReturns {
311              name
312              data
313          }
314      }
315    }
316  }
317"""
318
319GET_MODEL_STOCK_UNIVERSE_ID_QUERY = """
320query getModelStockUniverseId($modelId: ID!) {
321    model(id: $modelId) {
322        stockUniverseId
323    }
324}
325"""
326
327GET_PROS_CONS_QUERY = """
328query GetProsCons($gbiIds: [Int!]!) {
329    bulkSecurityProsCons(gbiIds: $gbiIds) {
330        gbiId
331        pros {
332            summary
333            details
334        }
335        cons {
336            summary
337            details
338        }
339    }
340}
341"""
342
343GET_MARKET_TRENDS_UNIVERSES_QUERY = """
344query getMarketTrendsUniverses {
345  getMarketTrendsUniverses {
346    id
347    name
348  }
349}
350"""
351
352
353GENERATE_THEME_QUERY = """
354mutation generateTheme($input: GenerateThemeInput!) {
355    generateTheme(input: $input) {
356      success
357      themeId
358    }
359  }
360"""
361
362
363GET_STOCK_NEWS_QUERY = """
364query getStockNews($gbiId: Int!, $deltaHorizon: String!) {
365  getStockNewsSummary(gbiId: $gbiId, deltaHorizon: $deltaHorizon) {
366    summary
367    sourceCounts {
368      count
369    }
370  }
371  getStockNewsTopics(gbiId: $gbiId, deltaHorizon: $deltaHorizon) {
372    topicId
373    topicLabel
374    topicDescription
375    topicPolarity
376    newsItems {
377      newsId
378      headline
379      url
380      summary
381      source
382      publishedAt
383    }
384  }
385}
386"""
387
388
389GET_THEMES = """
390query getThemes(
391    $type: MarketTrendsType!, $id: String, $startDate: String!, $endDate: String!,
392    $deltaHorizon: String) {
393  themes(
394    type: $type, id: $id, startDate: $startDate, endDate: $endDate, deltaHorizon: $deltaHorizon
395  ) {
396    themeId
397    themeName
398    themeImportance
399    volatility
400    positiveStockPerformance
401    negativeStockPerformance
402  }
403}
404"""
405
406
407GET_THEMES_FOR_STOCK_WITH_REASONS = """
408query themesForStockWithReasons($gbiId: Int!, $startDate: String!, $endDate: String!) {
409    themesForStockWithReasons(gbiId: $gbiId, startDate: $startDate, endDate: $endDate) {
410        themeId
411        themeName
412        importanceScore
413        similarityScore
414        positiveThemeRelation
415        reason
416    }
417}
418"""
419
420EARNINGS_IMPACTS_CALENDAR_FOR_STOCK = """
421query GetEarningsCalendarForStock($gbiId: Int!, $date: String!, $days: Int) {
422  earningsCalendarForStock(gbiId: $gbiId, date: $date, days: $days) {
423    gbiId
424    averageNextDayPerformance
425    eventDate
426    impactedCompanies {
427      gbiId
428      reason
429      security {
430        gbiId
431        name
432        symbol
433      }
434      correlation
435    }
436    security {
437      gbiId
438      name
439      symbol
440      isin
441    }
442  }
443}
444"""
445
446GET_ALL_THEMES = """
447  query GetAllThemesForUser($universeIds: [ID!]) {
448    getAllThemesForUser(universeIds: $universeIds) {
449      themeId
450      themeName
451      universeIds
452    }
453  }
454"""
455
456
457GET_THEME_DEEPDIVE_DETAILS = """
458  query GetMarketThemes(
459    $type: MarketTrendsType!
460    $id: String
461    $themeId: ID!
462    $startDate: String!
463    $endDate: String!
464    $deltaHorizon: String!
465  ) {
466    marketThemes(
467      type: $type
468      id: $id
469      themeId: $themeId
470      startDate: $startDate
471      endDate: $endDate
472      deltaHorizon: $deltaHorizon
473    ) {
474      themeName
475      themeDescription
476      universeReturn
477      impactInfos {
478        impactId
479        impactName
480        impactDescription
481        impactScore
482        newsItems {
483          headline
484          newsId
485          publishedAt
486          source
487          url
488        }
489        stocks {
490          gbiId
491          positiveThemeRelation
492        }
493      }
494      stockInfos {
495        gbiId
496        sectorId
497        subSectorId
498        priceChange
499        percentageChange
500        comboRecommendation
501        security {
502          gbiId
503          isin
504          symbol
505          currency
506          name
507          sector {
508            name
509          }
510        }
511        watchlists {
512          watchlistId
513          watchlistName
514        }
515        polarityReasonScores {
516          positiveThemeRelation
517          reason
518          impactScore
519          similarityScore
520        }
521      }
522      thematicSectorInfos {
523        sectorId
524        sectorName
525        sectorRank
526        sectorRankDelta
527        excessReturn
528        subSectorPerformances {
529          subSectorId
530          excessReturn
531        }
532      }
533      themeDevelopments {
534        articleCount
535        date
536        description
537        isMajorDevelopment
538        label
539        news {
540          headline
541          publishedAt
542          source
543          url
544        }
545        sentiment
546      }
547      errorMessage
548    }
549  }
550
551"""
552
553GET_EARNINGS_INSIGHTS_SUMMARIES = """
554  query GetEarningsSummaries($gbiIds: [Int!]!) {
555    getEarningsSummaries(gbiIds: $gbiIds) {
556      gbiId
557      reports {
558        date
559        title
560        details {
561          header
562          isAligned
563          detail
564          sentiment
565        }
566        highlights
567        qaDetails {
568          header
569          detail
570          sentiment
571        }
572        qaHighlights
573        quarter
574        year
575      }
576    }
577  }
578"""
579
580GET_EARNINGS_COMPARISONS = """
581  query GetLatestEarningsComparison($gbiIds: [Int!]!) {
582    getLatestEarningsChanges(gbiIds: $gbiIds) {
583      gbiId
584      changes {
585        header
586        detail
587      }
588    }
589  }
590"""
GET_SEC_INFO_QRY = '\nquery GetSecurities($ids: [Int!]) {\n securities(ids: $ids) {\n gbiId\n symbol\n name\n isin\n currency\n country\n sector {\n name\n topParentName\n }\n }\n}\n'
WATCHLIST_ANALYSIS_QRY = '\nquery WatchlistAnalysis(\n $modelIds: [ID!]\n $portfolioIds: [ID!]\n $gbiIds: [Int]\n $date: String!\n) {\n watchlistAnalysis(\n modelIds: $modelIds\n portfolioIds: $portfolioIds\n gbiIds: $gbiIds\n minDate: $date\n maxDate: $date\n ) {\n ...AnalysisFragment\n ...ExplainWeightsFragment\n }\n}\n\nfragment AnalysisFragment on WatchlistAnalysis {\n gbiId\n analysisDates {\n date\n aggregateSignal {\n rating\n ratingDelta\n }\n portfoliosSignals {\n portfolioId\n rank\n signalDelta\n rating\n ratingDelta\n }\n }\n}\n\n\nfragment ExplainWeightsFragment on WatchlistAnalysis {\n gbiId\n analysisDates {\n date\n portfoliosSignals {\n explainWeightNeg\n explainWeightPos\n }\n }\n}\n'
GET_MODELS_FOR_PORTFOLIOS_QRY = '\nquery GetPortfoliosAndModels($ids: [ID!]) {\n portfolios(ids: $ids) {\n id\n name\n modelId\n modelName\n }\n}\n'
GET_EXCESS_RETURN_QRY = '\nquery GetExcessReturn($modelIds: [ID!], $gbiIds: [Int], $date: String!) {\n models(ids: $modelIds) {\n id\n equityExplorerData(date: $date, gbiIds: $gbiIds) {\n equityExplorerSummaryStatistics {\n gbiId\n ER {\n SP {\n sixMonthWindowOneMonthHorizon\n }\n }\n }\n }\n }\n}\n'
GET_IDEAS_QUERY = '\nquery GetRecommendations(\n $modelId: ID!\n $portfolioId: ID!\n $horizon: String!\n $deltaHorizon: String!\n $startDate: String!\n $endDate: String!\n $marketDataDate: String!\n ) {\n recommendations(\n modelId: $modelId\n portfolioId: $portfolioId\n horizon: $horizon\n deltaHorizon: $deltaHorizon\n startDate: $startDate\n endDate: $endDate\n marketDataDate: $marketDataDate\n ) {\n mainCategories\n missingRecommendations {\n category\n missingReason\n }\n recommendations {\n category\n dividendYield\n reason\n rating\n ratingDelta\n risk {\n text\n }\n reward {\n text\n }\n ER {\n oneMonth\n threeMonth\n oneYear\n }\n security {\n symbol\n gbiId\n }\n }\n }\n }\n'

reasons { type text }

STOCK_RECOMMENDATION_QUERY = '\n query StockRecommendation(\n $modelId: ID!\n $portfolioId: ID!\n $gbiId: Int!\n $horizon: String!\n $date: String!\n ) {\n stockRecommendation(\n modelId: $modelId\n portfolioId: $portfolioId\n gbiId: $gbiId\n horizon: $horizon\n date: $date\n ) {\n ER {\n oneMonth\n threeMonth\n oneYear\n }\n rewardCategories {\n rank\n category\n }\n riskCategories {\n rank\n category\n }\n reasons {\n type\n text\n arrows\n }\n recommendation\n rewardCategory\n riskCategory\n }\n }\n'
MULTI_STOCK_RECOMMENDATION_QUERY = '\n query StocksRecommendations(\n $gbiIds: [Int!]\n $strategyId: ID!\n ) {\n currentRecommendationsFull(\n strategyId: $strategyId\n gbiIds: $gbiIds\n ) {\n gbiId\n recommendation1M {\n currentCategory\n ER {\n oneMonth\n threeMonth\n oneYear\n }\n reward {\n text\n }\n risk {\n text\n }\n reasons {\n type\n text\n }\n }\n recommendation3M {\n currentCategory\n ER {\n oneMonth\n threeMonth\n oneYear\n }\n reward {\n text\n }\n risk {\n text\n }\n reasons {\n type\n text\n }\n }\n recommendation1Y {\n currentCategory\n ER {\n oneMonth\n threeMonth\n oneYear\n }\n reward {\n text\n }\n risk {\n text\n }\n reasons {\n type\n text\n }\n }\n }\n }\n'
PF_HOLDING_QUERY = '\nquery getPortfolioHoldings(\n $date: String!\n $modelId: ID!\n $portfolioId: ID!\n) {\n portfolioHoldings (\n date: $date\n modelId: $modelId\n portfolioId: $portfolioId\n ) {\n security {\n symbol\n }\n gbiId\n }\n}\n'
GET_PORTFOLIO_RELATIVE_DATES_QUERY = '\nquery GetPortfolioRelativeDates(\n $portfolioId: ID!\n $relativePeriods: [String!]\n ) {\n portfolio(id: $portfolioId) {\n relativeDates(relativePeriods: $relativePeriods) {\n period\n date\n }\n }\n }\n'
GET_PORTFOLIO_FACTOR_ATTRIBUTION_QUERY = '\nquery getPortfolioFactorAttribution($portfolioId: ID!, $startDate: String, $endDate: String) {\n portfolio(id: $portfolioId) {\n factorAttribution(startDate: $startDate, endDate: $endDate) {\n dates\n portfolioFactorPerformance {\n name\n data\n }\n factorBetas {\n name\n data\n }\n factorReturns {\n name\n data\n }\n }\n }\n }\n'
GET_MODEL_STOCK_UNIVERSE_ID_QUERY = '\nquery getModelStockUniverseId($modelId: ID!) {\n model(id: $modelId) {\n stockUniverseId\n }\n}\n'
GET_PROS_CONS_QUERY = '\nquery GetProsCons($gbiIds: [Int!]!) {\n bulkSecurityProsCons(gbiIds: $gbiIds) {\n gbiId\n pros {\n summary\n details\n }\n cons {\n summary\n details\n }\n }\n}\n'
GENERATE_THEME_QUERY = '\nmutation generateTheme($input: GenerateThemeInput!) {\n generateTheme(input: $input) {\n success\n themeId\n }\n }\n'
GET_STOCK_NEWS_QUERY = '\nquery getStockNews($gbiId: Int!, $deltaHorizon: String!) {\n getStockNewsSummary(gbiId: $gbiId, deltaHorizon: $deltaHorizon) {\n summary\n sourceCounts {\n count\n }\n }\n getStockNewsTopics(gbiId: $gbiId, deltaHorizon: $deltaHorizon) {\n topicId\n topicLabel\n topicDescription\n topicPolarity\n newsItems {\n newsId\n headline\n url\n summary\n source\n publishedAt\n }\n }\n}\n'
GET_THEMES = '\nquery getThemes(\n $type: MarketTrendsType!, $id: String, $startDate: String!, $endDate: String!,\n $deltaHorizon: String) {\n themes(\n type: $type, id: $id, startDate: $startDate, endDate: $endDate, deltaHorizon: $deltaHorizon\n ) {\n themeId\n themeName\n themeImportance\n volatility\n positiveStockPerformance\n negativeStockPerformance\n }\n}\n'
GET_THEMES_FOR_STOCK_WITH_REASONS = '\nquery themesForStockWithReasons($gbiId: Int!, $startDate: String!, $endDate: String!) {\n themesForStockWithReasons(gbiId: $gbiId, startDate: $startDate, endDate: $endDate) {\n themeId\n themeName\n importanceScore\n similarityScore\n positiveThemeRelation\n reason\n }\n}\n'
EARNINGS_IMPACTS_CALENDAR_FOR_STOCK = '\nquery GetEarningsCalendarForStock($gbiId: Int!, $date: String!, $days: Int) {\n earningsCalendarForStock(gbiId: $gbiId, date: $date, days: $days) {\n gbiId\n averageNextDayPerformance\n eventDate\n impactedCompanies {\n gbiId\n reason\n security {\n gbiId\n name\n symbol\n }\n correlation\n }\n security {\n gbiId\n name\n symbol\n isin\n }\n }\n}\n'
GET_ALL_THEMES = '\n query GetAllThemesForUser($universeIds: [ID!]) {\n getAllThemesForUser(universeIds: $universeIds) {\n themeId\n themeName\n universeIds\n }\n }\n'
GET_THEME_DEEPDIVE_DETAILS = '\n query GetMarketThemes(\n $type: MarketTrendsType!\n $id: String\n $themeId: ID!\n $startDate: String!\n $endDate: String!\n $deltaHorizon: String!\n ) {\n marketThemes(\n type: $type\n id: $id\n themeId: $themeId\n startDate: $startDate\n endDate: $endDate\n deltaHorizon: $deltaHorizon\n ) {\n themeName\n themeDescription\n universeReturn\n impactInfos {\n impactId\n impactName\n impactDescription\n impactScore\n newsItems {\n headline\n newsId\n publishedAt\n source\n url\n }\n stocks {\n gbiId\n positiveThemeRelation\n }\n }\n stockInfos {\n gbiId\n sectorId\n subSectorId\n priceChange\n percentageChange\n comboRecommendation\n security {\n gbiId\n isin\n symbol\n currency\n name\n sector {\n name\n }\n }\n watchlists {\n watchlistId\n watchlistName\n }\n polarityReasonScores {\n positiveThemeRelation\n reason\n impactScore\n similarityScore\n }\n }\n thematicSectorInfos {\n sectorId\n sectorName\n sectorRank\n sectorRankDelta\n excessReturn\n subSectorPerformances {\n subSectorId\n excessReturn\n }\n }\n themeDevelopments {\n articleCount\n date\n description\n isMajorDevelopment\n label\n news {\n headline\n publishedAt\n source\n url\n }\n sentiment\n }\n errorMessage\n }\n }\n\n'
GET_EARNINGS_INSIGHTS_SUMMARIES = '\n query GetEarningsSummaries($gbiIds: [Int!]!) {\n getEarningsSummaries(gbiIds: $gbiIds) {\n gbiId\n reports {\n date\n title\n details {\n header\n isAligned\n detail\n sentiment\n }\n highlights\n qaDetails {\n header\n detail\n sentiment\n }\n qaHighlights\n quarter\n year\n }\n }\n }\n'
GET_EARNINGS_COMPARISONS = '\n query GetLatestEarningsComparison($gbiIds: [Int!]!) {\n getLatestEarningsChanges(gbiIds: $gbiIds) {\n gbiId\n changes {\n header\n detail\n }\n }\n }\n'