Back to Community
Anyway to import Bitcoin data?

Has anyone did any work with bitcoins?

13 responses

You can load custom datasets using fetch_csv()

There are several relevant datasests on quandl, here's one:

With Tyler's tip, I was able to cook together an example.

You can clone this and make a trading strategy now that you have the price imported.

Clone Algorithm
Backtest from to with initial capital
Total Returns
Max Drawdown
Benchmark Returns
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 516d6c7c3e08f2066274b4d7
This backtest was created using an older version of the backtester. Please re-run this backtest to see results using the latest backtester. Learn more about the recent changes.
There was a runtime error.

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.

I tried combining this with the sample algo but had no luck: halp?

import pandas

def rename_col(df):  
    df = df.rename(columns={'Weighted Price': 'price'})  
    df = df.fillna(method='ffill')  
    df = df[['price', 'sid']]' \n %s % df.head()')  
    return df  
def initialize(context):  
        usecols=['Weighted Price'],  
    context.stock = sid(3766)  
    context.max_notional = 1000000.1  
    context.min_notional = -1000000.0

def handle_data(context, data):  
    if 'price' in data['weighted_price']:  
    vwap = data[context.stock].vwap(3)  
    price = data[context.stock].price  
    notional = context.portfolio.positions[context.stock].amount * price  
    if price < vwap * 0.995 and notional > context.min_notional:  
    elif price > vwap * 1.005 and notional < context.max_notional:  

What was the error?

I agree, the error will be helpful.

Also, Kent, what are you trying to do? Currently the backtester only permits buying and selling US equities. Bitcoin prices can be used as a signal, but you can't (yet) model buying and selling bitcoin. Is there a stock you are trying to trade as Bitcoin value changes?

it was a runtime error; didn't know modeling buying/selling wasn't implemented: that answers my question :)

Dan, will buying and selling bitcoins be possible in the future?

Hello Cos,

Our livetrading model depends on connecting your Quantopian account to a broker. So far there isn't an obvious bitcoin broker to do livetrading with.

I expect our bitcoin modeling tools will get strong this summer, though.


ahahhaha without read all the thread i try and try to do what Kent Davis just try to do without success!!!
anyway you have to contact:
they are going to open in days....

i doesn't understand why having the price is not possible to backtest, let's the user choose the fees and the spread if is this the problem, if not what is?
anyway the problem will be solved soon because now 2 broker will be open in days (coinmkt in 5 days, coinsetter will also work in around a week)

Is there any hope of having the ability to backtest buying / selling of bitcoin in the future? Arthur, I'm not quite clear on your comment, are you saying that coinsetter and coinMKT would allow us to backtest buying / selling within Quantopian? Thanks

Any further progress on this in terms of selling/buying cryptocurrencies please?

would also be interested to see more on crypto