Overall Statistics
Total Trades
11060
Average Win
0.00%
Average Loss
0.00%
Compounding Annual Return
-1.421%
Drawdown
1.400%
Expectancy
0.023
Net Profit
-0.253%
Sharpe Ratio
-0.523
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
1.06
Alpha
0.036
Beta
-3.023
Annual Standard Deviation
0.021
Annual Variance
0
Information Ratio
-1.259
Tracking Error
0.021
Treynor Ratio
0.004
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,8)    #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):
            howmuch = weights[i] if asset[-3:] == 'USD' else (-1.0*weights[i])
            self.SetHoldings(asset, weights[i])