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
Probabilistic 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
2.48
Tracking Error
0.06
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
from clr import AddReference
AddReference("System.Core")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Algorithm")

from System import *
from QuantConnect import *
from QuantConnect.Algorithm import QCAlgorithm
from QuantConnect.Data import SubscriptionDataSource
from QuantConnect.Python import PythonData

from datetime import datetime, timedelta
import json

class ExuberAlgorithm(QCAlgorithm):

    def Initialize(self):

        # parameteres
        self.cash_invested = 20000
        self.use_short = False
        self.lookback = 100
        self.confidence_threshold = 1.4
        self.lag = 7
        self.use_log = True

        # set up
        self.SetStartDate(2021, 5, 1)
        # self.SetEndDate(2010, 1, 1)
        self.SetCash(self.cash_invested)
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)
        self.symbol = self.AddEquity("SPY", Resolution.Hour).Symbol
        self.AddData(Radf, "RADFDATA", Resolution.Hour)
        self.SetBenchmark("SPY")

        # Init
        # self.radf_window = RollingWindow[float](2)

    def OnData(self, data):

        if self.symbol not in data.Bars: return
        
        # self.Log(data["RADFDATA"]) Here is the error!!!!

        
class Radf(PythonData):

    # def __init__(self, symbols="AAPL", date="2021-01-01", window=100, price_lag=1, use_log=1):
    #     # self.algorithm = algorithm
    #     self.symbols = symbols
    #     self.date = date
    #     self.window = window
    #     self.price_lag = price_lag
    #     self.use_log = use_log

    def GetSource(self, config, date, isLive):
        # url = "http://207.154.227.4/alphar/radf_point?"
        # source = url + 'symbols=' + self.symbols + "&date=" + self.date + "&window=" + str(self.window) + "&price_lag=" + str(self.price_lag) + "&use_log=" + ste(self.use_log)
        # self.algorithm.Log(source)
        # source = "https://www.dropbox.com/s/8v6z949n25hyk9o/custom_weather_data.csv?dl=1"
        source = "http://207.154.227.4/alphar/radf_point?symbols=AAPL&date=2021-01-01&window=100&price_lag=1&use_log=1"
        return SubscriptionDataSource(source, SubscriptionTransportMedium.Rest)


    def Reader(self, config, line, date, isLive):
        index = Radf()
        index.Symbol = config.Symbol
        
        # if not isLive:
            
            # If first character is not digit, pass
        # radf.json = line
            # self.algorithm.Log(f"Line {line}")
            # self.algorithm.Log(f"Date {date}")
            # self.algorithm.Log(f"Line json {liveRadf}")
    
            # # If value is zero, return None
            # value = liveBTC["last"]
            # if value == 0: return None
        index.Value = 0


        return index

# http://207.154.227.4/alphar/radf_point?symbols=AAPL&date=2021-01-01&window=100&price_lag=1&use_log=1