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
I am pretty new to this but was hoping to break into the algo trading world. I am looking for a couple of mean reversion algo's written in python. I am looking to start on the EUR/USD, and then branch out from there. I was hoping for a pretty simple algo so that i can use that as a blueprint and expand it once I get more experience. Any help would be appreactiated.
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.
Bill McCabe
119
,
I am having trouble doing these things in python
#finding the current price and making that a live variable #finding the mean and making that a live variable #deciding on the difference needed to pull the triger #finding out how to do a buy Order #finding out how to store the current price as a non-live variable #finding out how to take profit and stop loss #finding out how to do a sell Order
0
Alexandre Catarino
,
We can find the price of a given security anytime in the Securities object:
price = self.Securities["EURUSD"].Price
However, if we are at the OnData event handler, we are receiving that data:
The mean of a price series can be calculated using the SimpleMovingAverage indicator. The SMA helper method creates that indicator and updates it accordingly:
# Initialize
# 30-day simple moving average with daily frequency
self.sma = self.SMA("EURUSD", 30, Resolution.Daily)
# OnData
if price > self.sma.Current.Value:
# Buy order, stop order and take profit order go here
Please checkout a working example below:
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.
Bill McCabe
119
,
Thanks Alexandre! I'll take a look and try to make my own.
0
István Kürtösi
79
,
Hi Alexandre, thank you, I was followin your advice.
Is there a way to get the Bid or Ask price for a currencypair? I see this documentation for Options:
When we access the data in the Slice object we receive in OnData(Slice), we can get the Bid and Ask like this:
// In OnData(Slice)
// QuoteBar object has OHLC Bid and Ask
var quoteBar = data[atmContract.Symbol];
bid = quoteBar.Bid.Close;
ask = quoteBar.Ask.Close;
Alternatively, we can use the Security object in other methods:
var symbol = atmContract.Symbol;
bid = Securities[symbol].BidPrice
ask = Securities[symbol].AskPrice
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.
István Kürtösi
79
,
Hi Alexandre,
thank you for your answer, so I was wrong above, sorry about it.
Also for others, probably it helps, here is an example of applying your code in Python:
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!
You do not have enough QC Credit to send this award, get a QC Credit Pack
here.
Award Sent Successfully
Thank you for giving back to the community.
Processing...
Choose a Credit Pack
Payment Confirmation
QuantConnect Credit (QCC) can be applied to your cloud-invoices or
gifted to others in the community with Community Awards in recognition of their contributions.
Community Awards highlight the awesome work your fellow community members are doing and inspires
high quality algorithm contributions to the community. Select an option below to add
QuantConnect Credit to your account:
$5
500 Credit Points
 
$10
1,000 Credit Points
 
$18
2,000 Credit Points
10% bonus
$45
5,000 Credit Points
10% bonus
03/23XXXX XXXX XXXX 0592
We will charge your default organization credit card on file, click
here to update.