Hi,
I 'm implementing the 24hour volume of a Altcoin/BTC pair.
I want to make a history request and a warm-up feature.
I made a rolling window for 1440 minutes = 24hour to insert the volume data.
private RollingWindow<decimal> _window = new(1440);
var history = History<TradeBar>(symbol, 1440, Resolution.Minute); //1440 minutes in 1 day.
foreach (var bar in history)
{
_window.Add(bar.Volume);
}
// volume is only available in trade bar
if (data.Bars.ContainsKey(symbol))
{
_window.Add(data.Bars[symbol].Volume);
}
Buying part condition:
//BUYING PART!!
if (!invested _window.Sum() > _VolumeMinimum)
I'm confused and dont know how to implement a history request and a warm-up featur.
Thanks in advance.
Louis Szeto
Hi Vronghel
The code seems fine to me. The way you call for historical data and iterate them to add to the RollingWindow is correct. Make sure you do so on initialize, or OnSecurityChanged event handler, so it was only called once when the security is added into the universe. Then update the RollingWindow with newly received data in OnData. Check here on how to do so.
Best
Louis
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.
Vronghel
Hi Louis,
Thanks for your response!!
I implemented the volume in my algorithm something different as above. And this works perfect.
But the problem for the moment is that I get the 24hours volume of an altcoin in the value of the altcoin. (see image above)
I get the 24h Volume(ZRX) but not the 24h dollar volume.
Whats the best way to transform the 24h volume(ZRX) to 24h volume(usd)?
Thanks in advance!!!
Derek Melchin
Hi Vronghel,
volume(USD) = volume(ZRX) * price(ZRX/USD)
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
Vronghel
Hi Derek,
Thanks for your respons!!!
I got a lot of altcoins to trade. Do I need to do this all manually for every altcoin? This would be absurd.
Or is there a easier way? Reading in the dictionary or something?
Thanks in advance!!!
Derek Melchin
Hi Vronghel,
An easy way is to use
See the attached backtest for a full example.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Check out our Wefunder campaign to join the revolution.
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.
Vronghel
Hi Derek,
Thanks for the answer.
I think its clear to me.
But the only problem is that your BaseCurrencySymbol is “USD” but mine BaseCurrencySymbol is “BTC”. Cause I'm trading BTC pairs and I wanna see my BTC balance instead of USD balance.
How can I get this “var baseCurrency = (Securities[symbol] as Crypto).BaseCurrencySymbol;” work while having a BaseCurrencySymbol of “BTC”? Do I need to transform it to USD?
Also your resolution is Daily while mine is Minute.
Do I have to consolidate all the data.bars[_symbol].Volume?
Thanks in advance.
Derek Melchin
Hi Vronghel,
In the algorithm above, the baseCurrency is actually ETH and the quote currency is BTC.
The algorithm will calculate the trading volume, denominated in the account currency. If you set your account currency to BTC, volumeInAccountCurrency will be denominated in BTC.
If we use minute-resolution data, to get the daily volume, we can consolidate the bars or just sum up the volume of the minute bars each day.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
Vronghel
Hi Derek,
Thanks for all your help.
I made this for my code:
Greetings David
Vronghel
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!