| 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 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total 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
self.AddData(DailyFx,"DFX",Resolution.Minute,DateTimeZone.Utc)
for tickers in self._tickers:
self.AddForex(tickers,Resolution.Minute, Market.Oanda)
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)))