LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
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.
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.
Joyanta
2.1k Pro
,
using System;
using System.Collections;
using System.Collections.Generic;
namespace QuantConnect
{
using QuantConnect.Securities;
using QuantConnect.Models;
public partial class DollarCostAverageAlgorithm : QCAlgorithm, IAlgorithm
{
private int Quantity(decimal price)
{
int quantity = (int) (monthlyDollarValue / price);
return quantity;
}
public override void OnTradeBar(Dictionary securityData)
{
try
{
//trade in the on a midday
if (Time.Date >= nextTradeDate.Date && Time.Hour >= 12)
{
// finally we will make our investment. Ho Ho HO Ho father christmas has arrived early.
int quantity = Quantity(securityData[etf].Price);
Order(etf, quantity); //symbol, quantity
nextTradeDate = nextTradeDate.AddMonths(1);
}
return;
}
catch (Exception err)
{
Error("This is an error handler." + err.Message);
}
}
}
}
0
Joyanta
2.1k Pro
,
Hi,
This is my code base. Dollar cost being 1000 Dollar per month say at 15th each month or soon after that.
I get result fine for a small simulation day 4 months (simulation id: b1e60c72-3d4e-48db-a9dd-948dba8d084b). I have checked the trades, they seem to be fine.
Anything longer simulation time seems not be working. The simulation ids are as follows:
c1747beb-2f47-4de5-9e03-6d45b57a7b34
ae50851a-a685-4a04-beeb-39466b8f661d
097beabe-1652-49dc-a972-1a966c7cc985
0
Joyanta
2.1k Pro
,
Yeah I am taking slices of time. Any simulation that deals with data more than 6 months seem not to work, at least for this dollar coast average that I have listed above.
Please feel free to copy/paste it and have a play with different start and end dates.
Joyanta
0
Jared Broad
Pro
,
Good catch, thank you. We pushed out code a little too fast last night and missed a bug ;) We'll patch this today -
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.
Joyanta
2.1k Pro
,
cool cheers.
0
Jared Broad
Pro
,
Cool done --> 1. Fixed the series bug. It was from the new dynamic scatter plotting, again only visual no backtests affected. 2. Fixed the bug restricting data from July 31st -> December 31st. Gustavo is finishing the charting tonight.
Now will add the daily update server so data is always current until yesterday...
Series analysis take too long I think so perhaps we'll work on some optimization there as well. At least now you'll get dynamic beautiful charts while the results stream in.
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.
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...
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!