-
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
WIP add: Calculate fees on backtest #282
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This commit updates backtesting to be executed in a different fork, it allows to start up several different executions independently, either by different tabs or even different pairs at the same time. In the future, this process could be persisted in database with the intention of running long backtestings of years of information on several dozen pairs. The exclusive locking had to be disabled so that each fork also has access to transact with the database. It would be interesting to move it to a Postgres, including a potential docker file
- Loading branch information
There are no files selected for viewing
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 | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,7 +155,7 @@ module.exports = { | |
myDb.pragma('journal_mode = WAL'); | ||
|
||
myDb.pragma('SYNCHRONOUS = 1;'); | ||
myDb.pragma('LOCKING_MODE = EXCLUSIVE;'); | ||
// myDb.pragma('LOCKING_MODE = EXCLUSIVE;'); | ||
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. why? 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. I specified it on the commit message bit it got lost in the log :) It's basically cos sqlite3 is for some reason not allowing multiple connections to the database, one from the fork and from the main app. Probably worth locking the queries instead of the connection to the db. Happy to change to for a different approach if you have any ideas |
||
|
||
return (db = myDb); | ||
}, | ||
|
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 %} |
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 am not a big fan of refactoring code if it doesn't have anything to do with the feature.
Please create another pull request for this
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 this might be the
prettier
plugin