Overall Statistics Total Trades0Average Win0%Average Loss0%Compounding Annual Return0%Drawdown0%Expectancy0Net Profit0%Sharpe Ratio0Loss Rate0%Win Rate0%Profit-Loss Ratio0Alpha0Beta0Annual Standard Deviation0Annual Variance0Information Ratio0Tracking Error0Treynor Ratio0Total Fees\$0.00
import numpy as np
import gc
from NodaTime import DateTimeZone
import math
import decimal as d
from datetime import datetime, timedelta

### <summary>
### Basic template algorithm simply initializes the date range and cash. This is a skeleton
### framework you can use for designing an algorithm.
### </summary>
class FxDailyalgo(QCAlgorithm):
'''Basic template algorithm simply initializes the date range and cash'''
def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

self.SetStartDate(2016,1, 1)  #Set Start Date
self.SetEndDate(2017,3,30)    #Set End Date
self.SetCash(100000)           #Set Strategy Cash
# Find more symbols here: http://quantconnect.com/data
self._tickers = ["EURUSD", "USDJPY", "USDCHF", "GBPUSD",  "USDCAD", "AUDUSD"]
#FxRiskManagment RiskManager;
self.Vol=dict()
self.signal=0

for tickers in self._tickers:
self.Vol[tickers]=self.STD(tickers, 24, Resolution.Hour)
self.SetBrokerageModel(BrokerageName.OandaBrokerage)

def OnData(self,DailyFx):
if not DailyFx.ContainsKey("DFX"): return
calendar=DailyFx['DFX']
#self.Debug("ondata")
#   // We only want to trade the news of all others currencies against USD.
if calendar.Currency.upper() == "USD" :  return
#    // The algorithm only uses meaningful and important news/announcements.
if calendar.Importance == FxDailyImportance.High and calendar.Meaning is not None:

for symbol in self._tickers:

fxPair = self.Securities[symbol]
#self.Debug(str(fxPair))
#self.Debug(str(self.Portfolio.Securities[symbol].Price))
# Check if the new/announcement affects the Base or the Quote of the actual pair.
isBaseCurrency = True if fxPair.BaseCurrencySymbol == calendar.Currency.upper() else False
isQuoteCurrency = True if fxPair.QuoteCurrency.Symbol == calendar.Currency.upper() else False

quantity = 0
stopLossPrice = d.Decimal(0)
longA=True if calendar.Meaning == FxDailyMeaning.Better and isBaseCurrency else False
longB=True if calendar.Meaning == FxDailyMeaning.Worse and isQuoteCurrency else False
shortA=True if calendar.Meaning == FxDailyMeaning.Worse and isBaseCurrency else False
shortB=True if calendar.Meaning == FxDailyMeaning.Better and isQuoteCurrency else False

if longA or longB:
self.signal+=1
date=self.Time
self.Log(str(self.signal)+ "\n" + str(date) + "\n" + str(symbol) + "\n" + str(calendar.Meaning))
self.Log(str(round(self.Vol[symbol].Current.Value,5)))

if shortA or shortB:
self.signal+=1
date=self.Time
self.Log(str(self.signal)+ "\n" + str(date) + "\n" + str(symbol) + "\n" + str(calendar.Meaning))
self.Log(str(round(self.Vol[symbol].Current.Value,5)))