The resource loading... loading...

Why is the tab not showing?

Author: lzhqlj, Created: 2023-07-02 22:26:16, Updated: 2023-07-03 09:13:33

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)

In the afternoon, the tabs don't show updates, and in the evening, the tabs don't show up.


More

lzhqljThank you.

Help (click on the image to get in touch) ```LogStatus('`' + json.dumps(tab1) + '`')```

Inventors quantify - small dreamsThe code format is: What's going on? The Code What's going on? Note that it is a ` symbol, not a'symbol. Seeing the code below, this just creates a tab, writes the data, and calls the LogStatus function written in the policy's status bar. See the API documentation.