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

Compare buy/sell price #772

Closed
talvasconcelos opened this issue Jun 6, 2017 · 7 comments
Closed

Compare buy/sell price #772

talvasconcelos opened this issue Jun 6, 2017 · 7 comments

Comments

@talvasconcelos
Copy link

Hi @askmike , is there any way i can, on sell, check if the price is lower than what was bought?

I mean i want the trader, when given an advice to sell, or before that, to check if price is lower than originally bought. If so, hold the coins/assets whatever...

Thanks,
Tiago

BTW, this is my attempt at a strategy, is very rough. Performs well on sim, been running live on my RPi3 and no buy or sell yet...
Rename file to .js
CCIRSI .txt

Rename to .toml
CCIRSI .txt

@askmike
Copy link
Owner

askmike commented Jun 6, 2017

Hey @talvasconcelos,

is there any way i can, on sell, check if the price is lower than what was bought?

Gekko works with the ideas of strategies, this would be logic that you'd have to script in your own strategy (or based on an existing strategy). The exact same issue came up some time ago, see here for context as well as implementation: #502.

BTW, this is my attempt at a strategy, is very rough. Performs well on sim, been running live on my RPi3 and no buy or sell yet...

If your strategy is not buying or selling it is caused by these condionals:

if (cci.result >= this.uplevel && this.stochRSI > this.highlevel){
    log.debug("CCI is high")
    log.debug("sRSI is high. Sell!")
    //this.stop.high  candle.high;
    this.advice('short');
  } else if (cci.result <= this.downlevel && this.stochRSI < this.lowlevel) {
    log.debug("CCI is down")
    log.debug("sRSI is low. Buy!")
    //this.stop.low = candle.low;
    this.advice('long');
  } else {
    log.debug("No advice")
    this.advice();
  }

I would suggest logging all the variables inside the if statements to see why the never evaluate to true. For example by logging just above the if check:

log.debug(cci.result, this.uplevel, this.stochRSI, this.highlevel);

@askmike
Copy link
Owner

askmike commented Jun 6, 2017

I am closing this, but feel free to ask more questions :)

@askmike askmike closed this as completed Jun 6, 2017
@talvasconcelos
Copy link
Author

Sorry for my noob questions... so there's only 1 buy order at a time? until the bot sells it doesn't buy again?

Thanks for the help above, it's gold...

i had the conditionals different:

if (cci.result >= this.uplevel)
    if (this.stochRSI > this.highlevel)
        this.advice('short')
if(other way around)
    if(other way around)
        this.advice('long)
this.advice()

but it seemed not to work like it was supposed... i tend to console log a lot to check where i am and what values come out. Thanks again for your help.

@askmike
Copy link
Owner

askmike commented Jun 6, 2017

so there's only 1 buy order at a time? until the bot sells it doesn't buy again?

Within Gekko buying and selling is separate from the strategy. A strategy is simply a script that gets candles and outputs advices (this.advice). This advice goes into either the paper trader or the real trader (depending on if you are simulating or running live) and they create buy/sell orders based on this advice. If your strat says "long" the (paper) trader will try trade so that all the money is into the asset.

In an ideal situation there is only a single buy order per advice (this is always the case with paper trader, since it's a simulation). But the real trader might create multiple orders depending on the orderbook, etc.

@thegamecat
Copy link

Write all the values out per candle to a csv :)

@Gebrax
Copy link

Gebrax commented Dec 21, 2017

why log.debug is not working?
ReferenceError: log is not defined

@bennycode
Copy link
Contributor

why log.debug is not working?

You need to import log in your strategy:

var log = require('../core/log');

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants