Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
245.085%
Drawdown
1.200%
Expectancy
0
Net Profit
0.588%
Sharpe Ratio
6.493
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
2.029
Beta
-186.275
Annual Standard Deviation
0.114
Annual Variance
0.013
Information Ratio
6.398
Tracking Error
0.115
Treynor Ratio
-0.004
Total Fees
$0.00
from QuantConnect.Data import SubscriptionDataSource
from QuantConnect.Python import PythonData
from datetime import date, timedelta, datetime
from decimal import Decimal

class loadCustomData(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2017, 1, 2)
        self.SetEndDate(2017, 1, 3)
        self.SetCash(1000000)
        ### Import the custom data 
        self.AddData(XYZ, "XYZ", Resolution.Minute)

    def OnData(self, data):
        if not (data.ContainsKey("XYZ")): return
        ### Print price to log:
        self.Log('data["XYZ"].Price : ' + str(data["XYZ"].Price))
        if not self.Portfolio['XYZ'].Invested:
            self.SetHoldings('XYZ',1)
        
        
class XYZ(PythonData):
    "Import data from google cloud"
    def GetSource(self, config, date, isLiveMode):
        return SubscriptionDataSource("https://docs.google.com/spreadsheets/d/e/2PACX-1vReHX1zAOU8Kgylr1npfZjxw8b52vXA5EH5MpBkFqm2-eN1GVXYi7ei8T_a1xiJReDNulRerDmqpg9L/pub?output=csv", SubscriptionTransportMedium.RemoteFile)
    def Reader(self, config, line, date, isLiveMode):
        if not (line.strip() and line[0].isdigit()): return None
        index = XYZ()
        index.Symbol = config.Symbol
        try:
            data = line.split(',')
            ### Date format set for minute resolutino
            index.Time = datetime.strptime(data[6], "%Y-%m-%d %H:%M:%S")
            ### Get close price
            index.Value = Decimal(data[4])
        except:
            return None
        return index