Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-0.579%
Drawdown
0.800%
Expectancy
0
Net Profit
-0.124%
Sharpe Ratio
-0.209
Probabilistic Sharpe Ratio
27.263%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.003
Beta
-0.006
Annual Standard Deviation
0.022
Annual Variance
0
Information Ratio
-1.383
Tracking Error
0.15
Treynor Ratio
0.76
Total Fees
$0.00
Estimated Strategy Capacity
$0
from datetime import date, timedelta, datetime
import numpy as np
import json

from QuantConnect.Data import SubscriptionDataSource
from QuantConnect.Python import PythonData

class CalculatingGreenGiraffe(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 1, 1)  # Set Start Date
        self.SetEndDate(2021, 3, 21)
        self.SetCash(10000000)  # Set Strategy Cash
        
        self.testSymbol = self.AddData(Fbsox, "D_FBSOX", Resolution.Daily).Symbol

    def OnData(self, data):
        if not data.ContainsKey("D_FBSOX"): return
    
        bar = data['D_FBSOX']
    
        if not self.Portfolio.Invested:
            self.MarketOrder(self.testSymbol, 1)
            #self.SetHoldings(self.testSymbol, 1)
            #self.Debug('Buy')
        
class Fbsox(PythonData):
    
    def GetSource(self, config, date, isLiveMode):
        return SubscriptionDataSource("https://www.dropbox.com/s/4s1gy1n9ziwdprn/fbsox.csv?dl=1", SubscriptionTransportMedium.RemoteFile);

    def Reader(self, config, line, date, isLiveMode):
        if not (line.strip() and line[0].isdigit()): return None
        
        symbolIndex = Fbsox()
        symbolIndex.Symbol = config.Symbol

        try:
            data = line.split(',')
    
            value = data[4]
            if value == 0: return None
    
            symbolIndex.Time = datetime.strptime(data[0][0:8], "%Y%m%d")
            symbolIndex.EndTime = symbolIndex.Time + timedelta(days=1)
            symbolIndex.Value = value
            symbolIndex["Open"] = float(data[1])
            symbolIndex["High"] = float(data[2])
            symbolIndex["Low"] = float(data[3])
            symbolIndex["Close"] = float(data[4])

        except ValueError:
            return None
            
        return symbolIndex