Overall Statistics
Total Trades
5
Average Win
0.00%
Average Loss
0%
Compounding Annual Return
23.723%
Drawdown
2.100%
Expectancy
0
Net Profit
4.350%
Sharpe Ratio
2.218
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.067
Beta
0.197
Annual Standard Deviation
0.077
Annual Variance
0.006
Information Ratio
-2.402
Tracking Error
0.147
Treynor Ratio
0.865
Total Fees
$0.00
# this is incomplete attempt to conver c# file to python. coarse funciton incomplete.
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")
AddReference("QuantConnect.Indicators")
from System import *
from QuantConnect import *
from System.Linq import *
from QuantConnect.Indicators import *
from QuantConnect.Data.Market import *
from System.Collections.Concurrent import *
from QuantConnect.Data.UniverseSelection import *
from QuantConnect.Indicators.CandlestickPatterns import *
from datetime import timedelta, datetime
import numpy as np
import sys
import decimal




class TestCandlestickAlgorithm ( QCAlgorithm):
    
    def Initialize(self):
        self.SetCash(100000)
        self.SetStartDate(2009,7,1)
        self.SetEndDate(2009,9,11)
        self.SetBrokerageModel(BrokerageName.OandaBrokerage)
        
        self.security= self.AddForex("EURUSD", Resolution.Daily, Market.Oanda)
        #self.security = self.AddEquity("SPY", Resolution.Daily)
        self.symbol = self.security.Symbol
        periods = decimal.Decimal(10)
        self.pattern = self.CandlestickPatterns.Doji(self.symbol)
        self.SetWarmUp(timedelta(days=10))
        

    def OnData(self,slice):
        self.Log("Time: {}" . format(slice.Time) )
        
        if (self.IsWarmingUp): return
        if slice is None:
            self.Log("no slice " )
            return
            
            
        self.Log("slice data is open {} close {} " . format(slice[self.symbol].Open, slice[self.symbol].Close) )
        self.Log("self pattern is {} " . format(self.pattern))

        if self.pattern is None: 
            self.Log("pattern not yet defined. skipping")
            return
            
        if (self.pattern.Current.Value == 1):
            self.Log("Time: {} pattern is 1 going long" . format(slice.Time) )
            self.SetHoldings(self.symbol, 1)
        elif (self.pattern.Current.Value== -1):    
            self.Log("pattern is -1 going short")
            self.SetHoldings(self.symbol, -1);
        else:
            self.Log("no doji recognized skipping")