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;
Mike G
Alexandre Catarino
Yes, Volume type has been changed accordingly by patch #992.
Ten Piyabut
Alexandre Catarino
Follow the Project at Github: Crypto Currency Support.
Lennart Lopin
Jonathan Andre
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?
Jared Broad
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.
Zhang Dong
Joel Price
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?
Jared Broad
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 =)
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.
Joel Price
Great! Thanks, I'll reach out to them and also check out your GDAX integration.
CryptoKing
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?
CryptoKing
Nevermind someone just posted a basic example here
https://www.quantconnect.com/forum/discussion/2747/crypto-trading-on-quantconnect
Caleb Stought
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.
Benjamin Stirrup
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))
Caleb Stought
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 = "")
Benjamin Stirrup
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?
Glenn Pedley
Can see the three different type of parameters but how to choose Decimal for Equity backtest code?
Varad Kabade
Hi Glenn Pedley,
We can use an integer or a float in the above method ( we do not need to use Decimal since it's the same as float), and the algorithm will round down the quantity to the minimum lot size that is 1 for equity. If we do the following order:
Â
The algorithm will buy 100 quantities of the SPY
Best,
Varad Kabade
Jared Broad
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!