Overall Statistics
Total Trades
2
Average Win
0.02%
Average Loss
0%
Compounding Annual Return
-2.885%
Drawdown
21.000%
Expectancy
0
Net Profit
-4.270%
Sharpe Ratio
-0.095
Probabilistic Sharpe Ratio
5.379%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.003
Beta
0.192
Annual Standard Deviation
0.129
Annual Variance
0.017
Information Ratio
0.13
Tracking Error
0.513
Treynor Ratio
-0.064
Total Fees
$43.99
Estimated Strategy Capacity
$77000.00
Lowest Capacity Asset
BTCUSD 2S7
# 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 *

class BinanceUSBrokerageExampleAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 1, 1)
        self.SetCash(100000)
        
        self.SetBrokerageModel(BrokerageName.BinanceUS, AccountType.Cash)
        
        self.symbol = self.AddCrypto("BTCUSD", Resolution.Minute).Symbol
        
        # Set default order properties
        self.DefaultOrderProperties = BinanceOrderProperties()
        self.DefaultOrderProperties.TimeInForce = TimeInForce.GoodTilCanceled
        self.DefaultOrderProperties.PostOnly = False


    def OnData(self, data):
        if self.Portfolio.Invested:
            return
        
        # Place an order with the default order properties 
        self.MarketOrder(self.symbol, 1)
        
        # Place an order with new order properties
        order_properties = BinanceOrderProperties()
        order_properties.TimeInForce = TimeInForce.Day
        order_properties.PostOnly = True
        ticket = self.LimitOrder(self.symbol, -0.5, round(data[self.symbol].Price + 1000, 2), orderProperties = order_properties)
        
        # If we try to call `Update`, an exception is raised
        # ticket.Update()
        
        # Update the order
        ticket.Cancel()
        ticket = self.LimitOrder(self.symbol, -0.5, round(data[self.symbol].Price + 100, 2), orderProperties = order_properties)