Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Customized setting for ping-pong trade (Sample: BTC-XRP pair in Poloniex) #1252

Closed
bitkominer opened this issue Oct 28, 2017 · 18 comments
Closed
Labels

Comments

@bitkominer
Copy link

bitkominer commented Oct 28, 2017

Hi, this is a sample of customized setting I made to make ping-pong trade. I'm using it to trade BTC-XRP pair in Poloniex.

1. I'm using short periode RSI to generate BUY-SELL signals. (inside config.js):

config.tradingAdvisor = { enabled: true, method: 'RSI', candleSize: 1, historySize: 3, adapter: 'sqlite', talib: { enabled: false, version: '1.0.2' } }

// RSI settings: config.RSI = { interval: 3, thresholds: { low: 30, high: 70, // How many candle intervals should a trend persist // before we consider it real? persistence: 1 } };

2. Inactivate cancel orders step. Just to let gekko execute all orders, and wait the pending orders to be executed later whenever the price movement strikes on them. (inside potfoliomanager.js):

`Manager.prototype.checkOrder = function() {
var handleCheckResult = function(err, filled) {
if(!filled) {
//log.info(this.action, 'order was not (fully) filled, cancelling and creating new order');
//-----inactivate below line to skip cancel orders
//this.exchange.cancelOrder(_.last(this.orders), _.bind(handleCancelResult, this));

  return;
}

`

3. Customize the BUY-SELL setting (inside potfolioManager.js, in the "Manager.prototype.trade" function):

`this.action = what;

var act = function() {
var amounttobuy, amounttosell, price, upperprice, lowerprice, minimumbalance, minimumasset, lotsize;

//if signal BUY appears
if(what === 'BUY') {

  //Split your bankroll at least into 10 lots. Lotsize is in currency (BTC).
  lotsize = 0.00010500;

  //define price to sell HI, 7 satoshi above current bid to make quick sell
  price = this.ticker.bid + 0.00000007;
  amounttosell = (lotsize + (0.005*lotsize)) / price;

  //define price to buy LO, 0.5% below sell price
  lowerprice = price - (0.005 * price);
  amounttobuy = lotsize / lowerprice;

  //define minimum parameter to execute pingpong trade
  minimumasset = amounttosell + (0.01*amounttosell);
  minimumbalance = 0.00011000;


  //execute buy LO if balance > minimum parameter
  if(this.getBalance(this.currency) > minimumbalance){
      this.buy(amounttobuy, lowerprice);
  }

  //execute sell HI if asset > minimum parameter
  if(this.getBalance(this.asset)>minimumasset){
		  this.sell(amounttosell, price);
  }

//if signal SELL appears
} else if(what === 'SELL') {

  //Split your bankroll at least into 10 lots. Lotsize is in currency (BTC).
  lotsize = 0.00010500;

  //define price to buy LO, 7 satoshi below current ask to make quick buy
  price = this.ticker.ask - 0.00000007;
  amounttobuy = lotsize / price;

  //define price to sell HI, 0.5% above buy price
  upperprice = price + (0.005*price);
  amounttosell = (lotsize + (0.005*lotsize)) / upperprice;

  //define minimum parameter to execute pingpong trade
  minimumbalance = 0.00011000;
  minimumasset = amounttosell + (0.01*amounttosell);

  //execute sell HI if asset > minimum parameter
  if(this.getBalance(this.asset) > minimumasset){
      this.sell(amounttosell, upperprice);
  }

  //execute buy LO if balance > minimum parameter
  if(this.getBalance(this.currency) > minimumbalance){
	  this.buy(amounttobuy, price);
  }
}`

Please have a try, and you might give a feedback to furnish the setting.

Note: not sure if the setting can be backtested. I'm only using it in real trade mode thru terminal and checking the result in polo trade history.

@askmike
Copy link
Owner

askmike commented Oct 28, 2017

Thanks a lot for sharing! When I am working on exchange integration and I need to test buys and sells I use this strategy which triggers a signal every 3 minutes (BUY/SELL/BUY/..): https://gist.github.com/askmike/959cada3c68f0bb3904ef08e7db28073

@bitkominer
Copy link
Author

I tried a similar approach, ie: a time-based pingpong strategy eg.: every 2, 3 or 5 minutes strikes. (I used the strategy in CoinExchange by created a js+iMacros script). Basically it's working nicely in sideways market, but it's gonna eat up our bankroll during trending market when the price goes to opposite direction than we expect.

Since gekko has integrated TA strategies, I tried to utilize it as a trigger to determine the correct time to execute buy-sell order. I've been running this approach for 2 days, and the balance is stable after >200 strikes. What I need to do is furnishing the approach by making some tweaks, either on the RSI setting, or using different TA strategy other than RSI, or making lot size management to cover market fee (which is 0.15% in Poloniex).

I'm pretty sure that the above setting I made will give nice result if we can run it in 0% market fee exchange, such as in vipbitcoin exchange which I requested @danKHUU to add it into gekko in 1186.

@askmike
Copy link
Owner

askmike commented Oct 28, 2017 via email

@bitkominer
Copy link
Author

Great. I'll take a look on it first.

@bitkominer
Copy link
Author

If you are looking for a 0 fee exchange for market makers, you can use GDAX right now :)

Well... the smallest order of 0.01 in GDAX is quite big, especially for "micro" traders like me :)
That's why currently Poloniex is my favorite until @danKHUU comes back with vipbitcoin integration.

@bitkominer
Copy link
Author

bitkominer commented Oct 28, 2017

The above pingpong strategy can be downloaded from following gist: portfolioManager_pingpong.

It contains 2 supplemental js files to be saved inside folder: /plugins/trader/

To change back to default gekko portfolioManager, just inactivate pingpong variable inside trader.js (line#11):
var activatepingpong = false;

@askmike
Copy link
Owner

askmike commented Oct 28, 2017

Ah in order for your strategy to work you also needed to patch certain files. What you can also do is create a new fork of Gekko that includes all your changes, that makes it easier for other users to run your version.

@bitkominer
Copy link
Author

It was actually optional to patch certain files, since it can be done also inside portfolioManager individually. But it was quite complicated for some users.

I've never done creating any fork before, but I'll try to do it. Github is a new thing for me... :)
Hope I can do it soon.

Thanks!

@Altcoinnoob
Copy link

Hello @bitkominer and @askmike ,

Can you please give some advice to set this up?

I tried to set up the ping pong trader but now I still have to patch the files like askmike notices.

Any help on this? Now I get the error that I can not get market data.

Thank you.

@BitKwik
Copy link

BitKwik commented Jan 14, 2018

Hi all,

I am a bit new to using bots for trading so I perhaps have some silly questions.

I installed gekko and did some backtesting of the example strategies. Now I would like to start with develop my own strategy and this pingpong strategy is interesting to start with.

I replaced the files that can be downloaded here: portfolioManager_pingpong.

Can I now simply start using the strategy RSI, and then it uses this ping pong strategy or am I making a thinking mistake?

Thanks for your help!

@BitKwik
Copy link

BitKwik commented Jan 16, 2018

@askmike could you please help me with this issue? I really like to get this thing working but I seems that I cant get it running

@bitkominer
Copy link
Author

bitkominer commented Jan 17, 2018

Hi @BitKwik & @Altcoinnoob, if you just wanna give a try, here's a modified portfolioManager

No need to patch certain files, just replace the portfolioManager.js using the modified file, then run gekko as usual.

This setting can be used for poloniex (USDT-BTC), using lot size of 11K satoshi for each trade. (You might modify the lot size in variables: amounttobuy & amounttosell).

Inside config file, make following settings to get frequent buy & sell.

exchange: 'poloniex', currency: 'USDT', asset: 'BTC',

config.tradingAdvisor = { enabled: true, method: 'RSI', candleSize: 1, historySize: 3, adapter: 'sqlite' }``

// RSI settings: config.RSI = { interval: 5, thresholds: { low: 30, high: 70, // How many candle intervals should a trend persist // before we consider it real? persistence: 2 } };

@BitKwik
Copy link

BitKwik commented Jan 18, 2018

Thanks! I will give it a try

@arisuryo
Copy link

hi..@bitkominer, i have gekko installed in my rpi3 but till now i havent use it to trade in real market.i dont have any knowledge regarding programing,i only use it bactest in ui mode. how can i use your strat in UI mode, which part of the script needs to modified, and also i trade in indonesian currency.Thank you.

@gitOtonaut
Copy link

Hi,
when i try to run the portfolioManager_pingpong with commandline live gekko
i receive following error, could you please let me know how to patch files?
Thx in advance,

`2018-03-05 21:22:30 (INFO): Setting up:
2018-03-05 21:22:30 (INFO): Advice logger
2018-03-05 21:22:30 (INFO):
2018-03-05 21:22:30 (INFO): Setting up:
2018-03-05 21:22:30 (INFO): Trader
2018-03-05 21:22:30 (INFO): Follows the advice and create real orders.
2018-03-05 21:22:30 (DEBUG): getting ticker, balance & fee from binance
/gekko/plugins/trader/trader.js:13
this.manager.init(next);
^

TypeError: this.manager.init is not a function
at gekko/plugins/trader/trader.js:13:16)
at /gekko2/gekko/core/pluginUtil.js:95:22)
at /gekko2/gekko/node_modules/async/dist/async.js:1156:9
at /gekko2/gekko/node_modules/async/dist/async.js:1030:17)
at /gekko2/gekko/node_modules/async/dist/async.js:1015:17)
at /gekko/node_modules/async/dist/async.js:988:16
at /gekko/node_modules/async/dist/async.js:1158:13
at /gekko/core/pluginUtil.js:103:9
at Timeout._onTimeout (/gekko/node_modules/lodash/dist/lodash.js:5496:43)
at ontimeout (timers.js:458:11)
`

@JohannesHoppe
Copy link

Hello guys. Many thanks for you efforts on gekko.

Is there any chance to backtest the modified portfolio manager from @bitkominer? As far as I understand the architecture, it should be hard to get meaningful results. We don't know if one or both orders will be filled or not. During backtest we can't answer that for sure, because we don't have access to the order book. Please correct me if I'm wrong. Do you really test this out with real money until it works? 🤔

@FreshLondon
Copy link

have the same issue as @sterns - was attempting to edit the pingpong files for my own but realise even basic use of them fails (after rolling back my edits).

Any advice as to why this wouldn't work, maybe the new updates are clashing with this older script?

Any help greatly appreciated

@stale
Copy link

stale bot commented Oct 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you feel this is very a important issue please reach out the maintainer of this project directly via e-mail: gekko at mvr dot me.

@stale stale bot added the wontfix label Oct 24, 2018
@stale stale bot closed this as completed Nov 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants