-
Notifications
You must be signed in to change notification settings - Fork 1k
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
add: refactor backtesting to a different fork #281
Open
juandelacruz-calvo
wants to merge
1
commit into
Haehnchen:master
Choose a base branch
from
juandelacruz-calvo:backtest-fork
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
Changes from all commits
Commits
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 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,23 @@ | ||
const services = require('../modules/services'); | ||
|
||
process.on('message', async msg => { | ||
const p = msg.pair.split('.'); | ||
|
||
const results = await services | ||
.getBacktest() | ||
.getBacktestResult( | ||
msg.tickIntervalInMinutes, | ||
msg.hours, | ||
msg.strategy, | ||
msg.candlePeriod, | ||
p[0], | ||
p[1], | ||
msg.options, | ||
msg.initialCapital, | ||
msg.projectDir | ||
); | ||
|
||
process.send({ | ||
results: results | ||
}); | ||
}); |
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
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 @@ | ||
{% extends './layout.html.twig' %} | ||
|
||
{% block title %}Backtesting | Crypto Bot{% endblock %} | ||
|
||
{% block content %} | ||
<!-- Content Wrapper. Contains page content --> | ||
<div class="content-wrapper"> | ||
<!-- Content Header (Page header) --> | ||
<section class="content-header"> | ||
<div class="container"> | ||
<div class="row mb-2"> | ||
<div class="col-sm-6"> | ||
<h1>Backtesting</h1> | ||
</div> | ||
<div class="col-sm-6"> | ||
<ol class="breadcrumb float-sm-right"> | ||
<li class="breadcrumb-item"><a href="{{ '/' }}">Dashboard</a></li> | ||
<li class="breadcrumb-item active">Backtesting</li> | ||
</ol> | ||
</div> | ||
</div> | ||
</div><!-- /.container-fluid --> | ||
</section> | ||
<!-- /.Content Header (Page header) --> | ||
|
||
<!-- Main content --> | ||
<div class="content"> | ||
<div class="container"> | ||
<h3>Waiting results for backtest id {{ key }}</h3> | ||
</div><!-- /.container-fluid --> | ||
</div> | ||
<!-- /.content --> | ||
</div> | ||
<!-- /.content-wrapper --> | ||
|
||
{% endblock %} | ||
|
||
{% block javascript %} | ||
<script src="/js/backtest-form.js?v={{ asset_version() }}"></script> | ||
<script> | ||
var ready = false; | ||
const intervalId = setInterval(call, 2000); | ||
function call() { | ||
$.ajax({ | ||
type: "GET", | ||
url: '/backtest/{{ key }}', | ||
dataType: "json", | ||
success: function(data, textStatus) { | ||
ready = data.ready; | ||
if (data.ready === true) { | ||
clearInterval(intervalId); | ||
window.location.href = '/backtest/result/{{ key }}' | ||
} | ||
} | ||
}) | ||
}; | ||
|
||
</script> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js" integrity="sha512-rMGGF4wg1R73ehtnxXBt5mbUfN9JUJwbk21KMlnLZDJh7BkPmeovBuddZCENJddHYYMkCh9hPFnPmS9sspki8g==" crossorigin="anonymous"></script> | ||
{% endblock %} | ||
|
||
{% block stylesheet %} | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css" integrity="sha512-yVvxUQV0QESBt1SyZbNJMAwyKvFTLMyXSyBHDO4BG5t7k/Lw34tyqlSDlKIrIENIzCl+RVUNjmCPG+V/GMesRw==" crossorigin="anonymous" /> | ||
{% endblock %} |
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
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.
just call the code directly instead of forking.
"LOCKING_MODE = EXCLUSIVE" is needed for performance reason.
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.
If you call the code directly it doesn't benefit from parallel execution for various pairs at the same time, right? Also, the UI was struggling when a backtest was configured for various thousand hours
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.
Then it should have some sort of lock or limiter, if this is not handled carefully it may induce too much load onto the server and cause a heap overflow.
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.
Good point, I'm completely unaware of that, I'll dig a bit into it to see if I can figure out how to implement it neatly, thanks!
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.
You can setup a queue that consists out of an array holding each job.
That would be easiest, to just pop each job after the prior got done.
Main benefit of the array would be that the jobs just die away once you kill the server