Firetron’s ReportMaxRiskPoint

1 75 Views No Comments 4 weeks ago
  • Adds a custom report on your worst point of liquidation risk.

    Custom Command Dependencies:
    Firetron’s FormatRoundedQuoteCurrency

    • This topic was modified 3 weeks, 5 days ago by Team HaasScripts.
    • This topic was modified 3 days, 6 hours ago by Firetron. Reason: Added hyperlink to command
    HaasScript Code
    --  ==========================================================================================================
    --    Firetron's ReportMaxRiskPoint
    --
    --    Adds a custom report on your worst point of liquidation risk.
    --
    --    Custom Command Dependencies:
    --    Firetron’s FormatRoundedQuoteCurrency
    --
    --    Discord:  @FiretronP75
    --    BTC Tips: 14WLDZsrhshcP6qvBarKW8ABACv3iUXEro
    --    ETH Tips: 0xfaaac99fbf11f8f4abc4b3bf079cb2c7a43b5f87
    --  ==========================================================================================================
    
    --  ==============
    --    Definition
    --  ==============
    
    DefineCommand('ReportMaxRiskPoint', 'Adds a custom report on your worst point of liquidation risk.')
    
    --  =========
    --    Logic
    --  =========
    
    local positionList = GetAllOpenPositions()
    
    if Count(positionList) > 0 then
    
      local nowRiskPointAmount = 0
    
      for i = 1, #positionList do
    
        local positionContainer = positionList[i]
    
        nowRiskPointAmount = nowRiskPointAmount + positionContainer.profit
    
      end
    
      local maxRiskPointAmount = Load('maxRiskPointAmount', 0)
    
      if nowRiskPointAmount < maxRiskPointAmount then
    
        maxRiskPointAmount = nowRiskPointAmount
    
        Save('maxRiskPointAmount', maxRiskPointAmount)
    
      end
    
    end
    
    --  ============
    --    Finalize
    --  ============
    
    Finalize(function()
    
      local maxRiskPointAmount = Load('maxRiskPointAmount', 0)
    
      local group = 'Max Risk Point Report'
      local name  = 'Max Risk Point Amount'
      local value = CC_FormatRoundedQuoteCurrency(maxRiskPointAmount)
    
      CustomReport(name, value, group)
    
    end)
    
    --  ==========
    --    Output
    --  ==========
    
    DefineOutput(VoidType)
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free