-
Notifications
You must be signed in to change notification settings - Fork 2
incubation #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kbh4r4th
wants to merge
2
commits into
master
Choose a base branch
from
develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
incubation #1
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 +1 @@ | ||
| rootProject.name = 'opentrading-core' | ||
| rootProject.name = 'opentrading-core' |
This file contains hidden or 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
7 changes: 0 additions & 7 deletions
7
src/main/java/dev/opentrading/core/spring/CoreApplicationProperties.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -7,6 +7,10 @@ | |
| import org.springframework.core.annotation.Order; | ||
|
|
||
| import javax.inject.Named; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.concurrent.CompletableFuture; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** | ||
| * First runner | ||
|
|
@@ -15,12 +19,12 @@ | |
| @Named | ||
| @Order(1) | ||
| public abstract class CoreApplicationRunner implements ApplicationRunner { | ||
| private final CoreApplicationProperties applicationProperties; | ||
| private final CoreProperties coreProperties; | ||
|
|
||
| private final CoreBootstrap coreBootstrap; | ||
|
|
||
| protected CoreApplicationRunner(CoreApplicationProperties applicationProperties, CoreBootstrap coreBootstrap) { | ||
| this.applicationProperties = applicationProperties; | ||
| protected CoreApplicationRunner(CoreProperties applicationProperties, CoreBootstrap coreBootstrap) { | ||
| this.coreProperties = applicationProperties; | ||
| this.coreBootstrap = coreBootstrap; | ||
| } | ||
|
|
||
|
|
@@ -39,18 +43,36 @@ public void run(ApplicationArguments args) { | |
| coreBootstrap.getTradingInstruments().thenAccept(tradingInstrument -> { | ||
| log.info("Filtered trading instruments"); | ||
|
|
||
| coreBootstrap.initWebSocket().thenAccept(initWebsocket -> { | ||
| coreBootstrap.<Boolean> initWebSocket().thenApply(initialized -> { | ||
| log.info("Initialized WebSocket"); | ||
|
|
||
| coreBootstrap.streamTicks().thenAccept(ScheduledStreamingTicks -> { | ||
| log.info("Started streaming ticks"); | ||
|
|
||
| coreBootstrap.scheduleTicksAggregator().thenAccept(success -> { | ||
| log.info("Scheduled tick aggregator"); | ||
|
|
||
| log.info("Started CoreApplicationRunner."); | ||
| }); | ||
| }); | ||
| List<CompletableFuture<Boolean>> completableFutureList = new ArrayList<>(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We’re not doing any tick aggregation right now, right? Can we delete these, and start the scheduler here? |
||
| if (coreProperties.getOptions().isStreamTicks()) { | ||
| completableFutureList.add((coreBootstrap.<Boolean> streamTicks() | ||
| .thenApply(scheduled -> { | ||
| log.info("Scheduled streaming ticks"); | ||
| return scheduled; | ||
| }))); | ||
| } | ||
| if (coreProperties.getOptions().isStreamTicksAggregator()) { | ||
| completableFutureList.add((coreBootstrap.<Boolean> scheduleTicksAggregator() | ||
| .thenApply(scheduled -> { | ||
| log.info("Scheduled ticks aggregator"); | ||
| return scheduled; | ||
| }))); | ||
| } | ||
| return initialized && completableFutureList.stream() | ||
| .map(CompletableFuture::join) | ||
| .collect(Collectors.toList()) | ||
| .stream() | ||
| .reduce(true, Boolean::logicalAnd); | ||
| }).whenComplete((initialized, throwable) -> { | ||
| if (throwable != null) { | ||
| log.error("Exception occurred. exception={}", throwable.getCause().getMessage()); | ||
| } | ||
| if (initialized) { | ||
| log.info("Started CoreApplicationRunner"); | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
31 changes: 31 additions & 0 deletions
31
src/main/java/dev/opentrading/core/spring/CoreProperties.java
This file contains hidden or 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,31 @@ | ||
| package dev.opentrading.core.spring; | ||
|
|
||
| import lombok.Data; | ||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Data | ||
| @ConfigurationProperties(prefix = "opentrading.core") | ||
| public class CoreProperties { | ||
| Options options; | ||
| MarketData marketData; | ||
| TradingData tradingData; | ||
|
|
||
| @Data | ||
| public static class Options { | ||
| private boolean streamTicks; | ||
| private boolean streamTicksAggregator; | ||
| } | ||
| @Data | ||
| public static class MarketData { | ||
| private String openTime; | ||
| private String closeTime; | ||
| } | ||
| @Data | ||
| public static class TradingData { | ||
| private String startTime; | ||
| private String endTime; | ||
| private List<String> instrumentGroups; | ||
| } | ||
| } |
This file contains hidden or 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 +1,68 @@ | ||
| opentrading: | ||
| # | ||
| # 1. core properties | ||
| # | ||
| opentrading.core: | ||
| options: | ||
| streamTicks: false | ||
| streamTicksAggregator: false | ||
| marketData: | ||
| openTime: 09-00 | ||
| closeTime: 15-30 | ||
| tradingData: | ||
| startTime: 09:30 | ||
| endTime: 15:00 | ||
| instrumentGroups: | ||
| - a | ||
| - b | ||
| orchestrator: | ||
| ### | ||
|
|
||
|
|
||
| # | ||
| # 2. persistence properties | ||
| # | ||
| opentrading.persistence: | ||
| ### | ||
|
|
||
|
|
||
| # | ||
| # 3. data properties | ||
| # | ||
| opentrading.data: | ||
| tickIntevalMillSeconds: 300000 | ||
| ### | ||
|
|
||
|
|
||
| # | ||
| # 4. compute properties | ||
| # | ||
| opentrading.compute: | ||
| ### | ||
|
|
||
|
|
||
| # | ||
| # 5. strategy properties | ||
| # | ||
| opentrading.strategy | ||
| ### | ||
|
|
||
|
|
||
| # | ||
| # 6. analyzer properties | ||
| # | ||
| opentrading.analyzer | ||
| ### | ||
|
|
||
|
|
||
| # | ||
| # 7. agent properties | ||
| # | ||
| opentrading.agent | ||
| ### | ||
|
|
||
|
|
||
| # | ||
| # 8. simulator properties | ||
| # | ||
| opentrading.simulator | ||
| ### |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to make everything a completable future here like login, getMargin, getAllInstruments. If we're going to block on them all anyway, this chain of futures just adds boilerplate and a bunch of extra nesting. We should maybe only wrap things in futures if we want to launch tasks in parallel or need other specific capabilities.