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

Username
  

Password
  





Search Forums



(Advanced Search)

Forum Statistics
» Members: 20,176
» Latest member: festivusfestoons
» Forum threads: 1,541
» Forum posts: 7,707

Full Statistics

Online Users
There are currently 161 online users.
» 0 Member(s) | 161 Guest(s)

Latest Threads
Gekko development status ...
Forum: Announcements
Last Post: ailynne
6 hours ago
» Replies: 794
» Views: 503,831
New Gekko UI in the works
Forum: Announcements
Last Post: pmkisanstatuscheckaadharcard
10 hours ago
» Replies: 133
» Views: 150,350
Gekko with malware spotte...
Forum: Announcements
Last Post: sabinaholt
Yesterday, 12:18 PM
» Replies: 125
» Views: 86,437
An official Gekko service...
Forum: Announcements
Last Post: sabinaholt
Yesterday, 12:13 PM
» Replies: 81
» Views: 135,581
Gekko 0.6 released
Forum: Announcements
Last Post: sabinaholt
Yesterday, 12:10 PM
» Replies: 104
» Views: 209,888
How to Soft Reset or Hard...
Forum: General Discussion
Last Post: lucifar
10-07-2021, 07:18 PM
» Replies: 22
» Views: 38,153
How to add Binance Future...
Forum: Technical Support
Last Post: Xavier32
10-07-2021, 02:20 PM
» Replies: 47
» Views: 79,410
Bittrex Configuration hel...
Forum: Bittrex
Last Post: yirzolusto
10-07-2021, 07:39 AM
» Replies: 6
» Views: 14,826
[Question] Why does gekko...
Forum: General Discussion
Last Post: cryptocurrency0
10-06-2021, 01:16 PM
» Replies: 16
» Views: 33,580
a couple of technical Que...
Forum: Technical Support
Last Post: mtom78632
10-06-2021, 11:08 AM
» Replies: 25
» Views: 44,677

 
  Proper stop losses coming soon
Posted by: askmike - 07-07-2018, 07:27 AM - Forum: General Discussion - Replies (52)

[EDIT]
I'm working hard on implementing native trailing stop losses! Follow this PR: https://github.com/askmike/gekko/pull/2429
[/EDIT]

Stop losses are a very big part of trading successfully, whether it is automated trading or not. Gekko currently does not support proper stop losses (unless users implement those themselves in their strategies, which is far from ideal) due to the complexities around different exchanges API capabilities (most do not support native stop losses at all).

Now Gekko v0.6 is out I am planning to enhance Gekko Broker with proper stop losses while giving strategies a way to include stop losses when giving advice. I'm working on Gekko Plus where I am taking Gekko to the next level and I feel this has to include proper stop losses.

What is a stoploss?

A stoploss is an order designed to get out of a position that might turn the wrong direction, limiting risk. Imagine you are using Gekko to trade on USD/BTC and your strategy sees an opportunity to buy. It will trigger a buy advice and Gekko will gladly buy BTC with your USD. But what if your strategy turned out wrong and the price of BTC tanks? With a stoploss you can limit your potential loss to say 1% by automatically selling the BTC once the price drops 1%. Stop losses are not perfect: If there is a small dip in the price you will sell, even though the price might go up after.

Why are there currently no stop losses?

There are two big reasons for this:

1. Up until recently Gekko had a lot of limitations in the communication between strategies and the module responsible for executing (simulated or real) trade orders at the exchange. Gekko v0.6 introduced a new event system that allows for bi-directional communication needed to update the strategy in case a stop loss gets executed.
2. Not all exchanges support stop losses natively, in cases exchanges don't Gekko needs a way to offer them (by watching the price and trading whenever it hits X). Since v0.6 Gekko comes with a library that can be extended to support this: Gekko Broker.

What will Gekko support in the future?

I haven't fully figured this out yet (which is why I am posting this thread). But this is what I am currently thinking:

- introduce the concept of triggers such as:
  - stop loss (create an order when the price goes AGAINST your direction).
- trailing stop loss (same as above the the price trigger will move with the price, slowly securing more profit).
  - take profit (create an order when the price goes IN your direction - and you want to secure your profit).
- allow for strategies to specify how to execute the trigger, such as:
  - market order
  - sticky order
  - limit order

There is already a "tradeCompleted" event which can be extended to include information about what caused it (an advice, a stoploss or takeprofit trigger). As for now triggers can be passed along with "LONG" (buy) advice signals as to end a roundtrip early (before the strategy adviced to "SHORT" (sell)).

I'm still thinking about this execution part, I might split this design into two phases: first with only triggers and second with more order types.

What do you think?


  Problem Importing Data on Win10 Fresh Install
Posted by: spiritracket - 07-07-2018, 02:12 AM - Forum: Technical Support - Replies (2)


.png   Screenshot 2018-07-06 at 93614 PM.png (Size: 64.47 KB / Downloads: 16) I just installed Gekko on a Win 10 machine following the instructions from the YouTube video on the "Install Gekko on Windows" page (which differs considerably from the instructions on that page). Everything appeared to install properly and Gekko opened in my browser, but when I went to the Local Data tab and attempted to import data, the drop-down menus under Market don't appear until after reloading the page and then are blank and impossible to populate. The drop-downs under the Backtest tab work fine, but without local data are useless. I tried installing Git manually as I saw recommended in another forum post for Win7, but that changed nothing. Still the same problem. Thanks.


  Example strategy request
Posted by: Henry151 - 07-06-2018, 11:20 PM - Forum: Strategy Development - Replies (2)

Hello all,

I am hoping somebody can help me out by drafting an example strategy, that just shows how to use gekko-broker to make partial orders; i.e. to signal "buy with only 10% of portfolio." Unless I misunderstand, I believe that this should now be possible, with v0.6 and gekko broker, but I don't understand yet how it would be implemented.

Thanks in advance for any assistance, I'm sure others will benefit from this as well!

--Henry


  GekkoGA Parallel questions
Posted by: PatTrends - 07-06-2018, 07:24 PM - Forum: Third Party Software - Replies (2)

Hey all,

I'm attempting to use the run-ga-parallel.js script but after running it for a while I don't get any results. I can see in terminal that its changing the parameters with each run, and the epochs are stacking up, but it always returns "profit 0$" at the top and this at the bottom...


Quote:Other metrics of global maximum:
Global maximum so far:
false

As far as I can tell, no errors are being generated and the same strategy works via CLI, Web UI, and the standard GekkoGA.

Also (might be related), but can someone explain the "writer" parameters? I assume it writes the results to the specified path, but I can't get this to work either.


Code:
  "writer": {
            "enabled": true,
            "logpath": "logs/test"
          },


Thanks,

PT


  New properly install ubuntu terminal
Posted by: cantthink19 - 07-05-2018, 07:20 PM - Forum: Technical Discussion - Replies (1)

I started gekko being a butthead and going straight for the windows install since the windows 10 seemed a bit lengthy, I come to find out I need bash support for running xFFFFF strategies. I get the ubuntu but still have node.js and im having trouble adding  api keys on the new process can any point me in the right direction and help me firgure out if my ip is banned since i tried to run two different gekkos from the same ip?


  Webinterface disconnected on V0.6.1
Posted by: vultureonline - 07-05-2018, 01:34 PM - Forum: Technical Support - Replies (3)

I installed Gekko 0.6.1 on my Raspberry Pi but I'm unable te get the webinterface running.
I installed all the files via git (from the installation instructions) and edited the config-file in the web/vue/public dir.
This file is exactly as it was when in version 0.5 that was working great.
Is there any more configuration to do?

The error I get is when Gekko is running and I browse to the webinterface (on port 3000) is: 
Disconnected
Something happened to either Gekko or the connection. Please check the terminal where Gekko is running or your network connection.
This message is shown when the UI is unable to open a websocket connection with the Gekko Server.

This is my UIconfig.js file:

const CONFIG = {
 headless: true,
 api: {
   host: '0.0.0.0',
   port: 3000,
   timeout: 120000 // 2 minutes
 },
 ui: {
   ssl: false,
   host: '192.168.1.221',
   port: 3000,
   path: '/'
 },
 adapter: 'sqlite'
}

if(typeof window === 'undefined')
 module.exports = CONFIG;
else
 window.CONFIG = CONFIG;



Any help?


  how to set a stop loss?
Posted by: bashbash - 07-05-2018, 09:21 AM - Forum: Strategy Development - No Replies

Set up using mfi and macd it has more profitable trades than losses, however the losses are very big. this during a bearish market. Need help with setting a percentage stop loss.


  Installing on Windows 7 Issue
Posted by: Orpheus2 - 07-05-2018, 06:47 AM - Forum: Technical Support - Replies (5)

Hello,
 I am trying to install Gekko on Windows 7.  Off of the bat i noticed the code shown below wasnt pointing correctly to what I downloaded.  I had to path to "gekko-develop" in the file path.

Code:
cd Downloads
cd gekko-stable
cd gekko-stable
 Once I use that path I am able to install,  then I am able to run 
Code:
npm install --only=production




After the above step when I try to install  "Gekko Broker's dependencies"  I get the error listed below.


C:\Gekko\Gekko Unzip>cd gekko-develop



C:\Gekko\Gekko Unzip\gekko-develop>npm install --only=production

up to date in 7.002s



C:\Gekko\Gekko Unzip\gekko-develop>cd exchange



C:\Gekko\Gekko Unzip\gekko-develop\exchange>npm install --only=production

npm ERR! code ENOGIT

npm ERR! No git binary found in $PATH

npm ERR!

npm ERR! Failed using git.

npm ERR! Please check if you have git installed and in your PATH.



npm ERR! A complete log of this run can be found in:

npm ERR!     C:\Users\2nd Laptop\AppData\Roaming\npm-cache\_logs\2018-07-05T06_3
0_47_322Z-debug.log




I am able to Install Tulip Indicators.  I do Have an issue starting Gekko, and i get the error listed below.


C:\Gekko\Gekko Unzip\gekko-develop\exchange>node gekko --ui

module.js:549

    throw err;

    ^



Error: Cannot find module 'C:\Gekko\Gekko Unzip\gekko-develop\exchange\gekko'

    at Function.Module._resolveFilename (module.js:547:15)

    at Function.Module._load (module.js:474:25)

    at Function.Module.runMain (module.js:693:10)

    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

Any help would be appreciated,

Thanks!

Or[heus2


Question Difference between check and update
Posted by: NaN - 06-28-2018, 01:54 PM - Forum: Strategy Development - Replies (2)

Hello, can someone explain me what is the difference between check and update methods inside strategies code?
This methods look pretty similar to me. Thanks.


  Generate binance-markets.json
Posted by: docdrow - 06-27-2018, 09:27 PM - Forum: Third Party Software - Replies (5)

Hey all,

  I'm sure someone out there has already done this, or perhaps Gekko will eventually acquire the ability to do this.  For now though I've whipped up this little program that will generate binance-markets.json for you.


Code:
/* generate binance-markets.json for Gekko
* Written by George Shearer --- doc@drow.org
* Notes: There's not much error checking here, I just threw this together because I got tired of manually updating the file.
* I hope others can benefit from this.
*
* Thank you Mike van Rossum and all other Gekko contributors
*
* You can build this on most any modern linux platform:
*
* gcc -Wall -s -o genmarkets genmarkets.c -lcurl -ljson-c */


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <json-c/json.h>
#include <curl/curl.h>

#define SUCCESS 0
#define FAIL    1

#define OUTPUT_FILE   "binance-markets.json"
#define BINANCE_URL   "https://api.binance.com/api/v1/exchangeInfo"

#define MAX_MARKETS 4000
#define MAX_CURRENCIES 50
#define MAX_ASSETS 2000

struct market
{
 char currency[10];
 char asset[10];
 double min_price;
 double min_qty;
 double stepsize;
 double min_notional;
 int currency_precision;
 int asset_precision;
} markets[MAX_MARKETS];

struct currency
{
 char currency[10];
} currencies[MAX_CURRENCIES];

struct asset
{
 char asset[10];
} assets[MAX_ASSETS];

struct curl_fetch_st {
   char *payload;
   size_t size;
};

int total_currencies = 0;
int total_assets = 0;
int total_markets = 0;

/* callback for curl fetch */
size_t curl_callback (void *contents, size_t size, size_t nmemb, void *userp) {
   size_t realsize = size * nmemb;                             /* calculate buffer size */
   struct curl_fetch_st *p = (struct curl_fetch_st *) userp;   /* cast pointer to fetch struct */

   /* expand buffer */
   p->payload = (char *) realloc(p->payload, p->size + realsize + 1);

   /* check buffer */
   if (p->payload == NULL) {
     /* this isn't good */
     fprintf(stderr,"ERROR: Failed to expand buffer in curl_callback");
     /* free buffer */
     free(p->payload);
     /* return */
     return(-1);
   }

   /* copy contents to buffer */
   memcpy(&(p->payload[p->size]), contents, realsize);

   /* set new buffer size */
   p->size += realsize;

   /* ensure null termination */
   p->payload[p->size] = 0;

   /* return size */
   return(realsize);
}

/* fetch and return url body via curl */
CURLcode curl_fetch_url(CURL *ch, const char *url, struct curl_fetch_st *fetch) {
   CURLcode rcode;                   /* curl result code */

   /* init payload */
   fetch->payload = (char *) calloc(1, sizeof(fetch->payload));

   /* check payload */
   if (fetch->payload == NULL) {
       /* log error */
       fprintf(stderr, "ERROR: Failed to allocate payload in curl_fetch_url");
       /* return error */
       return CURLE_FAILED_INIT;
   }

   /* init size */
   fetch->size = 0;

   /* set url to fetch */
   curl_easy_setopt(ch, CURLOPT_URL, url);

   /* set calback function */
   curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, curl_callback);

   /* pass fetch struct pointer */
   curl_easy_setopt(ch, CURLOPT_WRITEDATA, (void *) fetch);

   /* set default user agent */
   curl_easy_setopt(ch, CURLOPT_USERAGENT, "libcurl-agent/1.0");

   /* set timeout */
   curl_easy_setopt(ch, CURLOPT_TIMEOUT, 5);

   /* enable location redirects */
   curl_easy_setopt(ch, CURLOPT_FOLLOWLOCATION, 1);

   /* set maximum allowed redirects */
   curl_easy_setopt(ch, CURLOPT_MAXREDIRS, 1);

   /* fetch the url */
   rcode = curl_easy_perform(ch);

   /* return */
   return rcode;
}

int
do_curl(const char *url, char **storage)
{
 CURL *curl_handle;
 CURLcode curl_result;

 struct curl_fetch_st curl_fetch;
 struct curl_fetch_st *cf = &curl_fetch;

 curl_handle = curl_easy_init();
 curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 20L);
 curl_result = curl_fetch_url(curl_handle, url, cf);
 curl_easy_cleanup(curl_handle);

 /* check return code */
 if (curl_result != CURLE_OK || cf->size < 1)
 {
   fprintf(stderr, "do_curl(): Error grabbing '%s': %s", url, curl_easy_strerror(curl_result));
   return(1);
 }

 /* check payload */
 if (cf->payload != NULL) {
   *storage = cf->payload;
   return(SUCCESS);
 } else {
   fprintf(stderr, "do_curl(): Error storing payload from '%s'\n",url);
   return(FAIL);
 }
}

void
add_currency(char *currency)
{
 int x = 0;
 for(;x < total_currencies && x < MAX_CURRENCIES;x++)
   if(!strcmp(currencies[x].currency, currency))
     return;
 total_currencies++;
 strncpy(currencies[x].currency, currency, 10);
}

void
add_asset(char *asset)
{
 int x = 0;
 for(;x < total_assets && x < MAX_ASSETS;x++)
   if(!strcmp(assets[x].asset, asset))
     return;
 total_assets++;
 strncpy(assets[x].asset, asset, 10);
}

int
get_binance_info(void)
{
 char *data;
 json_object *bjson;
 enum json_tokener_error jerr = json_tokener_success;

 printf("Connecting to %s ... ",BINANCE_URL); fflush(stdout);

 if(do_curl(BINANCE_URL, &data))
 {
   puts("failed");
   return(FAIL);
 }
 puts("success");

 bjson = json_tokener_parse_verbose(data, &jerr);
 free(data);

 if(jerr == json_tokener_success)
 {
   json_object *symbols;

   if((symbols = json_object_object_get(bjson, "symbols"))!=NULL)
   {
     int x;
     
     total_markets = json_object_array_length(symbols);

     for(x = 0; x < total_markets && x < MAX_MARKETS; x++)
     {
       json_object *tmpmkt = json_object_array_get_idx(symbols, x);
       json_object *filters;

       strncpy(markets[x].currency, json_object_get_string(json_object_object_get(tmpmkt, "quoteAsset")), 10);
       markets[x].currency_precision = atoi(json_object_get_string(json_object_object_get(tmpmkt, "quotePrecision")));
       add_currency(markets[x].currency);

       strncpy(markets[x].asset, json_object_get_string(json_object_object_get(tmpmkt, "baseAsset")), 10);
       markets[x].asset_precision = atoi(json_object_get_string(json_object_object_get(tmpmkt, "baseAssetPrecision")));
       add_asset(markets[x].asset);

       if((filters = json_object_object_get(tmpmkt, "filters"))!=NULL)
       {
         int y, numfilters = json_object_array_length(filters);

         for(y = 0; y < numfilters; y++)
         {
           json_object *tmpfilter = json_object_array_get_idx(filters, y);
           const char *filter_type = json_object_get_string(json_object_object_get(tmpfilter, "filterType"));

           if(!strcmp(filter_type, "PRICE_FILTER"))
             markets[x].min_price = atof(json_object_get_string(json_object_object_get(tmpfilter, "minPrice")));
           else if(!strcmp(filter_type, "MIN_NOTIONAL"))
             markets[x].min_notional = atof(json_object_get_string(json_object_object_get(tmpfilter, "minNotional")));
           else if(!strcmp(filter_type, "LOT_SIZE"))
           {
             markets[x].min_qty = atof(json_object_get_string(json_object_object_get(tmpfilter, "minQty")));
             markets[x].stepsize = atof(json_object_get_string(json_object_object_get(tmpfilter, "stepSize")));
           }
         }
       }
     }
     printf("Loaded %d markets\n",total_markets);
   }
 }
 json_object_put(bjson);
 return(SUCCESS);
}

void
gen_gekko_markets(const char *output)
{
 int x = 0;
 FILE *fp = fopen(OUTPUT_FILE, "w");

 fprintf(fp, "{\n  \"currencies\": [");
 for(; x < total_currencies; x++)
 {
   if(x)
     fprintf(fp, ",");
   fprintf(fp, " \"%s\"", currencies[x].currency);
 }

 fprintf(fp, " ],\n  \"assets\": [");
 for(x = 0; x < total_assets; x++)
 {
   if(x)
     fprintf(fp, ",");
   fprintf(fp, " \"%s\"", assets[x].asset);
 }
 fprintf(fp, " ],\n  \"markets\": [\n");

 for(x = 0; x < total_markets; x++)
 {
   char fmt[500], temp[100];

   if(x)
     fprintf(fp, ",\n");

   strcpy(fmt, "    {\n      \"pair\": [\n        \"%s\",\n        \"%s\"\n      ],\n      \"minimalOrder\": {\n        \"amount\": %f,\n        \"price\": %");
   sprintf(temp, "0.%df", markets[x].asset_precision);
   strcat(fmt, temp);
   strcat(fmt, ",\n        \"order\": %f\n      }\n    }");
   fprintf(fp, fmt, markets[x].currency, markets[x].asset, markets[x].min_qty, markets[x].min_price, markets[x].min_notional);
 }

 fprintf(fp, "\n  ]\n}\n");
 fclose(fp);
}

int
main(int argc, char *argv[])
{
 memset((void *)markets, 0, sizeof(struct market) * MAX_MARKETS);
 memset((void *)currencies, 0, sizeof(struct currency) * MAX_CURRENCIES);
 memset((void *)assets, 0, sizeof(struct asset) * MAX_ASSETS);

 if(get_binance_info() == SUCCESS)
 {
   printf("Generating gekko file \"%s\" ...", OUTPUT_FILE); fflush(stdout);
   gen_gekko_markets(OUTPUT_FILE);
   puts("done");
   exit(SUCCESS);
 }
 exit(FAIL);
}