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

Creating a Strategy #640

Closed
KryptoNova opened this issue Oct 16, 2017 · 4 comments
Closed

Creating a Strategy #640

KryptoNova opened this issue Oct 16, 2017 · 4 comments

Comments

@KryptoNova
Copy link
Contributor

Hello,

When it comes to strategies, I'm having a hard time determining what the difference should be when it comes to the significance of the "calculate" and "onPeriod" method within the strategy.

It appears that "calculate" is done on a timeframe that is not in agreement with the "onPeriod" where the "onPeriod" seems to align with the candlestick period that is defined.

This leads me to three questions.

  1. Should the "calcluate" method actually be firing buy/sell signals when the "onPeriod" is not soon enough?

  2. If a new object is added to the "s" object in the "calcluate", will it maintain the state of these additional objects for the lifetime of the zenbot session?

  3. Is there anywhere that I can see a breakdown of the core objects/properties and their explanations that reside in the "s" object that is passed between the "calculate" and "onPeriod" methods? Primarily, what is the significance of s.trend and s.signal and how they communicate to the bot what needs to happen in the market.

If anyone could shed light on these three questions, it would greatly help. Thanks!

@KryptoNova
Copy link
Contributor Author

I figured out the answer to question 2 through some trial-and-error. If anyone could shed some light on questions 1 and 3, that would be very helpful.
Thanks in advance!

@tuxitor
Copy link
Contributor

tuxitor commented Oct 17, 2017

@KryptoNova
And it would be good if you could shed some light on your findings ;-)

@KryptoNova
Copy link
Contributor Author

Sorry about that @tuxitor. That was rude of me.

For question 2, the answer is yes. State is maintained in the s variable for any objects that are created for the lifetime of the zenbot process.

When working with this variable care must be taken when it comes to memory management. Storing large, mutating objects in that variable can create large problems. When developing new strategies, it is a good idea to cleanup any array variables so they don't consume more resources than are available.

Any help with questions 1 and 3 would be greatly appreciated. Question 1 is particularly intriguing now since question 2 has been addressed.

@brucetus
Copy link
Contributor

brucetus commented Oct 18, 2017

For your first question: You can put the buy/sell signals in the calculate section. It works in simulations and there is a difference in timing of when the trade is executed, sometimes it's better and sometimes it's worse. I haven't tried it in live trading.

For the third: I'm not sure but you should look in zenbot/lib/engine.js

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

3 participants