I'm ultimately trying to use a url to fetch a single symbol for the current backtest day and I am having an incredibly difficult time getting around Quantopian's platform restrictions.
I tried Fetcher and first tried to change the backtest date in the query param of the url... however it only runs once in backtest mode and daily on live mode (also why? seems dangerous to have state behave differently in those cases!)
Next I then tried to fetch all the symbols at once, each row with their own date and that isn't working for me either. Because I don't know what the symbols will be on a given day I tried using data.fetcher_assets
but that seems to pull in any rows on the same day and earlier, but not in the future. I'm struggling to only filter it to the current day.
# fetch all symbols (not just a specific date)
fetch_csv("https://myserver.com/api/stocks?category=opening_bell&format=csv", date_column="date", date_format="%y-%m-%d")
CSV:
csv
date,symbol,category
2017-05-22,ARE,foo
2017-05-18,BEDU,foo
2017-05-16,ED,foo
2017-05-15,GM,foo
and then in handle data I am getting all the current day and past stocks:
for stock in data.fetcher_assets:
print stock.symbol
if data.can_trade(stock) and context.bought == False:
order_target_value(stock, (CASH * LEVERAGE))
context.bought = True
print "Bought " + stock.symbol
So is there any way that I can either:
- run the fetch_csv every day in init (not likely)
- or just fetch the row(s) for the current backtest day?