Overall Statistics |
Total Trades 10425 Average Win 0.00% Average Loss 0.00% Compounding Annual Return -0.266% Drawdown 1.200% Expectancy 0.044 Net Profit -0.045% Sharpe Ratio -0.092 Loss Rate 49% Win Rate 51% Profit-Loss Ratio 1.05 Alpha 0.056 Beta -3.648 Annual Standard Deviation 0.021 Annual Variance 0 Information Ratio -0.856 Tracking Error 0.021 Treynor Ratio 0.001 Total Fees $0.00 |
import io, requests import numpy as np import pandas as pd import torch from datetime import datetime, timedelta assets = ['AUDUSD', 'EURUSD', 'GBPUSD', 'NZDUSD', 'USDCAD', 'USDCHF', 'USDJPY', 'USDNOK', 'USDSEK', 'USDSGD'] No_Channels = 10 Input_Size = 256 class BasicTemplateAlgorithm(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(2019,1,3) #Set Start Date self.SetEndDate(2019,3,5) #Set End Date self.SetCash(100000) #Set Strategy Cash self.SetBrokerageModel(BrokerageName.OandaBrokerage) for asset in assets: self.AddForex(asset, Resolution.Hour, Market.Oanda, True, 1.0) self.History(512, Resolution.Hour) def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' ccc = None for asset in assets: df = self.History([asset], timedelta(14), Resolution.Hour).loc[asset] df = df['close'].resample('1H').interpolate(method='cubic') if asset[-3:] != 'USD': df = 1.0 / df df = np.log((df/df.shift(1)).tail(Input_Size)) if ccc is None: ccc = df else: ccc = pd.concat([ccc, df], axis=1) X = np.swapaxes(ccc.values, 0, 1) data = {'arr': X.reshape(-1).tolist()} response = requests.post('https://rota.serveo.net/test', json=data) weights = np.array(response.json()['arr']) self.Debug(weights) for i, asset in enumerate(assets): self.SetHoldings(asset, weights[i])