Back

[Update] Crypto-Currency & Decimalized Orders

Hello All!

Just a quick update; we've merged a foundational change to the engine to support crypto-currencies in LEAN. This required allowing fractional orders. In traditional markets units are whole; you buy 1 share of AAPL, you have 1 futures contract. Crypto-currencies allow you to hold fractions of the token.

This new change should impact roughly 5% of people who refer to or save their order quantities directly. Previously you may have code which looks like this:

int quantity = Portfolio["SPY"].Quantity;

Which will no longer work as Quantity is now a decimal. If your code depends on the int type you can continue using it safely with Equity, Forex, Futures, Options etc as they all have round lots:

int quantity = (int)Portfolio["SPY"].Quantity;

However we recommend updating your code to the new generic form as its better in the long term:

var quantity = Portfolio["SPY"].Quantity;

 

Update Backtest






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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.



Hi Jared. Has Volume type been changed as well from Long to Decimal?
0

Yes, Volume type has been changed accordingly by patch #992.

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


good
0

Follow the Project at Github: Crypto Currency Support.

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


awesome
0

Now that the functionality for decimal amounts has to added to the core engine will there soon be official support for the more popular cryptocurrency exchanges?

0

Yes! We're working on it :)
0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Thanks for the help
0

I am looking at trading multiple cryptocurrencies through coinigy. They apparently use REST API. I am trying to get an understanding of how the pieces fit together and what I would need to do to trade using Coinigy and QuantConnect. Are you also working on a Coinigy interface. If not, any suggestions on where to start?

0

Hi Joel; tomorrow we're launching with GDAX deeply integrated with QuantConnect/LEAN.

To add a brokerage integration we need a dialog with the brokerage as it is a time consuming process. If you're interested in Coingy please petition them to reach out to QuantConnect and we can investigate an integration.

 Jonathan Andre you might want to beta test GDAX =)

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Great!  Thanks, I'll reach out to them and also check out your GDAX integration.

0

Jared Broad Are there any examples for crypto? I am trying to create a basic template just to show previous BTCUSD chart data from GDAX but nothing comes up. I've just shared it with you can you let me know what I'm doing wrong and a good basic template for crypto?

0

0

Is there a way to place a market order using a decimal quantity?  Looking at the documentation it looks like it takes int. If I wanted to scale out of a position in halves let's say, and I try to do something like this:

self.MarketOrder("BTCUSD", -.5 * d.Decimal(self.Portfolio["BTCUSD"].Quantity))

I get an error.

0

What is your error? I guess you must have this error: "Runtime Error: Trying to perform a summation, subtraction, multiplication or division between 'float' and 'decimal.Decimal' objects throws a TypeError exception. To prevent the exception, ensure that both values share the same type."

Do as the error says: ensure that both values share the same type by casting -0.5 with d.Decimal() as follows:

self.MarketOrder("BTCUSD", -d.Decimal(.5) * d.Decimal(self.Portfolio["BTCUSD"].Quantity))
0

Yes that was the error I was getting.  I tried casting -.5 with d.Decimal().  The problem however is that, as the documentation indicates, self.MarketOrder() takes integers for quantity.  It would have to take decimal for scaling out to work right.  Here's the excerpt from the documentation.

MarketOrder(Symbol symbol, int quantity, bool asynchronous = false, string tag = "")
0

When using the algorithmic lab, click on the API tab. Then, search for "marketorder". You will end up on the documentation of the self.MarketOrder() method. You will actually see 3 different documentations for the same function: these differ by the type of paramaters they take. You will see that self.MarkerOrder() accepts Int32, Double and Decimal. 

Therefore, I doubt very much the fact that Decimal cannot be used from what we can see in the documentation and from the fact that I also run algorithms on crypto assets with decimal orders. 

If there is indeed an error, could you post the backtest so that we have a look at it?

0

Update Backtest





0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed