Firetron's ReportMaxRiskPoint
stableDescription
Adds a custom report on your worst point of liquidation risk.
Custom Command Dependencies:
Firetron’s FormatDateTime
Test Script:
if not Load('done', false) then
PlaceGoLongOrder(CurrentPrice(), TradeAmount(), PriceMarket(), MarketOrderType)
Save('done', true)
end
CC_ReportMaxRiskPoint()
HaasScript
-- ============================================================================
-- Firetron's ReportMaxRiskPoint
--
-- Adds a custom report on your worst point of liquidation risk.
--
-- Custom Command Dependencies:
-- Firetron's FormatDateTime
--
-- Discord: @FiretronP75
-- ============================================================================
-- ========================================================
-- Variables
-- ========================================================
-- ------------------------------------
-- Definition
-- ------------------------------------
local dDescription
local dName
local dType
-- ------------------------------------
-- Function
-- ------------------------------------
local Format
local Report
local Track
-- ========================================================
-- Command Definition
-- ========================================================
dName = 'ReportMaxRiskPoint'
dDescription = 'Adds a custom report on your worst point of liquidation risk.'
DefineCommand(dName, dDescription)
-- ========================================================
-- Functions
-- ========================================================
Track = function ()
local positionList = GetAllOpenPositions()
if Count(positionList) == 0 then return end
local current = 0
for i = 1, #positionList do
local positionContainer = positionList[i]
current = current + positionContainer.profit
end
if current >= Load('worst', 0) then return end
Save('unix', Time())
Save('worst', current)
end
-- ----------------
Report = function ()
local unix = Load('unix')
local worst = Load('worst', 0)
local group = 'Max Risk Point Report'
local name = 'Worst Point'
local value = IfElse(worst == 0, 'positions were never cumulatively negative', Format(unix, worst))
CustomReport(name, value, group)
end
-- ----------------
Format = function (unix, worst)
return worst..' '..ProfitLabel()..' on '..CC_FormatDateTime(unix)
end
-- ========================================================
-- Execution
-- ========================================================
Track()
Finalize(function()
Report()
end)
-- ========================================================
-- Output Definition
-- ========================================================
dType = VoidType
DefineOutput(dType)
0 Comments
Sign in to leave a comment.
No comments yet. Be the first!