Comments (14)
I don't see any change in the strategy code above other than the name. Were there some other changes that were made?
from gekkoga.
Can you share your code changes with us?
from gekkoga.
var _ = require('lodash');
var log = require('../core/log.js');
var method = {};
method.init = function() {
// strat name
this.name = 'tulip-mega-strat';
// trend information
this.trend = 'none'
// tulip indicators use this sometimes
this.requiredHistory = this.settings.historySize;
// define the indicators we need
this.addTulipIndicator('myadx', 'adx', this.settings);
this.addTulipIndicator('mymacd', 'macd', this.settings);
}
// what happens on every new candle?
method.update = function(candle) {
// tulip results
this.adx = this.tulipIndicators.myadx.result.result;
this.macd = this.tulipIndicators.mymacd.result.macdHistogram;
}
// for debugging purposes log the last
// calculated parameters.
method.log = function() {
log.debug(
`---------------------
Tulip ADX: ${this.adx}
Tulip MACD: ${this.macd}
`);
}
method.check = function() {
// just add a long and short to each array when new indicators are used
const all_long = [
this.adx > this.settings.up && this.trend!=='long',
this.settings.macd_up < this.macd && this.trend!=='long',
].reduce((total, long)=>long && total, true)
const all_short = [
this.adx < this.settings.down && this.trend!=='short',
this.settings.macd_down > this.macd && this.trend!=='short',
].reduce((total, long)=>long && total, true)
// combining all indicators with AND
if(all_long){
log.debug(`tulip-mega-strat In low`);
this.advice('long');
}else if(all_short){
log.debug(`tulip-mega-strat In high`);
this.advice('short');
}else{
log.debug(`tulip-mega-strat In no trend`);
this.advice();
}
}
module.exports = method;
from gekkoga.
Is there a more elegant way of modifying the GekkoGA code instead of having to flatten all the indicators and strategies?
from gekkoga.
@KittenLandmine, you can implement something that parses the config and builds the needed object.
from gekkoga.
Great i understand now, why my tulind mutlistrad doesn't wan to work thanks a lot mr mkondel
from gekkoga.
So if I wanted to test for StochRSI what would the getProperties be? I currently have
getProperties: () => ({
// Strat settings must be flattened and cannot be nested for mutation to work properly!
historySize: randomExt.integer(100, 20),
interval: randomExt.integer(10, 2),
low: randomExt.integer(30, 15),
high: randomExt.integer(85, 75),
persistence: randomExt.integer(10, 2),
candleSize: config.candleValues[randomExt.integer(config.candleValues.length -1, 0)]
})
but am getting an error
TypeError: Cannot read property 'high' of undefined
at Base.method.check (/home/athroener/gekko/strategies/StochRSI.js:64:46)
at Base.bound [as check] (/home/athroener/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Base.propogateTick (/home/athroener/gekko/plugins/tradingAdvisor/baseTradingMethod.js:233:10)
at Base.bound [as propogateTick] (/home/athroener/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Base.tick (/home/athroener/gekko/plugins/tradingAdvisor/baseTradingMethod.js:150:10)
at Base.bound [as tick] (/home/athroener/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Actor.processCustomCandle (/home/athroener/gekko/plugins/tradingAdvisor/tradingAdvisor.js:79:15)
at CandleBatcher.bound (/home/athroener/gekko/node_modules/lodash/dist/lodash.js:729:21)
at emitOne (events.js:115:13)
at CandleBatcher.emit (events.js:210:7)
--> in Database#all('\n SELECT * from candles_BTC_TRX\n WHERE start <= 1515894779 AND start >= 1515891780\n ORDER BY start ASC\n ', [Function])
at Reader.get (/home/athroener/gekko/plugins/sqlite/reader.js:98:11)
at Reader.bound [as get] (/home/athroener/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Market.get (/home/athroener/gekko/core/markets/backtest.js:61:15)
at Market.bound [as get] (/home/athroener/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Market.processCandles (/home/athroener/gekko/core/markets/backtest.js:105:10)
at bound (/home/athroener/gekko/node_modules/lodash/dist/lodash.js:729:21)
at Statement.<anonymous> (/home/athroener/gekko/plugins/sqlite/reader.js:108:5)
which I am guessing is because threshold is undefinded.
from gekkoga.
For help getting it running I recommend dropping by our discord server https://discord.gg/cj34wxw
from gekkoga.
Thanks for the invite! I ended up copying the default strategy in gekko and flattening the threshold object like @mkondel said. Just took a bit to figure out what he was talking about :)
from gekkoga.
My solution was to use one of many "flattening" modules available on NPM and tweak mutate() and crossover() so that the input objects would be flattened and then once the mutations are calculated, "unflattened" to their original shape. Seems to work just fine so far, and accommodates for practically any shape of the params
from gekkoga.
Should be solved with #34 . @astepanov256 's approach is used here ;)
from gekkoga.
@H256 have you tested this nested more than 1 level deep? I ended up with only the first element mutating for some reason though it could have been an operator error...
trend: {
accumulate: {
up: 0.3,
down: -0.3
}
}
from gekkoga.
@generalectric I've tested it with something like this:
getProperties: () => ({
historySize: randomExt.integer(100, 20),
weight: randomExt.integer(35, 5),
thresholds: {
down: randomExt.float(0, -0.3),
up: randomExt.float(0.3, 0)
},
// Nested Parameters
testMutation: {
one: {
two: randomExt.integer(35, 5),
three: { number: randomExt.integer(35, 5)}
},
four:randomExt.float(0.3, 0)
},
candleSize: config.candleValues[randomExt.integer(config.candleValues.length - 1, 0)]
})
The first generation gives me:
{ historySize: 60,
weight: 28,
thresholds: { down: -0.230725980037592, up: 0.02893010413118295 },
testMutation: { one: { two: 22, three: [Object] }, four: 0.21912992458765415 },
candleSize: 15 }
the next epoch, it has changed to
{ historySize: 33,
weight: 30,
thresholds: { down: -0.2351412333200722, up: 0.007525782034289929 },
testMutation: { one: { two: 17, three: [Object] }, four: 0.11544516373376212 },
candleSize: 30 }
So I assumed, that it works ;)
from gekkoga.
@H256 I appreciate you buddy, thanks for your contribution.
from gekkoga.
Related Issues (20)
- Feature request: log all backtests HOT 2
- Error when starting a genetic simulation on actual config (macos)
- Calculation error of yearlyProfit HOT 1
- no "stratName" and "daterange" in result file
- One random number for two parameters HOT 1
- tulindError: needs to be number HOT 1
- update for gekko 0.6 HOT 2
- 500 - "Internal Server Error" HOT 6
- Score as mainObjective HOT 2
- General purpose of this project HOT 1
- Cannot read property 'exchange' of undefined HOT 4
- Parameter units HOT 1
- sharpe: null - global maximums can't get filled HOT 1
- Startprice/Endprice question HOT 1
- Critical security vulnerability during npm install HOT 4
- Questions - Number of Epochs & relaunch of GA session HOT 2
- "Global maximum" not persistent when profits are negative
- always picking up and working through default parameters.. // HOT 3
- Manual backtest results don't match GA results HOT 1
- Your website HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gekkoga.