Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Noob: How make a strategy that profit in bitcoin?

I'm complete noob at this, but wanna learn about how is possible to create a strategy that could profit from bitcoin trading.

In my naive understanding, If I start with 1 BTC at US 100 I could sell at US 110+ and buy at US 90-, if I imagine that long term bitcoins must be always up (even if crash in the short term). How bad is my thinking? How understand how do this right?

I have expertise in python and account at https://www.coinsetter.com & coinbase. I suspect that the ability to do instant trading will be good.

6 responses

I don't think you can use Quantopian to do this. As far as I know there are no ETFs or stocks involved with bit coins.

They just added the function to import any data set:
https://www.quantopian.com/posts/new-feature-fetcher
You could use this to get the info for bitcoin.
http://www.quandl.com/BITCOIN-Bitcoin-Charts/MTGOXUSD-Bitcoin-Markets-mtgoxUSD is one but it seems they don't have minute data.
If you find live feed of the data let us know.

Ok, now the questions is how simulate a trade that could make profit on it. I understand this is not live.

With the information that data give, what can be done to use it for trading? With http://gbeced.github.io/pyalgotrade/docs/v0.13/html/mtgox_tutorial.html exist a tutorial that do that, but the problem is that I don't understand the fundamentals to know what it is doing.

So for a newbie like me, what I need to read to learn how this kind of trading work?

Well, both of them are using python so you might want to look into that a bit.
http://www.codecademy.com is a great resource for beginners.
Then you can use the sample algorithm but instead of the apple id used there you can import your own.
https://www.quantopian.com/posts/new-feature-fetcher
Then you have the historical data and you can test your algorithm against that.

And in any case always read up if any question comes up. You might look at the graph at mtgox and wonder "What are those candlesticks" and then you go figure it out.

Maybe if I have time on the weekend I can put something together for you.

I have expertise in python, only need help in trading.

After read a little, I develop a python script that simulate prices of BTC in random.

After some profit, I save a little to later get that money back and let the rest be for trade. I think the problem with this is understand the basic concepts before move to more complicated matter, and is the kind of info I have not found yet.

Is this correct?

(Could run here. Pure python:) http://rextester.com/CLG92944

from random import randint  
from decimal import Decimal

margin = Decimal(0.03)  
stance = 'none'  
buyPrice = Decimal(0)  
sellPrice = Decimal(0)  
stockPrice = Decimal(0)  
investmentAmount = Decimal(50)  
previousPrice = investmentAmount  
totalProfit = investmentAmount  
coins = Decimal(0)  
totalCoins = Decimal(0)  
savings = Decimal(0)  
savingsAmount = Decimal(0.2)


BUY_MSG = "BUY %.2f coins at %.2f (%.2f). Profit %.2f"  
SELL_MSG = "SELL %.2f coins at %.2f (%.2f). Profit %.2f"

def getValue():  
    for x in xrange(100):  
        yield Decimal(randint(750, 890))

#print list(getValue())  
for stockPrice in getValue():  
    if stance == 'none':  
        if stockPrice  totalProfit:  
                buyPrice = totalProfit  
            else:  
                buyPrice = stockPrice

            coins = buyPrice / stockPrice

            totalCoins += coins

            totalProfit -= buyPrice  
            print BUY_MSG % (coins, buyPrice, stockPrice, totalProfit)

            stance = 'holding'  
    else:  
        if stockPrice > buyPrice * margin + buyPrice:  
            coins = totalCoins

            sellPrice = stockPrice * totalCoins

            totalCoins = Decimal(0)

            totalProfit += sellPrice

            print SELL_MSG % (coins, sellPrice, stockPrice, totalProfit)

            # Ahora guardar un poco en el ahorro!  
            if totalProfit > investmentAmount:  
                amountToSave = savingsAmount * totalProfit  
                savings += amountToSave  
                totalProfit -= amountToSave  
                print "\tSaved %.2f" % amountToSave

            stance = 'none'

    previousPrice = stockPrice

print "\n\n"  
print "Initial investment:", investmentAmount  
print "Final: %.2f Coins =  %.2f" % (totalProfit, totalCoins)  
print "In savings: %.2f" % savings  

I am sorry I don't really understand what it is you are asking.
You have the github tutorial that explains how to trade on mntgox, by sending buy and sell orders.
You have a python script that can send those orders and you have historical data to backtest it.

Are you asking for what strategy makes sense?
Nobody can tell you that. Buy low and sell high, now the only question is how you determine what is high and what is low.
You can fit it with a spline and check the derivative and develop some momentum trading strategy or you can compare current price to three day average or whatever you want.

Bitcoin trading is a nice start because there is very low delay between order placed and executed and you can start with 10$ to just try it. Also you can still take advantage of price differences between different exchanges.

Check against historical data that there is no runaway effect in your strategy and then just try it on the market.