Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Trading strategy for bitcoin: Only buy/sell if after fees never lose more than initial investment?

I'm a developer, and wanna create a trading strategy in charge of buy/sell bitcoins. I don't care at all about speculations or guessing the future or do anything fancy, I wish to have a simple strategy that buy/sell only if the balance after fees is never below a initial investment, and hopefully, increase the (positive) balance.

So, Let's say I have US 500. I have a 0.25% trading fee. I have a bot in python (maybe made with quantopian or pyalgotrade or custom made) that have all the patient in the world and get notified when the price of the currency pair change.

How proceed? Is possible this or I'm too naive?

8 responses

We have data for US stocks and ETFs on the platform, but if you have your own Bitcoin datasource, you can use Fetcher to import a custom CSV. Good luck!

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.

Yes, I have my own data. But my question is how do the strategy?

@Mario,
You realize you cannot trade BTC on Quantopian right? You can only trade equities here. You'd have to trade BTC on one of the dedicated exchanges that trade the pseudocurrency.

That said, in order to automate a trading system to trade BTC you'd have to drive a webpage with script in order to interact with these exchanges which, as far as I know, only work through web interfaces. You can get data from bitstamp through their websocket api: https://www.bitstamp.net/websocket/ but you'd still have to figure out how to submit orders through an interface like: https://zeroblock.com/. Not to mention that many web market exchanges have express verbiage in their license that forbids automation.

Would you rather trade FX then? Not here of course/ Or symbolic currency ETFs? Like UUP, FXE, FXB or FXA? Which you can trade here.

Yes, I know I need to use something else for the bitcoin.

I'm more interested in the idea of how hold transactions to no lost below the initial investment, so is in fact inmaterial the currency pair.

@Mario,
In simplest terms you're talking about a stop loss order.

You would buy X amount of BTCUSD and once you get executed (you confirm the trade) you can then place another order, a Stop order at a specific price (below where you bought it at), which will sell your BTCUSD if the current price of BTCUSD drops to touch your Stop order price. This type of order will stop your losses.

Yes, this is immaterial to whatever instrument you are trading.

Be aware that stop loss (sell stop order) can't protect you from lag on exchange side.
Bitcoin exchange like MtGox could have when crisis occurred several decade seconds.

Be also aware that market depth is also an important part of trading logic of not very liquid assets.
Zipline doesn't handle market depth.

is there a way we get the data that works seamlessly with the stocks? bitcoin that is...

Bitcoin etf coming... Eventually