askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.07k stars 3.95k forks source link

Current Price, Last Buy Price, and Multiple Timeline Strategy Questions #1995

Closed CmvrkDunn closed 6 years ago

CmvrkDunn commented 6 years ago

Note: for support questions, please join our Discord server

I am thoroughly amazed by Gekko and want to give you the highest compliments on its brilliance. Thank you for such an amazing tool and for all the time you take to support it!

I'm looking to integrate several factors into a strategy but am failing due to my lack of familiarity of gekko (though I have spent many hours looking it over) and difficulty finding working examples of properties / logic I'm trying to use in the strategy.

My end goal is to integrate a stop loss and a trailing stop into my strategy. Items I am hoping to learn about specifically:

I recognize this is honestly quite a bit to respond to. I think these are items that are basic building blocks to a successful strategy and would be helpful to many others as well. Any help is appreciated! Please keep up the great work. We are all counting on you ;)

Tiim12312 commented 6 years ago

Am interested in these issues as well!

askmike commented 6 years ago

Actual result (unexpected outcome) Child Process Died

Please use to commandline interface when developing as you get a lot more debug information.

I have not been able to find a property I can use in a strategy that holds the value of the last buy in price (or average of last buy in's if multiple partially filled), as opposed to assigning the candle.close value of an adviced to a variable. This would be essential for an accurate stop loss, trailing stop, and setting an "acceptable" sell price so sells are not purely indicator based.

The event from the develop branch exposes the "average" execution price under trade.price. Note that a lot more information will be shared in the future, have a look at #1850 which is in the works.

I am looking to monitor and act on the current coin price in real time. I am using Binance. I am concerned about monitoring the current price as a stop loss price can easily be blown by, even using 1 minute candles.

Gekko is focussed on long term trends, dealing with seconds instead of minutes means a bunch of things:

Unfortunately gekko is not build for people doing HFT kind of stuff, if you want this you can't really use Gekko :(

I am looking to base my strategy on multiple time frames. Mainly because if real time price updates are not possible, I would like my stop loss and trailing stop to act off of candle.close on the 1 minute time frame while my buy in strategy act on a different strategy, like the 5 minute time frame. Or even to make a RSI strategy that buys if the 15 minute and 1 hour RSI is under 30%.

There have been some discussions on multi timeframe strategies before, the hard thing here is that configuring and creating strategies becomes very complex. Please have a look on the issue tracker. I want to move in a direction that the compenents that make up the current "tradingAdvisor" (base stratrunner) can be reused to make a more complex one that can do these things.

Can volume be used as an indicator?

Yes! Every candle has a volume prop :)

Do you have links to any helpful video walkthroughs commenting on files and code segments of gekko? This would really help with general understanding of the different pieces under the hood as well as help possibly head off support questions.

Not yet unfortunately, working on this though.

Any debugging tips?

Use the commandline interface :)

CmvrkDunn commented 6 years ago

Thank you for your response, it was extremely helpful! It has given me much better insight into how gekko works and appreciation for the hard work you have put into it. Your thoughtful response and my working with gekko on my above mentioned strategy has spurred some additional questions. Again, thank you SO much for taking the time, it is a tremendous help to us all!

Follow-up Questions:

Backtesting

How does this.tradingadvisor.histoysize work in backtesting vs live gekkos? If I understand correctly, when you specify required history in backtesting, no trades are advised until that amount of time has passed. In live trading, does gekko need to wait the number of required history candles or does it download that amount of past history candles directly from the exchange and start advising almost right away? Does some kind of stitching occur from downloaded backtesting to enable live trading advise to be available sooner? Just wondering as a daily MACD indicator could take day 26 days to initialize before trades if it couldn't download previous history. It would be extremely painful to restart your strategy if say your computer needed to restart.

Using the ui version of gekko, has their been any complaints of the backtesting total percentage being inaccurate?

For extensive and in depth backtesting, is there significant advantages using MongoDB vs SQLite? If not, are there instructions / discussions on how to interface with the SQLite database directly? If so, are there instructions on how to switch data storing to MongoDB and how to interact with the database directly?

Overlapping question: Does gekko have the ability in backtesting (or live and paper trading for that matter) to export trade summaries to an Excel or text file? Kind of like the backtesting summary but with more information such as buy in price, sell price as well? If so, is it possible to customize the data fields exported?

Is there any possibility of backtesting or ui live gekko displaying a tradingview.com chart? It would be so helpful to look at in depth detail of each trade afterwards to see what improvement in the strategy is possible or to find common trends.

Strategy

Does gekko have the ability to short if an exchange allows it? Using gekko on Bitfinex for example?

In sample strategies, I see references to this.settings. Where is this referring to? I recognize that this.config is referencing variables in the strategies toml file but didn't find a similar file for this.settings. Is this.settings referring to the timeframe and required history from gekko's ui? Does it refer to variables in your strat.init?

Has there been any discussions about strategies that recognize and act on patterns like an equilibrium, bull or bear flag, or inside bars?

In your response, you referenced trade.price as a property that holds average last buy price. Can you give a brief snippet of trade.price usage in a strategy (how do you call it, I imagine by assigning it to a variable in the update function of your strategy)?

Is there any perceivable way to change variables in your method while a live gekko is running (that the live gekko would then start acting on)? For example, in the case of having a general strategy but you manually place a buy at an opportune point, from the ui you could update your boughtin variable to true along with the buy in price and let the bot handle selling. This would help not having to stop and start the strategy over in this situation or risk having the bots buying and selling out of sync with the actual buy / sell situation on the exchange.

Assuming a strategy is using one minute candles, using counters to delay indicator result calculation, I edited the RSI and MACD indicators to each give multiple timeframe results to be used in the same strategy (calculations tested successfully). I did this to achieve quickest price reaction gekko allows as well as providing more strategy conditions to use. Can you think of any consequences of this? I'm sure there is a more elegant design approach than I took (willing to send you the files), and I'd love to hear if any come to mind and your thoughts on this. Ultimately I think this would be terrific if it could be integrated into the ui though I know it would require some major front end design changes.

Again, thank you, thank you, thank you for your time and helpful responses. They are beyond appreciated!!

askmike commented 6 years ago

Hey! This bug tracker is not the best place to discuss these things. Would you mind posting the questions on the forum instead: https://forum.gekko.wizb.it/

That way it becomes easier for other people to find them as well. If you post the link to the thread here I'll be sure to respond there :)

CmvrkDunn commented 6 years ago

Will do! Thank you in advance! Thread below:

https://forum.gekko.wizb.it/thread-56599.html