Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums



(Advanced Search)

Forum Statistics
» Members: 28,517
» Latest member: for88day
» Forum threads: 1,541
» Forum posts: 8,068

Full Statistics

Online Users
There are currently 305 online users.
» 2 Member(s) | 303 Guest(s)
bhangad12, for88day

Latest Threads
Gekko with malware spotte...
Forum: Announcements
Last Post: Isobel
10 hours ago
» Replies: 191
» Views: 170,268
Gekko development status ...
Forum: Announcements
Last Post: kontho
10 hours ago
» Replies: 1,008
» Views: 933,756
Gekko 0.6 released
Forum: Announcements
Last Post: Pharagon
11-23-2024, 10:13 AM
» Replies: 122
» Views: 269,125
An official Gekko service...
Forum: Announcements
Last Post: drivemad2
11-22-2024, 07:24 AM
» Replies: 103
» Views: 190,138
New Gekko UI in the works
Forum: Announcements
Last Post: clduplicateremover
11-18-2024, 08:21 PM
» Replies: 174
» Views: 227,826
How to Soft Reset or Hard...
Forum: General Discussion
Last Post: lucifar
10-07-2021, 07:18 PM
» Replies: 22
» Views: 53,035
How to add Binance Future...
Forum: Technical Support
Last Post: Xavier32
10-07-2021, 02:20 PM
» Replies: 47
» Views: 108,417
Bittrex Configuration hel...
Forum: Bittrex
Last Post: yirzolusto
10-07-2021, 07:39 AM
» Replies: 6
» Views: 19,123
[Question] Why does gekko...
Forum: General Discussion
Last Post: cryptocurrency0
10-06-2021, 01:16 PM
» Replies: 16
» Views: 45,837
a couple of technical Que...
Forum: Technical Support
Last Post: mtom78632
10-06-2021, 11:08 AM
» Replies: 25
» Views: 58,584

 
  [SHARE] PSAR Indicator and Strat
Posted by: PatTrends - 06-27-2018, 05:22 PM - Forum: Strategy Development - No Replies

Hey all,

I've really been enjoying Gekko lately and thought I would share a PSAR Indicator/Strat I wrote.

PSAR, by itself, is an awful strategy - particularly in consolidating markets. The included strategy is provided more as an example, and simply buys and sells on trend reversals. That said, PSAR is a great way to set dynamic stop-losses (as opposed to static values or percentage-based trailing stop-losses).

While I didn't specifically port the Tulip code, I did verify my indicator generates the same results. I also heavily commented the indicator so newer users can try to figure out what its doing. If you can improve my code, let me know!

PSAR.toml

Code:
acceleration = 0.02
maximum = 0.2
persistence = 2



strategies/PSAR.js

Code:
// PSAR strat
// PT 06/26/18

// let's create our own method
var method = {};

// prepare everything our method needs
method.init = function() {
 this.name = 'PSAR';
 this.inTrade = false;

 this.requiredHistory = 100;

 // define the indicators we need
 this.addIndicator('psar', 'PSAR', this.settings);


};

// what happens on every new candle?
method.update = function(candle) {
 // nothing!
};


method.log = function(candle) {
 // nothing!
};

method.check = function() {
 var psar = this.indicators.psar;
 var trend = psar.trend;
 var trendDuration = psar.duration;
 // var psarResult = psar.psar;


 //Sell Signal
 if(trend == "down" && trendDuration >= this.settings.persistence && this.inTrade){
   this.advice('short');
   this.inTrade = false;

 }

 //Buy Signal
 if(trend == "up" && trendDuration >= this.settings.persistence && !this.inTrade){
   this.advice('long');
   this.inTrade = true;
 }

};

module.exports = method;



indicators/PSAR.js

Code:
//PSAR
//PT-06/26/2018

var Indicator = function(config) {
 this.input = 'candle';
 this.acceleration = config.acceleration;
 this.accelerationStep = config.acceleration;
 this.persistence = config.persistence;
 this.maximum = config.maximum;
 this.psar = null;
 this.initPsar = null;
 this.psarEpAcc = null;
 this.extremePoint = null;
 this.trend = null;
 this.previousTrend = null;
 this.duration = 0;

 this.candleHistory = [];

};


Indicator.prototype.update = function(candle) {

 this.candleHistory.push(candle);

 if(this.candleHistory.length >= 3) {

   //Define candles
   // var candle = this.candleHistory[2];
   var previousCandle = this.candleHistory[1];
   var prevPreviousCandle = this.candleHistory[0];

   //first run
   if (this.psar === null) {
     this.extremePoint = prevPreviousCandle.low;
     this.psar = prevPreviousCandle.high;
     this.previousTrend = 'down';
   }


   //PSAR EQUATION
   this.psarEpAcc = (this.psar - this.extremePoint) * this.acceleration;

   //PAST TREND LOGIC
   if (this.previousTrend == 'down') {

     //calculate initial psar
     this.initPsar = Math.max((this.psar - this.psarEpAcc), previousCandle.high, prevPreviousCandle.high);

     //calculate PSAR
     this.psar = (candle.high < this.initPsar) ? this.initPsar : this.extremePoint;

     //increase duration count
     this.duration++;

   }

   if (this.previousTrend == 'up') {

     //calculate initial psar
     this.initPsar = Math.min((this.psar - this.psarEpAcc), previousCandle.low, prevPreviousCandle.low);

     //calculate PSAR
     this.psar = (candle.low > this.initPsar) ? this.initPsar : this.extremePoint;

     //increase duration count
     this.duration++;

   }

   //Define trend
   this.trend = (this.psar > candle.close) ? 'down' : 'up';

   //CURRENT TREND LOGIC
   if(this.trend == 'down'){
     //calculate Extreme point
     this.extremePoint = Math.min(this.extremePoint, candle.low);
   }
   if(this.trend =='up'){
     //calculate Extreme point
     this.extremePoint = Math.max(this.extremePoint, candle.high);
   }

   //UPDATE LOGIC
   //If the trend stays the same and the extreme point doesn't equal the previous extreme point and the acceleration factor is less than the maximum factor...
   if (this.trend == this.previousTrend && this.extremePoint != this.previousExtremePoint && this.acceleration <= this.maximum) {

     //Increment the acceleration value
     this.acceleration += this.accelerationStep;
   }

   //If the trend stays the same and the extreme point value stays the same...
   if (this.trend == this.previousTrend && this.extremePoint == this.previousExtremePoint) {
     //Acceleration stays the same
   }

   // If the current trend doesn't equal the previous trend...
   if (this.trend != this.previousTrend) {

     //Set the acceleration to the initial value
     this.acceleration = this.accelerationStep;

     //reset duration count
     this.duration = 0;
   }

   //set values/array for next run
   this.previousExtremePoint = this.extremePoint;
   this.previousTrend = this.trend;
   this.candleHistory.shift();
 }

};

module.exports = Indicator;


  Issue on Kraken
Posted by: flychicken - 06-26-2018, 05:03 AM - Forum: Technical Support - Replies (2)

[kraken.js] (getTrades) returned an error, retrying: Service:Unavailable


  Gekko 0.6 released
Posted by: askmike - 06-24-2018, 10:31 AM - Forum: Announcements - Replies (122)

[EDIT]
0.6 is OUT! Get the release here
[/EDIT]


Gekko 0.6.0 is a major upgrade of the Gekko project, you can find some background information here.

The release of 0.6.0 is now finally ready for testing! Note that this release only includes:

- rewritten core & event logic.
- rewritten core plugins such as baseStrategy, performanceAnalyzer, paperTrader and (live) trader.
- Addition of the Gekko Broker library for live order execution.

LIMITATIONS:

- It does not support all exchanges previously supported by Gekko, see here for a list: https://github.com/askmike/gekko/blob/de....md#status


To test the 0.6 pre release:

- Update Gekko to the latest release.
- Make sure you run a new Node version (minimum is updated from 6.0 to 8.11.2)
- Besides the usual installation, please also install Gekko Broker dependencies, see here: https://github.com/askmike/gekko/blob/pr...pendencies

If you find any issue with the new release please open an issue on github (or open a new thread on the forum).


  How to create an automated trailing stop limit order?
Posted by: Elorpar - 06-24-2018, 08:09 AM - Forum: Automated Trading - Replies (1)

Let's say I have a stock trading at $100. If it gets to $120 I want to have a trailing stop limit order initiated with a trailing amount of $1 let's say.
I only want the trailing stop limit to take effect once the stock reaches $120.
How to create an strategy to automate this process?


  How to create an automated trailing stop limit order?
Posted by: Elorpar - 06-24-2018, 08:08 AM - Forum: Strategy Development - No Replies


Let's say I have a stock trading at $100. If it gets to $120 I want to have a trailing stop limit order initiated with a trailing amount of $1 let's say.
I only want the trailing stop limit to take effect once the stock reaches $120.
How to create an strategy to automate this process?


  Does gekko store data in memory or database?
Posted by: gsxr - 06-22-2018, 03:16 AM - Forum: General Discussion - Replies (5)

I had run --import to load initial data of over 5000 mintues using CLI.

I found the postgresql database loaded with some records successfully (with 6718 records).

Live paper trader was successfully run with slow moving average indicator loaded with 1000 x 5 min candles.

I did make sure config.candleWriter = { enabled: true }

I supposed new candle data will be inserted to database for all the subsequent ticker update. However, I found the number of records did not increased.

After a day of running, I restarted gekko live trader using the same config file. Datasets were not stitched with following log...

---- DEBUG LOG ----
The trading method requests 5000 minutes of historic data. Checking availablity..
Available local data:
from: 5000 minutes ago
to: 1176 minutes ago
Usable local data available, trying to match with exchange data..
Preventing Gekko from requesting 1191 minutes of history.
Fetching exchange data since 240 minutes ago
Available exchange data:
from: 240 minutes ago
to: 180 minutes ago
Unable to stitch datasets.
Not seeding locally available data to the trading method.
The exchange does not return enough data. 0 minutes are still missing.
---- END OF LOG ----

It seems like that 1176 minutes running of live paper trader did not save candle data into database but only in memory. Therefore that period of data was lost after gekko restarted.

I also don't understand why gekko fetch exchange data from 240 min to 180 min? I have seen this happened many times before.

Since it doesn't make sense to wait for a 5000 minutes warmup, my workaround is to run --import using CLI again to load the data after every gekko restart.

Does anyone know if this is a constraint of did I miss anything in the configuration for gekko to save live data into the database?

Thanks for advice.


Bug [TUT] CONFIG-FILE CONVERTOR FOR CLI GEKKO
Posted by: susitronix - 06-21-2018, 04:25 PM - Forum: Guides - Replies (1)

for the CLI-gekko (terminal gekko) we must set up the sample-config.js.

our strategie has its "my_strategie.toml" file, but in the config IT MUST BE AS JSON-style CODE.

if you do not use the backtest Machine from xFFFFF,
you can simply use an online tool that makes the conversation for you.
this is very easy and never makes an error.!!!

go to this page:
toml-json convertor

here simply copie paste your .toml code

Code:
[___trendatron___]
#<<<>>><<<>>>#
__longPos = false

#>>><<<>>><<#
[_backtest_start_]
__________day = 1
______month = 4
_____hour = 18
_minute = 38
candle_size = 1
#<<<>>><<<>>>#

[RSI]
optInTimePeriod = 30

[trsRSI]
high = 68
low = 30

[___stop_abs____]
stop_abs = -1.7
abs_exp = -250

now copie/paste the created .json code into your sample-config.js, as you can learn from my other Tutorial:
Code:
{
 "___trendatron___": {
   "__longPos": false
 },
 "_backtest_start_": {
   "__________day": 1,
   "______month": 4,
   "_____hour": 18,
   "_minute": 38,
   "candle_size": 1
 },
 "RSI": {
   "optInTimePeriod": 30
 },
 "trsRSI": {
   "high": 68,
   "low": 30
 },
 "___stop_abs____": {
   "stop_abs": -1.7,
   "abs_exp": -250
 }
}


TUT#5
just scroll down and find the thread :-)

thanks to xFFFFF, Matias Korhonen, and Ankasem
hope this helps


  Backtest error??
Posted by: Kris191 - 06-18-2018, 05:03 AM - Forum: Technical Support - Replies (1)

Code:
/root/gekko/node_modules/sqlite3/lib/trace.js:27
                   throw err;
                   ^

TypeError: Cannot read property 'currency' of undefined
   at PerformanceAnalyzer.calculateReportStatistics (/root/gekko/plugins/performanceAnalyzer/performanceAnalyzer.js:143:30)
   at PerformanceAnalyzer.bound [as calculateReportStatistics] (/root/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at PerformanceAnalyzer.finalize (/root/gekko/plugins/performanceAnalyzer/performanceAnalyzer.js:180:23)
   at PerformanceAnalyzer.bound [as finalize] (/root/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at /root/gekko/core/gekkoStream.js:46:25
   at /root/gekko/node_modules/async/dist/async.js:3205:16
   at replenish (/root/gekko/node_modules/async/dist/async.js:1030:17)
   at iterateeCallback (/root/gekko/node_modules/async/dist/async.js:1015:17)
   at /root/gekko/node_modules/async/dist/async.js:988:16
   at /root/gekko/core/gekkoStream.js:47:12
--> in Database#all('\n    SELECT * from candles_BTC_TRX\n    WHERE start <= 1529297820 AND start >= 1529298600\n    ORDER BY start ASC\n  ', [Function])
   at Reader.get (/root/gekko/plugins/sqlite/reader.js:98:11)
   at Reader.bound [as get] (/root/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at Market.get (/root/gekko/core/markets/backtest.js:61:15)
   at Market.bound [as get] (/root/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at Market.processCandles (/root/gekko/core/markets/backtest.js:105:10)
   at bound (/root/gekko/node_modules/lodash/dist/lodash.js:729:21)
   at Statement.<anonymous> (/root/gekko/plugins/sqlite/reader.js:108:5)
 Anyone now the reason for this error when a CLI backtest has finished? bT has been working but today it isnt,

Can someone help?


  Gekko CLI - Unable to buy for ETH/USD on Gemini
Posted by: crypto49er - 06-17-2018, 07:45 PM - Forum: Technical Support - Replies (1)

Hi all,

I know Gemini isn't a popular exchange (at least not talked about much in this forum). I'm trying to set it because I want to have a "set it and forget it" place to let Gekko do its thing and I will just check once a month on the performance of the strat.

So I just started live trading on Gekko CLI on Gemini the other day and I'm getting this error message. Anyone else experience this error message before? Any fixes? I will share my solution if I find it. Thanks.

Code:
2018-06-17 15:10:31 (ERROR):    unable to buy Error: Invalid quantity for symbol ETHUSD: 0.10618643
    at Request._callback (/home/jack/gekko/node_modules/gemini-exchange-coffee-api/lib/gemini.js:64:19)
    at Request.self.callback (/home/jack/gekko/node_modules/gemini-exchange-coffee-api/node_modules/request/request.js:123:22)
    at Request.emit (events.js:160:13)
    at Request.<anonymous> (/home/jack/gekko/node_modules/gemini-exchange-coffee-api/node_modules/request/request.js:893:14)
    at Request.emit (events.js:165:20)
    at IncomingMessage.<anonymous> (/home/jack/gekko/node_modules/gemini-exchange-coffee-api/node_modules/request/request.js:844:12)
    at IncomingMessage.emit (events.js:165:20)
    at endReadableNT (_stream_readable.js:1101:12)
    at process._tickCallback (internal/process/next_tick.js:152:19) undefined


  Binance entering "getTicker" callback after api call, err: null data: 357 symbols
Posted by: ankasem - 06-17-2018, 02:16 AM - Forum: Binance - Replies (1)

hi

2018-06-17 04:42:26 (INFO): Trader
2018-06-17 04:42:26 (INFO): Follows the advice and create real orders.
2018-06-17 04:42:26 (DEBUG): portfolioManager : getting balance & fee from binance
2018-06-17 04:42:26 (INFO):

2018-06-17 04:42:27 (DEBUG): [binance.js] entering "getTicker" callback after api call, err: null data: 357 symbols
2018-06-17 04:42:28 (DEBUG): [binance.js] entering "setBalance" callback after api call, err: null data: {"makerCommission":10,"takerCommission":10,"buyerCommission":0,"sellerCommission":0,"canTrade":true,"canWithdraw":true,"canDeposit":true,"updateTime":1529199170532,"balances"

1-Why does this error come in

[b]2-canWithdraw:true  (why true)?[/b]



[b]gekko v0.5.14[/b]