Hi, 

I am trying to read my live portfolio's log via API but am unable to get it to work.

Have verified that the API call's authentication is working, and tested with getting project's detail which also work. 

For /live/read/log  there is an algorithmId, I have set it in main.py→ Initialize using SetAlgorithmId. Is this the correct way to do it?

def Initialize(self):

        self.SetAlgorithmId("algoId123")
        self.Debug(f"AlgorithmId is {self.AlgorithmId}")

 

Attached my API code below..

#-- authentication
import base64
import hashlib
import time

#-- http call
import requests

#-- json formatting
import json

#-- CONFIGURATION
api_token =  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
base_url = "https://www.quantconnect.com/api/v2"


#-- GET API TOKEN
timestamp = str(int(time.time()))
time_stamped_token = api_token + ':' + timestamp
hashed_token = hashlib.sha256(time_stamped_token.encode('utf-8')).hexdigest()
authentication = "{}:{}".format(user_ID, hashed_token)
api_token = base64.b64encode(authentication.encode('utf-8')).decode('ascii')
# print(f"api_token: {api_token}")

# Create headers dictionary.
headers = {
    'Authorization': 'Basic %s' % api_token,
    'Timestamp': timestamp
}

#-- 1) AUTHENTICATION (successful)
request_url = base_url + "/authenticate"
response = requests.post(request_url, 
                         data = {}, 
                         headers = headers)
content = response.text
print(f"Authentication is {content}")


#-- 2) READ PROJECT  (successful)
request_url = base_url + "/projects/read"
dataDict = {}
dataDict["projectId"] = "13299999"


response = requests.post(request_url, 
                         data = dataDict, 
                         headers = headers)
content = response.json()
pretty_content = json.dumps(content, indent=4)
print(f"project's content is {pretty_content}")


#-- 3) READ LIVE PORTFOLIO  (not working)
request_url = base_url + "/live/read/portfolio"
dataDict = {}
dataDict["projectId"] = "13299999"


response = requests.post(request_url, 
                         data = dataDict, 
                         headers = headers)
content = response.json()
pretty_content = json.dumps(content, indent=4)
print(f"project's live portfolio is {pretty_content}")


#-- 4) READ LIVE LOG (not working)
request_url = base_url + "/live/read/log"
dataDict = {}
dataDict["format"] = "json"
dataDict["projectId"] = "13299999"
dataDict["algorithmId"] = "algoId123"
dataDict["start"] = 0
dataDict["end"] = 99999999999


response = requests.post(request_url, 
                         data = dataDict, 
                         headers = headers)
content = response.json()
pretty_content = json.dumps(content, indent=4)
print(f"project's log is {pretty_content}")