Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v20 #8

Open
streetgainer opened this issue Jul 6, 2019 · 7 comments
Open

v20 #8

streetgainer opened this issue Jul 6, 2019 · 7 comments

Comments

@streetgainer
Copy link

Is there a v20 update?

@PeterMalkin
Copy link
Owner

Havent been using 2.0. Is it needed? Ping me if you have something in mind

@streetgainer
Copy link
Author

I actually started the process, my oanda account is v2. So I'm doing the conversion line by line in the oanda.py script. Could you answer this, CANDLES_MINUTES is set in settings.py, what is the difference with that setting and size_of_candles_in_minutes that is used in oanda.py

I'm a js programmer, never programmed python so forgive me if this seems like a dumb question. Thanks

@PeterMalkin
Copy link
Owner

I see. Thanks for doing this.

As you can see, I based the bot on oandapy.py - which was the REST-level wrapper around their 1.0 API. So may be its just as simple as replacing that wrapper?

As far as your question - settings.py contain bot-level settings that later are passed as parameters to other places in the code. In particular, CANDLES_MINUTES define what size candles to use, meaning how many minutes in a single candle should be. Then that value is used in main.py to pass onto as a parameter to a Strategy object. When strategy initialized itself, it tries to get historic data from the exchange (using GetCandles function). And I think it passes the value of CANDLES_MINUTES to that function.

Let me know if I can be of further assistance, or if you need help with the code

@streetgainer
Copy link
Author

streetgainer commented Jul 12, 2019

Yes, I thought that's what should be happening, but it's not, settings.py is only sending that CANDLES_MINUTES parameter to backtest.py, everywhere else throughout the script the candle size is being initialised individually like this..def __init__(self, oanda, candle_size = 120, email = None, risk = 2) this is from strategy.py
So it seems there is a bug there, as setting it in settings.py only won't propagate correctly throughout the rest of the script.

@PeterMalkin
Copy link
Owner

No, no bug here.
Look, you launch the bot by executing
python main.py
Therefore main.py is the entry point.
Strategy initialization happens in main.py on line 32:
https://github.com/PeterMalkin/oandapybot/blob/master/main.py#L32
As you can see, the value is passed to the object constructor. And it is defined in the settings.py.
What you are quoting is the default value for the function parameters, which is a separate feature of Python programming language. See more here: https://www.geeksforgeeks.org/default-arguments-in-python/

@streetgainer
Copy link
Author

Ok, bare with me. I'm a JS programming and have never programmed in Python, so I assumed it to be the same variable assignment procedure. Shame on me for that, I do apologize. Thanks for all your help thus far.

@PeterMalkin
Copy link
Owner

Oh, no worries at all. Happy to help if I can

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

No branches or pull requests

2 participants