This project demonstrates how to organize your project with custom rules for th2-sim.
This project implemented gRPC API, which is described in th2-grpc-sim-template
Fork this project and follow instructions to start your custom project
- Fork th2-grpc-sim-template project and edit proto files if needed.
- Edit dependencies in
build.gradlefile to include all the required libraries with generated gRPC sources. - Edit
rootProject.namevariable insettings.gradlefile. - Edit services classes and their methods
- Edit services file in
META-INFif needed
Rules consists of two methods:
checkTriggered- it is used for checking if rule will generate the messageshandleorhandleTriggered- it is used for generating outgoing messages
Rules can also use arguments. In order to do this you should use constructor in your custom class.
The rules are divided into 3 types and the only difference between them is the login method for checkTriggered:
This type contains the most simple logic for check. The rules of this type will be triggered only if the message type and the fields from the incoming message are equals to the values that we had set in the rule.
This type contains the most flexible check conditions. The rules of this type will only be triggered if the message type and the message fields logical functions, which are set in rule, return a true value. The logical functions of the fields in this rule are isolated between each other.
This type contains the most flexible check conditions. The rules of this type will be triggered if your custom logic in method checkTriggered will return a value equal to true.
If you want to add the possibility of creating a rule via gRPC you should edit th2-grpc-sim-template and class TemplateService.
For adding a rule to simulator you can use the utility method ServiceUtils.addRule or the method from Simulator class with the name addRule. On the gRPC request you should return RuleID.
On the picture is presented an example of simulator work with the rule TemplateFixRule enabled. This rule sends an ExecutionReport message if the income message is a NewOrderSingle.
If the income message is wrong (not NewOrderSingle), the rule in simulator will not generate an outgoing message.
If the income message is correct (NewOrderSingle), the rule will generate one ExecutionReport.
- Produce multi-platform docker image
- migrated to amazoncorretto:11-alpine-jdk docker image as base
- [GH-49] KotlinFIXRule enhancement
- Fixed: use handle timestamp for
TransactTimeCSV field
- Fixed: use handle timestamp for
- Updated:
- kotlin-logging:
7.0.13
- kotlin-logging:
- Migrate to th2 gradle plugin
0.3.10(bom:4.14.2) - [GH-41] Use
TemplateFixRuleCreate.session_aliasesgRPC field for getting map internal rule key to session alias - [GH-49] KotlinFIXRule enhancement
- Used single transact time for handling messages
- Implemented independent handling for different instruments
- Set
AggressorIndicatorfield toExecutionReportwithExecTypetrade - Optionally store book log to CSV file. System properties can be specified in
JAVA_TOOL_OPTIONSusing-Dprefixth2.sim.kotlin-fix-rule.book-log.dir- folder for storing log inCSVformatth2.sim.kotlin-fix-rule.book-log.pattern- file name pattern likebook-log
- Updated:
- kotlin:
2.2.21 - common:
5.16.1-dev - common-utils:
2.4.0-dev - grpc-sim-template:
3.5.0-dev
- kotlin:
- Added libs:
- opencsv:
5.12.0 - kotlin-logging:
7.0.12
- opencsv:
- Message batching added
maxMessageBatchSizeandmaxMessageFlushTimecustom configuration settings added
- Updated th2-sim to version 7.1.0
- Updated
common-jto 5.8.0
- JDK downgrade to v11
- Update
kotlin.jvmto1.8.22 - Added
kotlin_version,sim_versionandcommon_versiontogradle.properties - Migration to books/pages cradle 5.1.1
- Update
common-jto 5.6.0 - Update
common-utils-jto 2.2.2
- Update
- Update th2-common to version 3.44.0
- Update bom to version 4.1.0
- Update
kotlin.jvmto1.6.21
- Updated th2-sim to version 5.2.3
- Update th2-common to version 3.41.1
- Update bom to version 4.0.2
- Add tests examples
- Add Gradle plugin for proto descriptors creation
- Update libraries version
- Update th2-sim to version 3.7.0
- Added
IRuleContext.removeRule()method which allows a rule to remove itself - Added ability to schedule execution of arbitrary actions via
IRuleContext.executemethods
- Added
- Update th2-common to version 3.19.0
- Update
th2-grpc-commonandth2-grpc-service-generatorversions to3.2.0and3.1.12respectively - Disable waiting for connection recovery when closing the
SubscribeMonitor - Change the way channels are stored (they mapped to the pin instead of the thread). It might increase the average number of channels used by the box, but it also limits the max number of channels to the number of pins
- Added the property
workers, which changes the count of gRPC server's threads - Added
session aliasanddirectionlabels to incoming metrics - Rework logging for incoming and outgoing messages
- Resets embedded
log4jconfiguration before configuring it from a file - Fixed a bug with message filtering by
message_type
- Update
