Coder Social home page Coder Social logo

Comments (14)

talentoscope avatar talentoscope commented on June 2, 2024 1

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.

rdetwiler avatar rdetwiler commented on June 2, 2024

Can you share your code changes with us?

from gekkoga.

mkondel avatar mkondel commented on June 2, 2024
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.

KittenLandmine avatar KittenLandmine commented on June 2, 2024

Is there a more elegant way of modifying the GekkoGA code instead of having to flatten all the indicators and strategies?

from gekkoga.

mkondel avatar mkondel commented on June 2, 2024

@KittenLandmine, you can implement something that parses the config and builds the needed object.

from gekkoga.

viking76 avatar viking76 commented on June 2, 2024

Great i understand now, why my tulind mutlistrad doesn't wan to work thanks a lot mr mkondel

from gekkoga.

trainerbill avatar trainerbill commented on June 2, 2024

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.

generalectric avatar generalectric commented on June 2, 2024

For help getting it running I recommend dropping by our discord server https://discord.gg/cj34wxw

from gekkoga.

trainerbill avatar trainerbill commented on June 2, 2024

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.

astepanov256 avatar astepanov256 commented on June 2, 2024

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.

H256 avatar H256 commented on June 2, 2024

Should be solved with #34 . @astepanov256 's approach is used here ;)

from gekkoga.

generalectric avatar generalectric commented on June 2, 2024

@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.

H256 avatar H256 commented on June 2, 2024

@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.

generalectric avatar generalectric commented on June 2, 2024

@H256 I appreciate you buddy, thanks for your contribution.

from gekkoga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.