我可以使用此代码获取实时股票数据和之前的 500-100 蜡烛图数据,但无法获取 CME_MINI:ESH2021 未延迟的数据。我认为 TradingView 在公共流中延迟了 600 秒。我确实支付了数据费用,并且可以在网络客户端上提取它,但我无法在 python 上获取非延迟数据,因为我不确定如何通过 python 登录 TradingView。如果有人知道我如何修复我的代码以执行我想要的操作,我将非常感谢您的意见或任何建议。
from websocket import create_connection
import json
import random
import string
import re
from datetime import datetime
from time import sleep
def filter_raw_message(text):
try:
found = re.search('"p":(.+?"}"])}', text).group(1)
print(found)
return found
except AttributeError:
print("error")
def generateSession():
stringLength=12
letters = string.ascii_lowercase
random_string= ''.join(random.choice(letters) for i in range(stringLength))
return "qs_" +random_string
def generateChartSession():
stringLength=12
letters = string.ascii_lowercase
random_string= ''.join(random.choice(letters) for i in range(stringLength))
return "cs_" +random_string
def prependHeader(st):
return …Run Code Online (Sandbox Code Playgroud)