omid kiasat
omid kiasat

Reputation: 31

How to Order a fraction of a Crypto (like Bitcoin) in zipline?

Basically as you all know we can backtest our strategies in Zipline, the problem is that Zipline is developed for stock markets and the minimum order of an asset that can be ordered is 1 in those markets but in crypto markets we are able to order a fraction of a Crypto currency. So how can I make zipline to order a fraction of Bitcoin base on the available capital?

Upvotes: 0

Views: 197

Answers (1)

SimplyFarzad
SimplyFarzad

Reputation: 51

You can simulate your test on a smaller scale, e.g. on Satoshi level (1e8).

I can think of two methods:

  1. Increase your capital to the base of 1e8, and leave the input as is. This way you can analyse the result in Satoshi, but you need to correct for the final portfolio value and any other factors that are dependent on the capital base.
  2. Scale the input to Satoshi or any other level and change the handle_data method to either order on Satoshi level or based on your portfolio percentage using order_target_percent method.

NOTE: Zipline rounds the inputs to 3 decimal points. So re-scaling to Satoshi turns prices that are lower than 5000 to NaN (not considering rounding errors for higher prices). My suggestion is to either use 1e5 for Bitcoin or log-scale.

Upvotes: 0

Related Questions