Firetron's InputOrderOptions
stableDescription
Creates a group of inputs for order options.
Custom Command Dependencies:
None
Test Script:
if not Load('done', false) then
-- Test Long Order
Log('==================================================')
Log('Testing Long Order: ')
Log('==================================================')
local longOptions = CC_InputOrderOptions('Long Order')
Log(longOptions.price)
Log(longOptions.amount)
Log(longOptions.market)
Log(longOptions.type)
Log(longOptions.note)
Log(longOptions.positionId)
Log(longOptions.timeout)
Log(longOptions.triggerPrice)
local longParams = {
market = longOptions.market,
type = longOptions.type,
note = longOptions.note,
positionId = longOptions.positionId,
timeout = longOptions.timeout,
triggerPrice = longOptions.triggerPrice,
}
PlaceGoLongOrder(longOptions.price, longOptions.amount, longParams)
-- Test Short Order
Log('==================================================')
Log('Testing Short Order')
Log('==================================================')
local shortOptions = CC_InputOrderOptions('Short Order')
Log(shortOptions.price)
Log(shortOptions.amount)
Log(shortOptions.market)
Log(shortOptions.type)
Log(shortOptions.note)
Log(shortOptions.positionId)
Log(shortOptions.timeout)
Log(shortOptions.triggerPrice)
local shortParams = {
market = shortOptions.market,
type = shortOptions.type,
note = shortOptions.note,
positionId = shortOptions.positionId,
timeout = shortOptions.timeout,
triggerPrice = shortOptions.triggerPrice,
}
PlaceGoShortOrder(shortOptions.price, shortOptions.amount, shortParams)
Save('done', true)
end
HaasScript
-- ============================================================================
-- Firetron's InputOrderOptions
--
-- Creates a group of inputs for order options.
--
-- Custom Command Dependencies:
-- None
--
-- Discord: @FiretronP75
-- ============================================================================
-- ========================================================
-- Variables
-- ========================================================
-- ------------------------------------
-- Definition
-- ------------------------------------
local defaultValue
local description
local index
local inputSuggestions
local isRequired
local label
local name
local output
local outputSuggestions
local tooltip
local type
-- ------------------------------------
-- Parameter
-- ------------------------------------
local pAmount = -1
local pGroup
local pIsAmountShown
local pIsMarketShown
local pIsNoteShown
local pIsPositionIdShown
local pIsPriceShown
local pIsTimeoutShown
local pIsTriggerPriceShown
local pIsTypeShown
local pMarket = PriceMarket()
local pNote = ''
local pPositionId = ''
local pPrice = -1
local pTimeout = -1
local pTriggerPrice = -1
local pType = LimitOrderType
-- ========================================================
-- Command Definition
-- ========================================================
description = 'Creates a group of inputs for order options.'
DefineCommand('InputOrderOptions', description)
-- ========================================================
-- Parameter Definition
-- ========================================================
type = StringType
name = 'group'
description = 'The group of the input fields.'
isRequired = false
defaultValue = 'Order Options'
inputSuggestions = 'Text'
pGroup = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)
type = BooleanType
name = 'isPriceShown'
description = 'Shows the input.'
isRequired = false
defaultValue = true
inputSuggestions = 'Boolean'
pIsPriceShown = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)
type = BooleanType
name = 'isAmountShown'
description = 'Shows the input.'
isRequired = false
defaultValue = true
inputSuggestions = 'Boolean'
pIsAmountShown = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)
type = BooleanType
name = 'isMarketShown'
description = 'Shows the input.'
isRequired = false
defaultValue = true
inputSuggestions = 'Boolean'
pIsMarketShown = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)
type = BooleanType
name = 'isTypeShown'
description = 'Shows the input.'
isRequired = false
defaultValue = true
inputSuggestions = 'Boolean'
pIsTypeShown = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)
type = BooleanType
name = 'isNoteShown'
description = 'Shows the input.'
isRequired = false
defaultValue = true
inputSuggestions = 'Boolean'
pIsNoteShown = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)
type = BooleanType
name = 'isPositionIdShown'
description = 'Shows the input.'
isRequired = false
defaultValue = true
inputSuggestions = 'Boolean'
pIsPositionIdShown = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)
type = BooleanType
name = 'isTimeoutShown'
description = 'Shows the input.'
isRequired = false
defaultValue = true
inputSuggestions = 'Boolean'
pIsTimeoutShown = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)
type = BooleanType
name = 'isTriggerPriceShown'
description = 'Shows the input.'
isRequired = false
defaultValue = true
inputSuggestions = 'Boolean'
pIsTriggerPriceShown = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)
-- ========================================================
-- Input Definitions
-- ========================================================
if pIsPriceShown then
label = ' Price'
defaultValue = -1
tooltip = 'The price on which to execute the order. If the order is a market order, this field will be ignored.'
pPrice = Input(label, defaultValue, tooltip, pGroup)
end
if pIsAmountShown then
label = ' Amount'
defaultValue = -1
tooltip = 'The amount to execute.'
pAmount = Input(label, defaultValue, tooltip, pGroup)
end
if pIsMarketShown then
label = ' Market'
tooltip = 'The market returned by PriceMarket(), InputAccountMarket() or InputMarket() for example.'
pMarket = InputAccountMarket(label, tooltip, pGroup)
end
if pIsTypeShown then
label = ' Type'
defaultValue = LimitOrderType
tooltip = 'The type of order. Default is limit.'
pType = InputOrderType(label, defaultValue, tooltip, pGroup)
end
if pIsNoteShown then
label = ' Note'
defaultValue = ''
tooltip = 'A note for the order. Visible in the open orders and history.'
pNote = Input(label, defaultValue, tooltip, pGroup)
end
if pIsPositionIdShown then
label = ' Position ID'
defaultValue = ''
tooltip = 'Optional unique internal identifier that can be used to maintain multiple separate positions.'
pPositionId = Input(label, defaultValue, tooltip, pGroup)
end
if pIsTimeoutShown then
label = ' Timeout'
defaultValue = -1
tooltip = 'The order timeout in seconds. By default the timeout is 600 seconds / 10 minutes.'
pTimeout = Input(label, defaultValue, tooltip, pGroup)
end
if pIsTriggerPriceShown then
label = 'Trigger Price'
defaultValue = -1
tooltip = 'Trigger price, used for conditional orders. This parameter must only be set when using native order types that are supported by the exchange.'
pTriggerPrice = Input(label, defaultValue, tooltip, pGroup)
end
-- ========================================================
-- Output Definitions
-- ========================================================
output = {
price = pPrice,
amount = pAmount,
market = pMarket,
type = pType,
note = pNote,
positionId = pPositionId,
timeout = pTimeout,
triggerPrice = pTriggerPrice,
}
type = ListDynamicType
description = 'ListDynamic with named elements.'
outputSuggestions = 'Trade'
DefineOutput(type, output, description, outputSuggestions)
index = 1
type = NumberType
name = 'price'
description = 'The price on which to execute the order. If the order is a market order, this field will be ignored.'
DefineOutputIndex(index, type, name, description)
index = 2
type = NumberType
name = 'amount'
description = 'The amount to execute.'
DefineOutputIndex(index, type, name, description)
index = 3
type = StringType
name = 'market'
description = 'The market returned by PriceMarket(), InputAccountMarket() or InputMarket() for example.'
DefineOutputIndex(index, type, name, description)
index = 4
type = EnumType
name = 'type'
description = 'The type of order.'
DefineOutputIndex(index, type, name, description)
index = 5
type = StringType
name = 'note'
description = 'A note for the order. Visible in the open orders and history.'
DefineOutputIndex(index, type, name, description)
index = 6
type = StringType
name = 'positionId'
description = 'Optional unique internal identifier that can be used to maintain multiple separate positions.'
DefineOutputIndex(index, type, name, description)
index = 7
type = NumberType
name = 'timeout'
description = 'The order timeout in seconds.'
DefineOutputIndex(index, type, name, description)
index = 8
type = NumberType
name = 'triggerPrice'
description = 'Trigger price, used for conditional orders.'
DefineOutputIndex(index, type, name, description)
0 Comments
Sign in to leave a comment.
No comments yet. Be the first!