Back

RenkoConsolidator in F#

Here is F# port of RenkoConsolidator.

This sample shows:
1) Event handling in f-sharp
2) basic structure of QCAlgorithm implementation
3) how to use QuantConnect.Data.Consolidators in f-sharp
4) Magic sprintf function

Update Backtest








Good stuff! I don't have a ton of familiarity with fsharp but its good to see a little variety. Thank you for sharing Casper.

0

But the web-platform seems not work with multiple f# source code; and .fs needs to be compiled in specific order.

0

Thank you for sharing a F# algorithm! Mind if we add this to the LEAN open source project?
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.


no problem ;)

0

@Casper how do I set properties of the security class? I'm trying to write some new multi language documentation and can't seem to figure out the FSharp! I keep getting this error: "This value is not a function and cannot be applied"

type BasicTemplateAlgorithm() =

inherit QCAlgorithm()

let pdt() = new PatternDayTradingMarginModel

//Implement core methods:
override this.Initialize() =
this.SetCash(100000)
this.SetStartDate(2013, 10, 7)
this.SetEndDate(2013, 10, 11)
this.AddEquity("SPY", Resolution.Second) |> ignore
this.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Cash);
//ERROR: This value is not a function and cannot be applied
this.Securities["SPY"].MarginModel <- pdt()
//TradeBars Data Event
member this.OnData(bar:TradeBars) =
if not this.Portfolio.Invested then
this.SetHoldings(this.Symbol("SPY"), 1)
else
()
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.


@Jared

There are two issue on the script.

1) try to use " let pdt = new PatternDayTradingMarginModel()" for instead
2) F# use ".["SPY"]" to access an item on collections; and here is an example:
this.Securities.["SPY"].MarginModel <- pdt

The corrected script has been attached.
0


@Jared F# does not have the indexer [] operator, you should use the Item property:

this.Securities.Item("SPY").MarginModel <- new PatternDayTradingMarginModel()

EDIT: or as @Casper suggested while I was writing:
this.Securities.["SPY"].MarginModel <- new PatternDayTradingMarginModel()
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.


Thanks guys. I'll give you both editor status on the documentation :)
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.


Update Backtest





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.


Loading...

This discussion is closed