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

Username
  

Password
  





Search Forums



(Advanced Search)

Forum Statistics
» Members: 3,936
» Latest member: bitcrypt
» Forum threads: 721
» Forum posts: 3,744

Full Statistics

Online Users
There are currently 66 online users.
» 1 Member(s) | 65 Guest(s)
bitcrypt

Latest Threads
Help for creating very ba...
Forum: Strategy Development
Last Post: mininpapoune
Yesterday, 11:37 AM
» Replies: 0
» Views: 36
Java + ? programming
Forum: General Discussion
Last Post: taichieel
Yesterday, 11:28 AM
» Replies: 1
» Views: 51
BTT
Forum: Binance
Last Post: sarah.roberts
02-17-2019, 08:11 PM
» Replies: 2
» Views: 172
State of the art of the a...
Forum: Third Party Software
Last Post: Guysmo
02-14-2019, 05:53 PM
» Replies: 0
» Views: 73
Daily Forex News
Forum: General Discussion
Last Post: xtreamforex
02-14-2019, 11:05 AM
» Replies: 0
» Views: 66
Issue with a strategie......
Forum: Technical Discussion
Last Post: SupraFan
02-13-2019, 11:46 AM
» Replies: 0
» Views: 76
[ARBITRAGE] Agent Smith: ...
Forum: Custom Systems
Last Post: curiousgeorge
02-13-2019, 05:21 AM
» Replies: 19
» Views: 62,158
Looking for Gekko expert ...
Forum: Technical Support
Last Post: brainmeorg
02-13-2019, 04:36 AM
» Replies: 1
» Views: 135
An official Gekko service...
Forum: Announcements
Last Post: Haki
02-12-2019, 10:36 PM
» Replies: 29
» Views: 16,463
Help, how to create multi...
Forum: Technical Support
Last Post: SupraFan
02-12-2019, 11:04 AM
» Replies: 2
» Views: 100

 
  Rejected Sell Trades Can Lose 10% Of Your Portfolio... Or More
Posted by: crypto49er - 01-14-2019, 11:05 PM - Forum: Technical Discussion - Replies (12)

I had seen this issue for sometime but I finally came up with a really rough fix. I would really appreciate if someone can write the code to do this asynchronously.

Issue: (Known to occur in Coinbase Pro, but can occur for any exchange that lets you use limit orders and a post flag that prevent executing market orders) When Gekko issues a sell order, in the seconds that it receives the current price from the exchange and before it sends the sell order to the exchange, the price went up. Normally, that's a good thing. This shows there's so much volume that your order shouldn't have any problem getting filled. The problem is, when the order goes to the exchange, the exchange rejects it because Gekko is now trying to sell below the ask price. Once the order is rejected, Gekko doesn't retry the order. Technically, even if Gekko did, it would get a message back from the exchange "HTTP 400 Error: order not found" and it will continue to get this message until the retry attempts are exhausted. So that's the issue. If your strategy issued a sell order to get out of the market in anticipation of further drops, you're now screwed!!! Gekko will be holding the bag for you while the crypto goes down in price from 2% to 5% to 10% (on a bad day) or more if you are trading an extremely volatile crypto.

To Test This: Modify sticky.js inside the exchange/orders folder. (You need to check your trade pair in the Coinbase Pro UI to see the spread first. See note directly below). In line 129, replace this:

Code:
return r(ticker.ask);

with:

(for Coinbase Pro)
Code:
return r(ticker.ask - 1);

If you want to see rejected buy trades, you can modify line 111 from this:

Code:
return r(ticker.bid);

with:

(for Coinbase Pro)
Code:
return r(ticker.bid + 1);

***Note: I previously modified it from 0.03 to 10% but in my recent test, I was getting insufficient funds error instead of the rejected trade error. I now changed it to 1 but it really comes down to the trade pair. The optimum number is a number that is slightly larger than the spread.***

This essentially tricks Gekko into selling below ask or buying above bid prices. For rejected buy trades, they don't cost you anything except for potential gain. But that could be a lot! Anyway, the next time your strategy issues a buy/sell order, you will see the rejected trade error in the console. It looks something like this.
Quote:2019-01-14 16:07:18 (INFO): Trader Received advice to go long. Buying  ETC

2019-01-14 16:07:18 (DEBUG): Creating order to buy 2.174301930195067 ETC



Mon Jan 14 2019 16:07:23 GMT-0500 (EST) {}

sticky create

buy

2019-01-14 16:07:23 (DEBUG): [ORDER] statusChange: SUBMITTED

2019-01-14 16:07:23 (DEBUG): [ORDER] statusChange: OPEN

2019-01-14 16:07:24 (DEBUG): [ORDER] statusChange: REJECTED

2019-01-14 16:07:24 (INFO): [ORDER] summary: { price: 0,

  amount: 0,

  date: moment("1969-12-31T19:00:00.000"),

  side: 'buy',

  orders: 1 }
2019-01-14 16:07:24 (DEBUG): syncing private data
I know ETC was 51% attacked recently. This is just a test and ETC is the cheapest crypto I have access to on Coinbase Pro. But do note the erroneous 1969 date listed in console. It usually is 12/31/1969 or 1/1/1970. If you ever seen this in the past, your trade failed to execute.

Solution: I am not an advanced coder in Javascript, so this isn't the cleanest solution, but it works. The idea is to have your strategy issue another buy order after getting the "rejected" message from the exchange. One thing I noticed while coming up with this is if you try to issue another buy order, Gekko completely ignores it and doesn't even output a message to console. I'm guessing this is because older strategies send multiple buy orders and Gekko has to ignore them. So the only way to get Gekko to accept a new buy order is to issue a sell order first.

The files I modified are:
config file
gdax.js
strategy file

In the config file, we are going to store the state of "rejected" so the other files can read/write to them. I just added the following before the last line. You can probably add them anywhere.

Code:
config.IssueState = {
 rejected: false,
 side: 'sell',

}

In gdax.js, we are going to give it the ability to write to the rejected variable in the config file, so we need to add this at the top where the other required files are declared.

Code:
var config = require('../../core/util.js').getConfig();

Now, in the checkOrder function, in the if (status == 'pending') section, I changed it from:

Code:
if(status == 'pending') {
     // technically not open yet, but will be soon
     return callback(undefined, { executed: false, open: true, filledAmount: 0 });
   } if (status === 'done' || status === 'settled') {
     return callback(undefined, { executed: true, open: false });
   } else if (status === 'rejected') {
     return callback(undefined, { executed: false, open: false });
   } else if(status === 'open' || status === 'active') {
     return callback(undefined, { executed: false, open: true, filledAmount: parseFloat(data.filled_size) });
   }

to:

Code:
   if(status == 'pending') {
     // technically not open yet, but will be soon
     return callback(undefined, { executed: false, open: true, filledAmount: 0 });
   } if (status === 'done' || status === 'settled') {
     config.IssueState.rejected = false;
     return callback(undefined, { executed: true, open: false });
   } else if (status === 'rejected') {
       if (data.reject_reason == 'post only' ) {
         config.IssueState.rejected = true;
         config.IssueState.side = data.side;
       }
     return callback(undefined, { executed: false, open: false });
   } else if(status === 'open' || status === 'active') {
     return callback(undefined, { executed: false, open: true, filledAmount: parseFloat(data.filled_size) });
   }
It essentially updates the "rejected" variable in the config file to true if the trade was rejected. It will also store the side so we know if it is a buy or sell order. If the trade is successfully placed, it will change the "rejected" variable in the config file to false.

In the strategy, I again have to give it the ability to access the config file by adding this at the top, where all the other required files are declared:

Code:
var config = require ('../core/util.js').getConfig();
The line is slightly different than the one for gdax.js because of the strategy file is stored in a different location than gdax.js.

I then added a variable to check how often to check if the "rejected" variable is still true. This is a global variable at the top where other variables are placed. 

Code:
var waitForRejectedRetry = 0;
This is where asynchronous code would make this much cleaner. Instead of checking after x minutes, you can have this run only when status changes from either rejected or completed/settled in gdax.js. But I couldn't figure out how to implement that.

So instead this is the code in the check function of the strategy:
Code:
 if (config.IssueState.rejected){
   if (waitForRejectedRetry == 0){
     if (config.IssueState.side == 'buy'){
       this.advice('short'); // To reset previous buy order by issuing a sell order
       this.advice('long');
     } else {
       this.advice('long'); // To reset previous sell order by issuing a buy order
       this.advice('short');
     }
     waitForRejectedRetry = 11;
   }
   if (waitForRejectedRetry > 0) {
     waitForRejectedRetry--;
   }

 }
With this code, it will create a new buy/sell order if "rejected" is set to true in the config file. As mentioned previously, it has to issue a sell first if a buy order was rejected or buy first if a sell order was rejected. It will then wait ~10 minutes (the check order function doesn't always run every minute, assuming 1 minute candles). If the "rejected" variable is still valid, it will repeat this until the order is no longer rejected. Again, I wish it doesn't have to do this every x minutes but this is the only way to do it that I know of synchronously.

I tested this and confirmed that it works. Don't forget to remove the code in sticky.js otherwise every order will be rejected. If you're interested to simulating a scenario where every other trade starting with the first is a rejected trade, you can modify sticky.js to read from the "rejected" variable from the config file. I will include the code in a reply post if anyone is interested. 

I now have to implement this in all of the strategies that I use. I can't wait for the official fix from AskMike. I know it is on his to-do list.


  https://www.newhealthera.com/trialix/
Posted by: glynjing - 01-14-2019, 04:50 AM - Forum: General Discussion - No Replies

we recommend that you try to go back to your ex even if you are married to a good-looking millionaire younger than you. You have more possibilities Do not look at the details When you enter a place with the intention of flirting, 


  Coming up with a "Strategy"-strategy
Posted by: wilbertvdl - 01-13-2019, 11:43 PM - Forum: Automated Trading - No Replies

Hi all,

I'm wondering: how do you guys define which strategy you are eventually going to use in live trading?

I've been doing a fair bit of backtesting, with both manual parameters setting and bruteforce/gekkoga results. Both on various strategies like MACD, RSI_BULL_BEAR(_ADX), RSI, etc. And of course on various timeframes.

With all these combinations I obviously get very mixed results. One strategy with a certain set of parameters perform better on certain timeframes and other strategies better on other timeframes.

As far as I can see it there are a couple of steps involved in defining what strategy you're going to use:
Determine which asset/currency you're going to trade;
BTC/USDT, ETH/BTC, XRP/ETH, etc.

What timeframe would you like to cover in your upcoming trade-periode;
Are you looking for shortterm (few weeks, a month) or longer term (months, year) trade-period?

What timeframe in the history would resemble your upcoming trade-periode (I guess this requires some feeling for the market);
Do you expect your upcoming trade-periode to be overall bullish or bearish?
Was there a time-span in history with a comparable trend?

What is the actual trade strategy you're going to use?
Do you base that on trying out a couple of strategies? Do you have a go-to strategy?

Finding the right parameters
(brutforce/gekkoga)backtesting?

To papertrade or not to papertrade?
Once you have your tradeperiod, strategy and parameters, do you actually start papertrading or do you start live-trading based on your research so far?

To be honest, I'm quite struggling with these steps. Perhaps my aproach is faulty or my knowledge lacking.

How did you come up with the set-up you're using for live-trading and which strategy are you using?

I would love to read it!


  Gekko Bot
Posted by: SebastianJu - 01-13-2019, 10:50 PM - Forum: General Discussion - No Replies

Hello everyone,

Just found the forum through Mikes post on bitcointalk, ages old in crypto times, I guess, but great read.

I wanted to see what the gekko bot is, is it a proof of concept bot? It looks like everyone is written in js, so performance wasn't a target it seems. Probably more for testing strategies, not for anything that relies on high frequency trades.

So I guess the backtesting functionality is the bots strenght, probably it's easy to include different indicators and such.

Out of interest, I once bought a bot on tradewave (honeybadger), never was able to test it back then and when I checked back, might be more than a year later, tradewave was gone already. :Big Grin Only the free version of the bot is used by someone on cryptotrader, while not performing really impressive. I believe the owner only used something like crossing ma's and pattern recognitions, really simple indicators. So is testing things like that the target of Gekko bot? Is the dev maybe on here as well, on first sight it looks like some great minds gathered here. Big Grin

Thanks for all your thoughts so far!
Sebastian


  Parameter optimization of Neural strategies
Posted by: Bychance - 01-13-2019, 05:27 AM - Forum: Strategy Development - Replies (2)

Hi friends,
Is there any guide on how to optimize the parameters for neural strategies? I found several posts about using the genetic algorithm to optimize the parameters. I did not see any information if it can be used for neural strategies as well. However, I could not run the genetic algorithm and appreciate if anybody could help. The steps mentioned by Gekko warez did not work for me. I found some others had the same problem with running the genetic algorithm.
Thanks,


  Multiple assets trading
Posted by: Bychance - 01-13-2019, 05:21 AM - Forum: Strategy Development - Replies (3)

Hi friends, 
I started using Gekko currently. I'm using Linux commandline to run gekko. I added several alts and started trading based on BNB. Is there any way to limit the buy and sell of each coin based on its balance? Because I noticed that the trading bot used my total BNB balance just for one coin. It will be ideal if the trading bot just could buy and sell based on each coin's balance and add each profit (if any!) for further trading of that coin.
Thanks


  I can not start the web interface
Posted by: vam - 01-12-2019, 06:20 PM - Forum: Technical Support - No Replies

I installed gekko in docker in a virtual machine without nginx. When I try to access it from the host machine, I see this popup:



Disconnected

Something happened to either Gekko or the connection. Please check the terminal where Gekko is running or your network connection.
[i]This message is shown when the UI is unable to open a websocket connection with the Gekko Server.[/i]




Tell me something I'm doing wrong?


  Idex.market support
Posted by: vam - 01-12-2019, 06:16 PM - Forum: General Discussion - No Replies

Tell me please, is there any support for the Idex decentralized exchange?


  Installing Gekko (Dependencies) help
Posted by: nwksaxman - 01-11-2019, 05:50 PM - Forum: Technical Support - No Replies

attempting to install Gekko on a raspberry pi 3b+. however the code in the section on "Installing Gekko's dependencies" isn't working.   I get "-bash nom: command not found". can someone point me in the right direction.  thanks!


  I'm new here at Gekko - Problems
Posted by: informaster - 01-11-2019, 02:15 PM - Forum: Strategy Development - No Replies

I made a strategy where every time they cross the middle, buy or sell.

I'm working with binance ...

What is certain is that theft opens but then closes soon.

Can someone explain what I'm doing wrong?

Code:
/ GTR
var strat = {};

// Prepare everything our strat needs
strat.init = function() {
 this.name = 'GTR';
 this.trend = 'none';

 this.requiredHistory = this.tradingAdvisor.historySize;


 this.addTulipIndicator('slow', 'ema', {
   optInTimePeriod: this.settings.slow
 });

 this.addTulipIndicator('fast', 'ema', {
   optInTimePeriod: this.settings.fast
 });


}

// What happens on every new candle?
strat.update = function(candle) {

}

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


strat.check = function(candle) {

 const ema1 = this.tulipIndicators.slow.result.result;
 const ema2 = this.tulipIndicators.fast.result.result;
 var   priceclose = candle.close;
 //console.dir(ema1)


   if (ema1 > ema2){
       this.trend = 'Compra';
       this.advice('long');

       console.dir(this.trend)
   }

   if (ema1 < ema2){
     this.trend = 'Venda';
     this.advice('short');

     console.dir(this.trend)
   }    


}

module.exports = strat;



Attached Files
.jpg   Screenshot_1.jpg (Size: 169.61 KB / Downloads: 8)