0
关注
0
关注者

求教为什么 tab不显示呢?

创建于: 2023-07-02 22:26:16, 更新于: 2023-07-03 09:13:33
comments   3
hits   465
import json
import pandas as pd
def main():


while True:
       # tab1['rows'].clear()
        tab1 = {
        "type": "table", 
        "title": "主账户", 
        "cols": ["货币对", "方向","持仓均价","持仓数量","冻结保证金","盈亏状态"], 
        "rows": []
        }
        tab2 = {
            "type": "table", 
        "title": "附属账户", 
        "cols":  ["货币对", "方向","持仓均价","持仓数量","冻结保证金","盈亏状态"], 
        "rows": []
        }
      

        data = exchanges[0].IO("api", "GET", "/fapi/v2/account")
        # 筛选出有持仓的数据
        positions_with_holdings = [position for position in data['positions'] if float(position['positionAmt']) != 0]
        df = pd.DataFrame(positions_with_holdings)    
        for i in range(len(df)):
            Log(df.loc[i, 'symbol'],df.loc[i, 'positionSide'],df.loc[i, 'entryPrice'],df.loc[i, 'positionAmt'],
            df.loc[i, 'initialMargin'],df.loc[i, 'unrealizedProfit'])
            tab1["rows"].append([df.loc[i, 'symbol'],df.loc[i, 'positionSide'],df.loc[i, 'entryPrice'],df.loc[i, 'positionAmt'],
            df.loc[i, 'initialMargin'],df.loc[i, 'unrealizedProfit']])
    
        data_2 = exchanges[1].IO("api", "GET", "/fapi/v2/account")
        # 筛选出附属账户有持仓的数据
        positions_with_holdings_2 = [position for position in data_2['positions'] if float(position['positionAmt']) != 0]
        df_2 = pd.DataFrame(positions_with_holdings_2)  
        #tab2['rows'].clear()
        for i in range(len(df_2)):
                tab2["rows"].append([df_2.loc[i, 'symbol'],df_2.loc[i, 'positionSide'],df_2.loc[i, 'entryPrice'],df_2.loc[i, 'positionAmt'],
                df_2.loc[i, 'initialMargin'],df_2.loc[i, 'unrealizedProfit']])
        Sleep(2000)

下午的时候是显示tab不更新数据,到晚上突然不显示表格了,奇怪啊

更多内容
全部留言
avatar of lzhqlj
lzhqlj
谢谢哈
2023-07-04 15:01:00
avatar of 提供帮助(点击头像可联系)
提供帮助(点击头像可联系)
```LogStatus('`' + json.dumps(tab1) + '`')```
2023-07-03 15:34:25
avatar of 发明者量化-小小梦
发明者量化-小小梦
贴代码格式为: \`\`\` 代码 \`\`\` 注意是`符号,不是'符号。 看了下代码,这个只是创建了一个tab ,写了数据,还需要调用LogStatus 函数写在策略的状态栏,具体可以参看API文档。
2023-07-03 09:15:58