Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
-0.639%
Drawdown
12.500%
Expectancy
0
Net Profit
-2.044%
Sharpe Ratio
-0.113
Probabilistic Sharpe Ratio
0.816%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.009
Beta
0.009
Annual Standard Deviation
0.034
Annual Variance
0.001
Information Ratio
-1.025
Tracking Error
0.597
Treynor Ratio
-0.438
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
Portfolio Turnover
0%
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from AlgorithmImports import *

### <summary>
### The demonstration algorithm shows some of the most common order methods when working with Crypto assets.
### </summary>
### <meta name="tag" content="using data" />
### <meta name="tag" content="using quantconnect" />
### <meta name="tag" content="trading and orders" />
class BasicTemplateCryptoAlgorithm(QCAlgorithm):

    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.last_not_empty_history = pd.DataFrame()

        self.empty_volume_counter = 0
        self.empty_history_counter = 0

        self.SetStartDate(2020, 1, 1)  #Set Start Date
        self.SetEndDate(2023, 3, 21)    #Set End Date

        # Although typically real brokerages as GDAX only support a single account currency,
        # here we add both USD and EUR to demonstrate how to handle non-USD account currencies.
        # Set Strategy Cash (USD)
        self.SetCash(100000000)

        # Set Strategy Cash (EUR)
        # EUR/USD conversion rate will be updated dynamically
        self.SetCash("EUR", 100000000)

        # Add some coins as initial holdings
        # When connected to a real brokerage, the amount specified in SetCash
        # will be replaced with the amount in your actual account.

        self.SetBrokerageModel(BrokerageName.Bitfinex, AccountType.Margin)

        # Find more symbols here: http://quantconnect.com/data
        self.AddCrypto("BTCUSD", Resolution.Hour)
        self.symbol = self.AddCrypto("BTCUSD", Resolution.Hour).Symbol

        # create two moving averages
        self.fast = self.EMA(self.symbol, 20, Resolution.Daily)
        self.slow = self.EMA(self.symbol, 50, Resolution.Daily)

    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
        '''

        self.his = self.History(["BTCUSD"],1)

        if(self.his.empty):
            self.empty_history_counter = self.empty_history_counter + 1
        else:
            self.last_not_empty_history = self.his

        if('volume' not in self.his):
            self.empty_volume_counter = self.empty_volume_counter + 1


    def OnOrderEvent(self, orderEvent):
        self.Debug("{} {}".format(self.Time, orderEvent.ToString()))

    def OnEndOfAlgorithm(self):
        self.Debug("Empty Volume Counter at end of algorithm:")
        self.Debug(self.empty_volume_counter)
        self.Debug("Empty History Counter at end of algorithm:")
        self.Debug(self.empty_history_counter)
        self.Debug("Last history:")
        self.Debug(self.last_not_empty_history)

        self.Log("Empty Volume Counter at end of algorithm:")
        self.Log(self.empty_volume_counter)
        self.Log("Empty History Counter at end of algorithm:")
        self.Log(self.empty_history_counter)
        self.Log("Last history:")
        self.Log(self.last_not_empty_history)
        pass