-
Notifications
You must be signed in to change notification settings - Fork 4.7k
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
No where to change benchmark? #2311
Labels
Comments
Yes
…On Fri, Sep 28, 2018, 7:23 PM Yi Li ***@***.***> wrote:
Say, I am using v1.3.0 and trying to zipline.run_algo to run the
algorithm. If I do not change the source code, I cannot find a way to
change the benchmark.
1.
In the run_algo() source code
<https://github.com/quantopian/zipline/blob/v1.3.0/zipline/utils/run_algo.py#L206>,
it essentially creates a TradingAlgorithm object by inputing a env
variable.
2.
This env variable, defined in the function body
<https://github.com/quantopian/zipline/blob/v1.3.0/zipline/utils/run_algo.py#L154-L160>,
is created without explicitly giving the bm_symbol argument.
3.
Based on the definition of the TradingEnvironment class
<https://github.com/quantopian/zipline/blob/v1.3.0/zipline/finance/trading.py#L77>,
the env has the bm_symbol always equals to SPY.
4.
In this way, the env.benchmark_return property is thus created
<https://github.com/quantopian/zipline/blob/v1.3.0/zipline/finance/trading.py#L100-L104>
with bm_symbol='SPY'.
5.
Thus, when TradingAlgorithm use it
<https://github.com/quantopian/zipline/blob/v1.3.0/zipline/algorithm.py#L557>,
it uses the benchmark_return created with SPY.
So, it looks like the only way to change the benchmark from SPY to
something else is to:
- change the code of TradingEnvironment class, the default of bm_symbol
- or, when creating the env variable in run_algo() source code
<https://github.com/quantopian/zipline/blob/v1.3.0/zipline/utils/run_algo.py#L206>,
explicitly add the bm_symbol argument. (and probably add a bm_symbol
argument for the run_algo function)
Am I right?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2311>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/APkkZGMVU01NlltrXBWWY_YTNIcxHwY5ks5uftmZgaJpZM4XAR4e>
.
|
Apologies for the slow reply to this issue. On Zipline master, you can now pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Say, I am using v1.3.0 and trying to use
zipline.run_algorithm()
to run the algorithm. If I do not change the source code, I cannot find a way to change the benchmark.In the run_algo() source code, it essentially creates a
TradingAlgorithm
object by inputing anenv
variable.This
env
variable, defined in the function body, is created without explicitly giving thebm_symbol
argument.Based on the definition of the
TradingEnvironment
class, theenv
has thebm_symbol
always equals toSPY
by default (andload
variable always equals toNone
).In this way, the
env.benchmark_return
property is thus (always) created bybm_symbol='SPY'
.Thus, when
TradingAlgorithm
uses it (env), it always uses thebenchmark_return
created bySPY
.(6. btw, adding
context.set_benchmark(symbol('XXX'))
in theinitialize()
function is not useful, since it runs after the above environment process.)So, it looks like the only way to change the benchmark from
SPY
to something else is to:TradingEnvironment
class, the default ofbm_symbol
env
variable in run_algorithm() source code, explicitly add thebm_symbol
argument. (and probably add abm_symbol
argument for therun_algo
function)(in either way, we have to change the source code)
Am I right?
The text was updated successfully, but these errors were encountered: