crypto49er / gekko-strategies Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Could you give instructions for setting up and running? Your videos are great but no clue how to get your strategies in gekko.
Hello,
I editted your file "stepgains" with the main that he buys at 0.99% of the current price and that he than sells at the buyPrice * 1.01. Do you know that's wrong with my code? If i backtest the code gekko doesn't do any trade.
// helpers
var _ = require('lodash');
var log = require('../core/log.js');
var buyPrice = 0.0;
var sellPrice = 0.0;
var advised = false;
// Let's create our own buy and sell strategy
var strat = {};
// Prepare everything our strat needs
strat.init = function() {
// how many candles do we need as a base
// before we can start giving advice?
this.requiredHistory = this.tradingAdvisor.historySize;
}
// What happens on every new candle?
strat.update = function(candle) {
// Display close price in terminal
log.debug('candle time', candle.start);
log.debug('candle close price:', candle.close);
}
// For debugging purposes.
strat.log = function() {
}
// Based on the newly calculated
// information, check if we should
// update or not.
strat.check = function(candle) {
if(buyPrice == 0){
buyPrice = candle.close * 0.99;
}
if(candle.close <= buyPrice && !advised){
this.advice("long");
log.debug('Buying at', candle.close);
sellPrice = candle.close * 1.01;
advised = true;
}
if(candle.close >= sellPrice && buyPrice != 0){
this.advice("short");
log.debug('Selling at', candle.close);
buyPrice = 0;
sellPrice = 0;
advised = false;
}
}
module.exports = strat;
Is this maybe an error in the backtest program?
uncaughtException { TypeError: log.remote is not a function
at Base.strat.update (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\strategies\RSICandle.js:73:9)
at Base.bound [as update] (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\node_modules\lodash\dist\lodash.js:729:21)
at Base.propogateTick (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\plugins\tradingAdvisor\baseTradingMethod.js:136:8)
at Base.bound [as propogateTick] (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\node_modules\lodash\dist\lodash.js:729:21)
at Base.calculateSyncIndicators (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\plugins\tradingAdvisor\baseTradingMethod.js:129:8)
at Base.bound [as calculateSyncIndicators] (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\node_modules\lodash\dist\lodash.js:729:21)
at afterAsync (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\plugins\tradingAdvisor\baseTradingMethod.js:94:10)
at Base.tick (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\plugins\tradingAdvisor\baseTradingMethod.js:108:5)
at Base.bound [as tick] (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\node_modules\lodash\dist\lodash.js:729:21)
at Actor.emitStratCandle (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\plugins\tradingAdvisor\tradingAdvisor.js:103:17)
--> in Database#all('\n SELECT * from candles_USDT_BTC\n WHERE start <= 1553806319 AND start >= 1553803320\n ORDER BY start ASC\n ', [Function])
at Reader.get (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\plugins\sqlite\reader.js:98:11)
at Reader.bound [as get] (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\node_modules\lodash\dist\lodash.js:729:21)
at Market.get (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\core\markets\backtest.js:61:15)
at Market.bound [as get] (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\node_modules\lodash\dist\lodash.js:729:21)
at Market.processCandles (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\core\markets\backtest.js:105:10)
at bound (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\node_modules\lodash\dist\lodash.js:729:21)
at Statement. (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\plugins\sqlite\reader.js:108:5) __augmented: true }
xxx POST /api/backtest 500 5,948ms -
Error: non-error thrown: [object Object]
at Object.onerror (C:\Users\Win10\Downloads\gekko-develop\gekko-develop\node_modules\koa\lib\context.js:105:40)
at process._tickCallback (internal/process/next_tick.js:68:7)
Hi,
Thanks for all the vids, just wondering if you have the updated StepGains from the second youtube vid?
Thanks
so i have your candelstick working at least when it comes to it piping out what the candle is but i am having a hard time finding out how to actually create a trade based on it. What code actually creates a trade in gekko?
I noted the the lastTreeTrend never got updated, you forgot to use .closed for the last element
so candles[8].close instead of candles[8], the same for candles[6]
So your fixed code would become (around line 76) :
if (candleLength < largestCandle.length * 0.25) {
if (candles[6].close <= candles[7].close && candles[7].close <= candles[8].close) {
lastThreeTrend = 'up';
}
if (candles[8].close <= candles[7].close && candles[7].close <= candles[6].close) {
lastThreeTrend = 'down';
}
Another bug or at least strange code detail that you might explain
Why do you use the 6,7,8 and not the header candles (ea the last 3 new candles) ??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.