| Overall Statistics |
|
Total Orders 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Start Equity 100000 End Equity 100000 Net Profit 0% Sharpe Ratio 0 Sortino Ratio 0 Probabilistic 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.251 Tracking Error 0.128 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% |
from base64 import b64encode
from hashlib import sha256
from time import time
from requests import post
# Request your API token on https://www.quantconnect.com/settings/ and replace the below values.
USER_ID = 325196
API_TOKEN = '2d79242ba9d70243c264f166a951a33e5dca1ca83283a5bc870092fee2c9f6f6'
def get_headers():
# Get timestamp
timestamp = f'{int(time())}'
time_stamped_token = f'{API_TOKEN}:{timestamp}'.encode('utf-8')
# Get hased API token
hashed_token = sha256(time_stamped_token).hexdigest()
authentication = f'{USER_ID}:{hashed_token}'.encode('utf-8')
authentication = b64encode(authentication).decode('ascii')
print(authentication)
print(timestamp)
# Create headers dictionary.
return {
'Authorization': f'Basic {authentication}',
'Timestamp': timestamp
}
BASE_URL = 'https://www.quantconnect.com/api/v2/'
response = post(f'{BASE_URL}/<request_url>',
headers = get_headers(),
data = {},
json = {}) # Some request requires json param (must remove the data param in this case)
content = response.text
# region imports
from AlgorithmImports import *
from datetime import timedelta
from param import Param
# endregion
# lean cloud backtest "TEST01" --push --open
class TEST01(QCAlgorithm):
def initialize(self) -> None:
# Set backtest period
self.set_start_date(2025, 5, 1)
self.set_cash(100000)
self._ticker = self.add_equity(Param.TICKER, Resolution.HOUR).symbol
def on_data(self, data: Slice) -> None:
if data[self._ticker] is not None:
self.log(f"Price: {data[self._ticker].close}")
from AlgorithmImports import *
class Param:
TICKER = "VOO"