Back to Community
fetch_csv API question

Hi

I see syntax for fetcher like this: (note the usecols)

fetch_csv(yahoo_vix_url, date_column='Date', date_format='%Y-%m-%d', symbol='vix', usecols=['Adj Close'], post_func=post_func)
context.xiv = sid(40516) #xiv

I don't see the API mentioning something like the usecols. Is that my lack of experience in python or I missed some other API doc ?
The copy that line from this community posting: https://www.quantopian.com/posts/method-to-get-historic-values-from-fetcher-data

12 responses

Hi, 'usecols' is an argument that pandas.io.parsers.read_csv accepts to select certain columns of a file. fetch_csv accepts **kwargs parameters that are forwarded along to requests.get or or read_csv. See the last argument in the fetcher api reference or refer to pandas to see what other parameters are available.

Is that from yahoo finance... being fetch by fetcher...??? yahoo_vix_url,

Dears,

Can anyone nominate a good trading Algo for me? I need to buy a good one with monthly ROI 10%

Thank you

Everyone is interested in getting ROI of 10%

@Ahmed.. try this and optimize it...good luck.... https://www.quantopian.com/posts/simple-machine-learning-example-mk-ii

I see that fetch_csv can only be called inside initialization. I don't really know which file I want to load during initialization though. For example, if it is July, I load the July bond future price file. There is no way I can tell in advance which one I need. Is there any way to get around this problem ?

Fetcher always looks at today in the CSV file - never backwards or forwards. In live trading, Fetcher will see what data is available for today and only act upon that information. Even if you have data in the future, it will be ignored.

In live trading it's important to keep the historical contents of your CSV unchanged. We don't keep a copy of your file, so if you want to add new information to the CSV, then append it to the bottom of the document. This creates a growing file and your algo can keep running. Take a look here for more info (bullet point #6): https://www.quantopian.com/help#overview-livetrading

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Let me explain a little better. I am running a backtest not live trading. Say today is 7/20/2015 and I know I want to buy today but I have one more condition to check. I need to check bond future prices using Fetcher_csv function. However, I have no idea which bond future file I want to check during initialization. When I know that I want to buy on 7/20/2015, I know I need to check the bond future contract for July and August and the quote I need are 7/20/2015. There is no way I can tell in advance during init which file I need to load. I cannot just tag along all files in a huge file either......

Any idea ?

ah, that's a different angle. You will need to load a file in advance to the algo.

Is there a screener you could use? You could screen the contract information from multiple sites to create your own custom CSV, and then pull this CSV into Fetcher.

screener is an API call ? You mean fetch all csv and merge into one custom one ? hmm let me think about that

There isn't an API call named 'screener'. I meant you can scrape the data online (from the sources you usually frequent) and then pull this data into a CSV you maintain. Then, you can import your custom CSV via fetcher to the algo.

@Gambulator - You can have more than one Fetcher call. Create 12 files, each named after a different month, some possibly initially empty, and put the corresponding 12 Fetcher calls in your code. Then you can append data to each file as needed. I don't know if you'll be able to discard old data from these files when you no longer need them, so they may have to grow forever, or at least as long as you run every algorithm that relies on them.