title: Design a JSON structure to create a display
body: <p>I'm requesting for help in creating a JSON structure that will help in creating a display in Command Prompt using python. I have a draft JSON structure that is given below. I can change the below structure to best suit the display.</p>
  <p>Plan is to use <code>{}.format()</code> to create the display.</p>
  <pre><code>[
      {
          &quot;Acc1&quot;: [
              {
                  &quot;clientId&quot;: &quot;Acc1&quot;,
                  &quot;Strategy&quot;: &quot;MONTHLY_IRON_CONDOR&quot;,
                  &quot;StrategyList&quot;: [
                      &quot;MONTHLY_IRON_CONDOR&quot;,
                      &quot;MONTHLY_IRON_CONDOR&quot;,
                      &quot;MANUAL&quot;
                  ],
                  &quot;strikeType&quot;: &quot;PE&quot;,
                  &quot;CurrentM2M&quot;: 1850.0,
                  &quot;MaxStopLoss&quot;: 24195.0,
                  &quot;MaxProfit&quot;: 8065.0
              },
              {
                  &quot;clientId&quot;: &quot;Acc1&quot;,
                  &quot;Strategy&quot;: &quot;MONTHLY_IRON_CONDOR&quot;,
                  &quot;StrategyList&quot;: [
                      &quot;MONTHLY_IRON_CONDOR&quot;,
                      &quot;MONTHLY_IRON_CONDOR&quot;,
                      &quot;MANUAL&quot;
                  ],
                  &quot;strikeType&quot;: &quot;CE&quot;,
                  &quot;CurrentM2M&quot;: -8075.0,
                  &quot;MaxStopLoss&quot;: 36060.0,
                  &quot;MaxProfit&quot;: 12020.0
              }
          ]
      },
      {
          &quot;Acc2&quot;: [
              {
                  &quot;clientId&quot;: &quot;Acc2&quot;,
                  &quot;Strategy&quot;: &quot;LONGTERM_STRANGLE&quot;,
                  &quot;StrategyList&quot;: [
                      &quot;LONGTERM_STRANGLE&quot;,
                      &quot;LONGTERM_STRANGLE&quot;
                  ],
                  &quot;strikeType&quot;: &quot;PE&quot;,
                  &quot;CurrentM2M&quot;: 405.0,
                  &quot;MaxStopLoss&quot;: 21735.0,
                  &quot;MaxProfit&quot;: 7245.0
              },
              {
                  &quot;clientId&quot;: &quot;Acc2&quot;,
                  &quot;Strategy&quot;: &quot;LONGTERM_STRANGLE&quot;,
                  &quot;StrategyList&quot;: [
                      &quot;LONGTERM_STRANGLE&quot;,
                      &quot;LONGTERM_STRANGLE&quot;
                  ],
                  &quot;strikeType&quot;: &quot;CE&quot;,
                  &quot;CurrentM2M&quot;: -3105.0,
                  &quot;MaxStopLoss&quot;: 36015.0,
                  &quot;MaxProfit&quot;: 12005.0
              }
          ]
      }
  ]
  </code></pre>
  <p>Output Structure:</p>
  <pre><code>     Strategies                            Acc1                           Acc2
                                     P&amp;L  |   SL   |   MaxPL        P&amp;L  |   SL   |   MaxPL
  MONTHLY_IRON_CONDOR ----&gt;    PE   1850.0  24195.0  8065.0
                               CE   -8075.0  36060.0  12020.0
  
  LONGTERM_STRANGLE ------&gt;                                     PE   405.0  21735.0  7245.0
                                                                CE   -3105.0  36015.0  12005.0
  </code></pre>
  <p>I've already tried the extract the data best out of the above JSON using the python code given below;</p>
  <pre><code>import json
  import os
  import random
  import sys
  import time
  
  import pandas as pd
  
  home = os.path.dirname(os.path.dirname(
      os.path.dirname(os.path.realpath(__file__))))
  sys.path.append(home)
  
  home = os.path.dirname(os.path.dirname(
      os.path.dirname(os.path.realpath(__file__))))
  tmp_path = str(os.path.join(home, &quot;tmp&quot;))
  
  # Set base path:--------------------------------------------------------
  sys.path.append(home)
  os.chdir(home)
  
  
  def clear_screen():
      os.system('cls' if os.name == 'nt' else 'clear')
  
  
  a = 0
  while True:
      clear_screen()
  
      positionsList = None
  
      if (os.path.isfile(os.path.join(tmp_path, &quot;input&quot;))):
          with open(os.path.join(tmp_path, &quot;input&quot;), &quot;r&quot;) as f:
              positionsList = json.loads(f.read(), strict=False)
  
      clientIdList = []
  
      headerClientId = &quot;       Strategies                          &quot; # This variable will hold the top Header line that will contain dynamic 
                                                                     # number of Accounts
      headerNames = &quot;                                   &quot;            # This variable will hold the text &quot;P&amp;L  |   SL   |   MaxPL&quot; for all 
                                                                       the accounts
      monthlyIC = &quot; &quot;                                                # Strategy Specific data for MONTHLY_IRON_CONDOR
      longtermStrangle = &quot; &quot;                                         # Strategy Specific data for LONGTERM_STRANGLE
      noData = &quot;                               &quot;                     # Filler when there is no data for a specific strategy for a given 
                                                                       account
  
      for client in positionsList:
          values = list(client.values())[0]
          flg = False
          for value in values:
              for clientId in client.keys():
                  if flg == False:
                      clientIdList.append(clientId)
                      headerClientId = headerClientId + &quot;{}                         &quot;
                      headerNames = headerNames + &quot;P&amp;L  |   SL   |   MaxPL        &quot;
                      flg = True
  
                  availableStrategies = [&quot;MONTHLY_IRON_CONDOR&quot;,'INTRADAY_STRANGLE&quot;, &quot;LONGTERM_STRANGLE&quot;, &quot;PUT_SPREAD&quot;]
  
                  unusedStrategies = list(
                      set(availableStrategies) - set(value['StrategyList']))      # Helps to fill &quot;noData&quot; for these strategies for each 
                                                                                  # Account
  
                  if Strategy.monthlyIronCondor.value in unusedStrategies and &quot;\n&quot; not in monthlyIC:
                      monthlyIC = monthlyIC + noData
                  elif Strategy.longTermStrangle.value in unusedStrategies and &quot;\n&quot; not in longtermStrangle:
                      longtermStrangle = longtermStrangle + noData
  
                  if value['Strategy'] == Strategy.monthlyIronCondor.value:
                      monthlyIC = monthlyIC + &quot;&quot; + str(value['strikeType']) + &quot;   &quot; + str(value['CurrentM2M']) + \
                          &quot;  &quot; + str(value['MaxStopLoss']) + \
                          &quot;  &quot; + str(value['MaxProfit'])
                  if value['Strategy'] == Strategy.longTermStrangle.value:
                      longtermStrangle = longtermStrangle + &quot;&quot; + str(value['strikeType']) + &quot;   &quot; + str(value['CurrentM2M']) + \
                          &quot;  &quot; + str(value['MaxStopLoss']) + \
                          &quot;  &quot; + str(value['MaxProfit'])
                  if monthlyIC.replace(' ', '', -1) != '':
                      monthlyIC = monthlyIC + &quot;\n                             &quot;
                  if longtermStrangle.replace(' ', '', -1) != '':
                      longtermStrangle = longtermStrangle + &quot;\n                             &quot;
                  # if longtermStrangle.replace(' ', '', -1) == '':
                  #    longtermStrangle = longtermStrangle + noData
  
      headerClientId = headerClientId.format(clientIdList[0], clientIdList[1])
      print(headerClientId, end='\n\r')
      print(headerNames, end='\n\r')
  
      print(&quot;MONTHLY_IRON_CONDOR ----&gt;   &quot; + monthlyIC, end='\n\r')
      print(&quot;LONGTERM_STRANGLE ------&gt;   &quot; + longtermStrangle, end='\n\r')
  
      time.sleep(1)
      a += 1
  </code></pre>