| Overall Statistics |
|
Total Trades
48
Average Win
0.81%
Average Loss
-1.08%
Compounding Annual Return
0.043%
Drawdown
8.600%
Expectancy
0.022
Net Profit
0.333%
Sharpe Ratio
0.029
Probabilistic Sharpe Ratio
0.312%
Loss Rate
42%
Win Rate
58%
Profit-Loss Ratio
0.75
Alpha
0
Beta
0.003
Annual Standard Deviation
0.024
Annual Variance
0.001
Information Ratio
-1.036
Tracking Error
0.129
Treynor Ratio
0.236
Total Fees
$247.45
|
# https://quantpedia.com/strategies/us-holiday-effect-in-eu-markets/
#
# Buy DAX index (via ETF, CFD, fund or futures) at European close one day before each US holiday day. Sell on European close during US holiday day. Hold cash otherwise.
import numpy as np
import fk_tools
class US_Holiday_EU_Markets(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2012, 1, 1)
self.SetEndDate(2019, 10, 1)
self.SetCash(100000)
data = self.AddData(fk_tools.QuandlFutures, "CHRIS/EUREX_FESX1", Resolution.Daily)
data.SetFeeModel(fk_tools.CustomFeeModel(self))
self.symbol = data.Symbol
def OnData(self, data):
calendar1 = self.TradingCalendar.GetDaysByType(TradingDayType.PublicHoliday, self.Time, self.Time)
calendar2 = self.TradingCalendar.GetDaysByType(TradingDayType.Weekend, self.Time, self.Time + timedelta(days=2))
holidays = [i.Date for i in calendar1]
weekends = [i.Date for i in calendar2]
# subtract weekends in all holidays
public_holidays = list(set(holidays) - set(weekends))
if not self.Portfolio.Invested and len(public_holidays) > 0:
self.SetHoldings(self.symbol, 1)
if self.Portfolio.Invested and len(public_holidays) == 0:
self.Liquidate()
# Quandl free data
class QuandlFutures(PythonQuandl):
def __init__(self):
self.ValueColumnName = "settle"
import numpy as np
def Return(values):
return (values[-1] - values[0]) / values[0]
def Volatility(values):
values = np.array(values)
returns = (values[1:] - values[:-1]) / values[:-1]
return np.std(returns)
# Custom fee model
class CustomFeeModel(FeeModel):
def GetOrderFee(self, parameters):
fee = parameters.Security.Price * parameters.Order.AbsoluteQuantity * 0.00005
return OrderFee(CashAmount(fee, "USD"))
# Quandl free data
class QuandlFutures(PythonQuandl):
def __init__(self):
self.ValueColumnName = "settle"
# Quantpedia data
# NOTE: IMPORTANT: Data order must be ascending (datewise)
class QuantpediaFutures(PythonData):
def GetSource(self, config, date, isLiveMode):
return SubscriptionDataSource("data.quantpedia.com/backtesting_data/futures/{0}.csv".format(config.Symbol.Value), SubscriptionTransportMedium.RemoteFile, FileFormat.Csv)
def Reader(self, config, line, date, isLiveMode):
data = QuantpediaFutures()
data.Symbol = config.Symbol
if not line[0].isdigit(): return None
split = line.split(';')
data.Time = datetime.strptime(split[0], "%d.%m.%Y") + timedelta(days=1)
data['settle'] = float(split[1])
data.Value = float(split[1])
return data