davisvaughan / flyingfox Goto Github PK
View Code? Open in Web Editor NEWAn R Interface to the Quantopian Zipline Financial Backtester
Home Page: https://rstudio.cloud/project/38291
License: Other
An R Interface to the Quantopian Zipline Financial Backtester
Home Page: https://rstudio.cloud/project/38291
License: Other
Hi,
first of all, thank you for introducing the quantopian backtesting module into R! While running your basic example classic dual moving average crossover I get the following error after running the chunk
``
performance <- fly_run_algorithm(
initialize = fly_initialize,
handle_data = fly_handle_data,
start = as.Date("2013-01-01"),
end = as.Date("2016-01-01")
)
``
Error in py_call_impl(callable, dots$args, dots$keywords) :
ValueError: no data for bundle 'quandl' on or before 2018-08-12 22:48:44.663246+00:00
maybe you need to run: $ zipline ingest -b quandl
Detailed traceback:
File "", line 50, in py_run
File "C:\Users\Simon\Anaconda3\Lib\site-packages\zipline\utils\run_algo.py", line 430, in run_algorithm
blotter=blotter,
File "C:\Users\Simon\Anaconda3\Lib\site-packages\zipline\utils\run_algo.py", line 141, in _run
bundle_timestamp,
File "C:\Users\Simon\Anaconda3\Lib\site-packages\zipline\data\bundles\core.py", line 521, in load
timestr = most_recent_data(name, timestamp, environ=environ)
File "C:\Users\Simon\Anaconda3\Lib\site-packages\zipline\data\bundles\core.py", line 497, in most_recent_data
timestamp=timestamp,
After trying zipline ingest -b quandl the following error emerges:
Traceback (most recent call last):
File "C:\Users\Simon\Anaconda3\Scripts\zipline-script.py", line 11, in
load_entry_point('zipline==1.3.0', 'console_scripts', 'zipline')()
File "C:\Users\Simon\Anaconda3\Lib\site-packages\click\core.py", line 722, in call
return self.main(*args, **kwargs)
File "C:\Users\Simon\Anaconda3\Lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "C:\Users\Simon\Anaconda3\Lib\site-packages\click\core.py", line 1066, in invoke
return process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\Simon\Anaconda3\Lib\site-packages\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Simon\Anaconda3\Lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "C:\Users\Simon\Anaconda3\Lib\site-packages\zipline_main.py", line 348, in ingest
show_progress,
File "C:\Users\Simon\Anaconda3\Lib\site-packages\zipline\data\bundles\core.py", line 451, in ingest
pth.data_path([name, timestr], environ=environ),
File "C:\Users\Simon\Anaconda3\Lib\site-packages\zipline\data\bundles\quandl.py", line 209, in quandl_bundle
environ.get('QUANDL_DOWNLOAD_ATTEMPTS', 5)
File "C:\Users\Simon\Anaconda3\Lib\site-packages\zipline\data\bundles\quandl.py", line 113, in fetch_data_tabl
"Failed to download Quandl data after %d attempts." % (retries)
ValueError: Failed to download Quandl data after 5 attempts.
Googling around a bit it seems the quantopian guys have changed the default bundle to quantopian quandl as the command zipline ingest -b quantopian-quandl works.
What needs to be changed in calling you example code, so that it searches for data in quantopian quandl and not quandl dataset?
Hi ,
This is not a bug. but I don't know where to put my question.
i tried to assign a security list to the context, like:
python:
context.security_list = [sid(24), sid(5061), sid(39840), sid(21435)]
flyingfox:
fly_initialize <- function(context) {
context$i <- 0L
sList <- c("ARNC","AAPL","ABT","ADSK","TAP","ADBE","ADI","ADM")
context$asset <- sList
}
fly_handle_data <- function(context, data) {
# Increment day
context$i <- context$i + 1L
# While < 300 days of data, return
if(context$i < 21L) {
return()
}
price_hist <- fly_data_history(data, context$asset, "price", bar_count = 21L, frequency = "1d")
}
Error:
debugSource('~/ShortTermMeanReversion.R')
Error in py_call_impl(callable, dots$args, dots$keywords) :
RuntimeError: Evaluation error: ValueError: invalid literal for int() with base 10: 'ARNC'.
Can you help? Or do you have some example that I can follow?
thanks
Mark
hi David,
thank you for the fantastic job. One quick question. you mention
To get started with zipline, you’ll need the zipline Python module. Install it with:
install_zipline()
i tried the following:
library(flyingfox)
install_zipline()
Solving environment: ...working... failed
PackagesNotFoundError: The following packages are not available from current channels:
Current channels:
however, install zipline in anaconda worked.
here is anaconda info:
(base) C:\Windows\system32>conda info
active environment : base
active env location : C:\ProgramData\Anaconda3
shell level : 1
user config file : C:\Users\mark\.condarc
populated config files : C:\Users\mark.condarc
conda version : 4.5.4
conda-build version : 3.10.9
python version : 3.5.5.final.0
base environment : C:\ProgramData\Anaconda3 (writable)
channel URLs : https://conda.anaconda.org/Qantopian/win-64
https://conda.anaconda.org/Qantopian/noarch
https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/win-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/pro/win-64
https://repo.anaconda.com/pkgs/pro/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\ProgramData\Anaconda3\pkgs
C:\Users\mark\AppData\Local\conda\conda\pkgs
envs directories : C:\ProgramData\Anaconda3\envs
C:\Users\mark\AppData\Local\conda\conda\envs
C:\Users\mark.conda\envs
platform : win-64
user-agent : conda/4.5.4 requests/2.19.1 CPython/3.5.5 Windows/7 Wi
ndows/6.1.7601
administrator : True
netrc file : None
offline mode : False
(base) C:\Windows\system32>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.