Back to Posts
Listen to Thread

Has anyone did any work with bitcoins?

You can load custom datasets using fetch_csv()

There are several relevant datasests on quandl, here's one: http://www.quandl.com/BITCOIN-Bitcoin-Charts/MTGOXUSD-Bitcoin-Markets-mtgoxUSD

Edited

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
156
Loading...
Backtest from to with initial capital ( data)
Cumulative performance:
Algorithm Benchmark
Custom data:
Week
Month
All
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Information Ratio
--
Benchmark Returns
--
Volatility
--
Max Drawdown
--
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
Information Ratio 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
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.

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']]  
    log.info(' \n %s % df.head()')  
    return df  
def initialize(context):  
    fetch_csv('http://www.quandl.com/api/v1/datasets/BITCOIN/MTGOXUSD.csv?trim_start=2012-01-01',  
        date_column='Date',  
        symbol='weighted_price',  
        usecols=['Weighted Price'],  
        post_func=rename_col,  
        date_format='%Y-%m-%d'  
        )  
    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']:  
       record(weighted_price=data['weighted_price'].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:  
        order(context.stock,-100)  
    elif price > vwap * 1.005 and notional < context.max_notional:  
        order(context.stock,+100)  

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.

Dan

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:
coinsetter
coinMKT
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

Log in to reply to this thread.
Not a member? Sign up!