Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
namespace QuantConnect.Algorithm.Data.Custom open System open System.Net open System.Diagnostics open QuantConnect open QuantConnect.Data open QuantConnect.Data.Market type YFinance() = inherit BaseData() member val Open = 0m with get,set member val High = 0m with get,set member val Low = 0m with get,set member val Close = 0m with get,set member val AdjClose = 0m with get,set member val Volume = 0 |> int64 with get,set override this.GetSource(config: SubscriptionDataConfig, date:DateTime, isLiveMode:bool) = //Trace.WriteLine <| sprintf "%O" date this.Symbol <- config.Symbol let fromDate = sprintf "&a=%i&b=%i&c=%i" (date.Month - 1) date.Day date.Year let toDate = sprintf "&d=%i&e=%i&f=%i" (date.Month - 1) date.Day date.Year let url = sprintf "http://real-chart.finance.yahoo.com/table.csv?s=%s%s%s&ignore=.csv&g=d" config.Symbol.Value fromDate toDate //Trace.WriteLine <| sprintf "%s" url new SubscriptionDataSource(url, SubscriptionTransportMedium.RemoteFile) override this.Reader(config:SubscriptionDataConfig, line:string, date:DateTime, isLiveMode:bool) = let retval = try let data = line.Split(',') new YFinance( Time = DateTime.ParseExact(data.[0],"yyyy-MM-dd",null), Open = Convert.ToDecimal(data.[1]), High = Convert.ToDecimal(data.[2]), Low = Convert.ToDecimal(data.[3]), Close = Convert.ToDecimal(data.[4]), Volume = Convert.ToInt64(data.[5]), AdjClose = Convert.ToDecimal(data.[6]), Value = Convert.ToDecimal(data.[4]) ) with | ex -> new YFinance() //f# not smart enough to get base-class type //" does not have the correct type to override any given virtual method" error throw if not cast to BaseData type retval :> BaseData ///////////////////////////////////////////////////// open QuantConnect.Algorithm type FSharpCustomData() = inherit QCAlgorithm() let ticker = "2012.HK" override this.Initialize() = this.SetCash(100000) this.SetStartDate(2014,1,1) this.SetEndDate(2015,1,1) this.AddData<YFinance>(ticker,Resolution.Daily) member this.OnData(data : YFinance) = this.Plot(ticker,"Daily",data.Close)