Firetron's InputSpreadOrder

stable
By Firetron in Miscellaneous Published November 2020 👁 1,302 views 💬 0 comments

Description

Creates a group of inputs for Firetron's PlaceSpreadOrder. Custom Command Dependencies: Firetron’s GetAmountSpread Firetron’s GetPriceSpread Firetron’s InputAmountSpread Firetron’s InputOrderOptions Firetron’s InputPriceSpread Test Code:
if not Load('done', false) then

  Log('==================================================')
  Log('Testing Alpha Spread Order')
  Log('==================================================')

  local alphaSpreadOrderOptions = CC_InputSpreadOrder('Alpha')

  local alphaOrderList = CC_PlaceSpreadOrder({listDynamic = alphaSpreadOrderOptions})

  for i = 1, #alphaOrderList do

    Log('Alpha Order ID: '..alphaOrderList[i])

  end

  Log('==================================================')
  Log('Testing Beta Spread Order')
  Log('==================================================')

  local betaSpreadOrderOptions = CC_InputSpreadOrder('Beta')

  local betaOrderList = CC_PlaceSpreadOrder({listDynamic = betaSpreadOrderOptions})

  for i = 1, #betaOrderList do

    Log('Beta Order ID: '..betaOrderList[i])

  end

  Save('done', true)

end
HaasScript
--  ============================================================================
--    Firetron's InputSpreadOrder
--
--    Creates a group of inputs for Firetron's PlaceSpreadOrder.
--
--    Custom Command Dependencies:
--    Firetron's GetAmountSpread
--    Firetron's GetPriceSpread
--    Firetron's InputAmountSpread
--    Firetron's InputOrderOptions
--    Firetron's InputPriceSpread
--
--    Discord: @FiretronP75
--  ============================================================================

--  ========================================================
--    Variables
--  ========================================================

--  ------------------------------------
--    Definition
--  ------------------------------------

local defaultValue
local description
local index
local inputSuggestions
local isRequired
local label
local name
local options
local output
local outputSuggestions
local tooltip
local type

--  ------------------------------------
--    Enumeration
--  ------------------------------------

local DirectionType = {
  buy       = 'Buy',
  sell      = 'Sell',
  goLong    = 'GoLong',
  exitLong  = 'ExitLong',
  goShort   = 'GoShort',
  exitShort = 'ExitShort',
}

--  ------------------------------------
--    Parameter
--  ------------------------------------

local pAmountSpreadOptions
local pDirection
local pGroup
local pOrderOptions
local pPriceSpreadOptions

--  ========================================================
--    Command Definition
--  ========================================================

name        = 'InputSpreadOrder'
description = 'Creates a group of inputs for Firetron\'s PlaceSpreadOrder. Does not create an input for the orderOptions parameter.'
DefineCommand(name, description)

--  ========================================================
--    Parameter Definition
--  ========================================================

type             = StringType
name             = 'group'
description      = 'The group of the input fields.'
isRequired       = false
defaultValue     = 'Spread Order'
inputSuggestions = 'Text'
pGroup           = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)

--  ========================================================
--    Input Definitions
--  ========================================================

label        = 'Direction'
defaultValue = DirectionType.goLong
options      = DirectionType
tooltip      = 'Buy, Sell, GoLong, ExitLong, GoShort, ExitShort.'
pDirection   = InputOptions(label, defaultValue, options, tooltip, pGroup..' Direction')

pPriceSpreadOptions  = CC_InputPriceSpread( pGroup..' Price Spread Options')
pAmountSpreadOptions = CC_InputAmountSpread(pGroup..' Amount Spread Options')
pOrderOptions        = CC_InputOrderOptions(pGroup..' Order Options', false, false)

--  ========================================================
--    Output Definitions
--  ========================================================

output = {
  amountList   = CC_GetAmountSpread({listDynamic = pAmountSpreadOptions}),
  direction    = pDirection,
  orderOptions = pOrderOptions,
  priceList    = CC_GetPriceSpread({listDynamic = pPriceSpreadOptions}),
}

type              = ListDynamicType
description       = 'ListDynamic with named elements.'
outputSuggestions = 'CC_PlaceSpreadOrder'
DefineOutput(type, output, description, outputSuggestions)

index       = 1
type        = ListDynamicType
name        = 'amountList'
description = 'List of amounts to use.'
DefineOutputIndex(index, type, name, description, outputSuggestions)

index       = 2
type        = StringType
name        = 'direction'
description = 'Buy, Sell, GoLong, ExitLong, GoShort, ExitShort.'
DefineOutputIndex(index, type, name, description, outputSuggestions)

index       = 3
type        = ListDynamicType
name        = 'orderOptions'
description = 'Parameters to give each order, other than price and amount. See PlaceGoLongOrder or PlaceGoShortOrder for help.'
DefineOutputIndex(index, type, name, description, outputSuggestions)

index       = 4
type        = ListDynamicType
name        = 'priceList'
description = 'List of prices to use.'
DefineOutputIndex(index, type, name, description, outputSuggestions)

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!