Firetron’s PlaceSpreadOrder

2 839 Views No Comments 4 years ago
  • Creates a spread of orders.

    Custom Command Dependencies:
    None

    Test Script:

    if not Load('done', false) then
    
      local currentPrice = CurrentPrice()[1]
    
      -- Test Long Spread
    
      Log('==================================================')
      Log('Testing Long Spread, CurrentPrice: '..currentPrice)
      Log('==================================================')
    
      local p = {
        amountList   = {1, 2, 3},
        direction    = 'GoLong',
        orderOptions = {
          market = PriceMarket(),
          type   = NoTimeOutOrderType,
          note   = 'Long Spread',
        },
        priceList    = {currentPrice, SubPercentage(currentPrice, 1), SubPercentage(currentPrice, 1)},
      }
    
      local longOrders = CC_PlaceSpreadOrder(p)
    
      for i = 1, #longOrders do
    
        Log('Long Order ID: '..longOrders[i])
    
      end
    
      -- Test Short Spread
    
      Log('==================================================')
      Log('Testing Short Spread, CurrentPrice: '..currentPrice)
      Log('==================================================')
    
      p.direction         = 'GoShort'
      p.orderOptions.note = 'Short Spread'
      p.priceList         = {currentPrice, AddPercentage(currentPrice, 1), AddPercentage(currentPrice, 1)}
    
      local shortOrders = CC_PlaceSpreadOrder(p)
    
      for i = 1, #shortOrders do
    
        Log('Short Order ID: '..shortOrders[i])
    
      end
    
      Save('done', true)
    
    end
    HaasScript Code
    Sign in or Register to download for free
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free