-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from QuanTemplate/task/QUAN-8655-use-yml
Parse yml for the revenueReport command, take Capital IQ ids from the QT
- Loading branch information
Showing
24 changed files
with
512 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# data-ingress | ||
# api-integrations | ||
|
||
Integrations with third-party data providers such as [Capital IQ](https://www.capitaliq.com) leveraging the [Quantemplate Data Ingress API](https://quantemplate.readme.io/docs/getting-started#-data-ingress). | ||
Integrations with third-party data providers such as [Capital IQ](https://www.capitaliq.com) leveraging the [Quantemplate API](https://quantemplate.readme.io/docs/getting-started). | ||
|
||
If you need help please contact as at [email protected] | ||
If you need help please contact us at [email protected] | ||
|
||
|
||
# Capital IQ | ||
|
@@ -26,9 +26,18 @@ The diagram below describes a potential integration pattern where CapitalIQ data | |
|
||
- Generating a total revenue report from the CapitalIQ data and uploading it to the Quantemplate dataset | ||
|
||
```sh | ||
cat ./data/capitaliq-identifiers.txt | java -jar ./capitaliq/target/scala-3.0.0-RC1/capitaliq-assembly-1.0.jar generateRevenueReport --orgId c-my-small-insuranc-ltdzfd --datasetId d-e4tf3yyxerabcvicidv5oyey --currency USD --from 1988-12-31 --to 2018-12-31 | ||
``` | ||
- with yaml config: | ||
```sh | ||
java -jar ./capitaliq/target/scala-3.0.0-RC2/capitaliq-assembly-0.1.0.jar apply ./data/revReport.yml | ||
``` | ||
|
||
Check out the [config file](./data/revReport.yml) | ||
|
||
|
||
- with CLI args: | ||
```sh | ||
cat ./data/capitaliq-identifiers.txt | java -jar ./capitaliq/target/scala-3.0.0-RC2/capitaliq-assembly-0.1.0.jar generateRevenueReport --orgId c-my-small-insuranc-ltdzfd --datasetId d-e4tf3yyxerabcvicidv5oyey --currency USD --from 1988-12-31 --to 2018-12-31 | ||
``` | ||
|
||
|
||
|
||
|
@@ -75,6 +84,7 @@ An example set of identifiers could be found in the `./data/capitaliq-identifier | |
``` | ||
CAPITALIQ_API_USERNAME=<api username you got with Capital IQ API license> | ||
CAPITALIQ_API_PASSWORD=<password for the corresponding Capital IQ API user> | ||
CAPITALIQ_DEMO_ACCOUNT=<indicates whether the Capital IQ demo account is used> | ||
QT_ENV=<name of the Quantemplate environment, should be `prod` for any consumers> | ||
QT_AUTH_REALM=<name of the Quantemplate auth ream, should be `qt` for any consumers> | ||
QT_CLIENT_ID=<id of the api-client user generated by the Quantemplate team> | ||
|
@@ -85,6 +95,7 @@ An example set of identifiers could be found in the `./data/capitaliq-identifier | |
``` | ||
[email protected] | ||
CAPITALIQ_API_PASSWORD=<password from dev credentials> | ||
CAPITALIQ_DEMO_ACCOUNT=true | ||
QT_ENV=dev | ||
QT_AUTH_REALM=test | ||
QT_CLIENT_ID=<id of the api-client user> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
capitaliq/src/main/scala/com/quantemplate/capitaliq/commands/ConfigDef.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.quantemplate.capitaliq.commands | ||
|
||
trait ConfigDef |
65 changes: 65 additions & 0 deletions
65
capitaliq/src/main/scala/com/quantemplate/capitaliq/commands/ConfigDefInterpreterCmd.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.quantemplate.capitaliq.commands | ||
|
||
import java.time.LocalDate | ||
import java.nio.file.Path | ||
import io.circe.{ Encoder, Decoder, Json, DecodingFailure } | ||
import io.circe.yaml.{parser as ymlParser} | ||
import org.slf4j.LoggerFactory | ||
import scopt.OParser | ||
import cats.syntax.bifunctor.given | ||
|
||
import com.quantemplate.capitaliq.common.* | ||
import com.quantemplate.capitaliq.domain.CapitalIQ.Identifier | ||
import com.quantemplate.capitaliq.domain.Identifiers | ||
import com.quantemplate.capitaliq.commands.revenuereport.* | ||
|
||
object ConfigDefInterpreterCmd: | ||
lazy val logger = LoggerFactory.getLogger(getClass) | ||
|
||
def fromCli(args: Array[String]) = ConfigArgsParser.parse(args).map { cliConfig => | ||
val configPath = IO.absolutePath(cliConfig.path) | ||
|
||
loadConfig(configPath).bimap( | ||
err => logger.error("Could not parse the config file", err), | ||
{ | ||
case config: RevenueReportConfigDef => RevenueReportCmd().fromConfigFile(config, configPath) | ||
} | ||
) | ||
} | ||
|
||
private def loadConfig(path: Path) = | ||
IO.readAll(path) | ||
.toEither | ||
.flatMap(ymlParser.parse(_)) | ||
.flatMap(_.as[ConfigDef]) | ||
|
||
given Decoder[ConfigDef] = Decoder.instance[ConfigDef] { c => | ||
c.get[String]("command").flatMap { | ||
case configDefInterpreterCmdName => c.get[RevenueReportConfigDef]("params") | ||
} | ||
} | ||
|
||
val configDefInterpreterCmdName = "apply" | ||
|
||
object ConfigArgsParser: | ||
case class CliConfig(path: String = "") | ||
|
||
def parse(args: Array[String]) = OParser.parse(parser, args, CliConfig()) | ||
|
||
private lazy val builder = OParser.builder[CliConfig] | ||
private lazy val parser = | ||
import builder.* | ||
|
||
OParser.sequence( | ||
programName("capitaliq-qt integration"), | ||
head("capitaliq-qt", "0.0.1"), | ||
cmd(configDefInterpreterCmdName) | ||
.text("Runs the command described in a file at a given path") | ||
.children( | ||
arg[String]("<config file>...") | ||
.action((path, c) => c.copy(path = path)) | ||
.unbounded | ||
.required | ||
) | ||
) | ||
|
52 changes: 0 additions & 52 deletions
52
capitaliq/src/main/scala/com/quantemplate/capitaliq/commands/RevenueReportCmd.scala
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
capitaliq/src/main/scala/com/quantemplate/capitaliq/commands/revenuereport/Config.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.quantemplate.capitaliq.commands.revenuereport | ||
|
||
import java.time.LocalDate | ||
|
||
import com.quantemplate.capitaliq.domain.CapitalIQ.Identifier | ||
|
||
case class CmdConfig( | ||
orgId: String, | ||
datasetId: String, | ||
from: LocalDate, | ||
to: LocalDate, | ||
currency: String, | ||
identifiers: Vector[Identifier] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 23 additions & 8 deletions
31
...iq/commands/RevenueReportArgsParser.scala → ...venuereport/RevenueReportArgsParser.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.