Hi there,
Quantified Strategies proposes some apparently nice set-ups. In this one, TLT is deemed getting value at the end of the month and depreciating at the beginning on the following months. Trading rules are:
* Buy at the close of the seventh last trading day of the month.
* Sell at the close of the last trading day of the month.
* Sell short at the close of the month.
* Cover at the close of the seventh trading day of the month.
Win rate is quite good, however SR is modest. But I hope a nice introduction to bonds strategies. Also if someone has the rationale behind the effect, I'd take it.
Feel free to comment and suggest improvement.
Best regards
SL
Mia Alissi
Looking at the code you provided, it seems to be well-structured and logically sound. However, there are a few missing pieces that need to be addressed:
The
BuyAtSeventhLastTradingDay
function is not defined. You need to define what should happen when this function is called. Typically, this is where you would place your order to buy the bond.Similarly, the
SellAtMonthEnd
,SellShortAtMonthEnd
, andCoverAtSeventhLastTradingDay
functions are also not defined. These functions should contain the logic for selling the bond at the end of the month, selling short at the end of the month, and covering at the seventh last trading day of the month, respectively.The
CheckSeventhLastTradingDay
function is scheduled to run every day, but it checks if the current day is the seventh last trading day of the month or the seventh trading day of the month. If it's neither, the function doesn't do anything. You might want to consider scheduling this function to run only on the specific days it needs to.Here's an example of how you might define the
BuyAtSeventhLastTradingDay
function:This function would set the holdings of the bond to 100% of the portfolio. You would need to do something similar for the other missing functions, depending on the specific trading logic you want to implement.
Remember, this is just a starting point. Depending on your specific strategy and risk tolerance, you might need to adjust the logic and parameters. Always backtest your algorithm with historical data before live trading.
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.
Sebastien M. Laignel
On below orders extracted, TLT is bought at the end of the month, sold the last day and position is reversed.
TimeSymbolPriceQuantityTypeStatusValueTag 2020-01-22T21:00:00ZTLT127.357.400.884790Market On OpenFilled10.061.234.669.836 2020-01-31T21:00:00ZTLT131.300.738.112-790Market On OpenFilled-10.372.758.310.848Liquidated 2020-01-31T21:00:00ZTLT131.300.738.112-783Market On OpenFilled-1.028.084.779.417 2020-02-11T21:00:00ZTLT129.869.618.036783Market On OpenFilled10.168.791.092.219Liquidated 2020-02-19T21:00:00ZTLT132.297.087.532788Market On OpenFilled10.425.010.497.522 2020-02-28T21:00:00ZTLT14.087.436.936-788Market On OpenFilled-11.100.900.305.568LiquidatedMia Alissi
Based on the order logs you provided, it seems like the algorithm is executing the following steps:
Here's a breakdown of the orders:
This aligns with the strategy you described: buying TLT at the end of the month, selling it on the last trading day of the month, and then reversing the position. However, without the actual algorithm code, it's hard to provide a more detailed explanation or suggest improvements. If you have the code, feel free to share it for a more in-depth analysis.
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.
Sebastien M. Laignel
So far so good then
Mia Alissi
I'm glad to hear that you're finding the information helpful, 'Sebastien'. If you have any more questions or need further clarification, feel free to ask. Happy coding!
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.
Sebastien M. Laignel
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!