So I wrote these functions that I thought might be useful to someone, so I'm pasting them here.

They attempt to place a limit order first, and then on the next loop, if the limit order is outstanding, they will cancel the limti order and place a market order.

My idea was to try to avoid paying fees when trading on GDAX this way. In my back testing though, you actually loose more money in the lost profit, than you save in the fees. So it seems you are better off doing market orders always (my stratergy is based around day trading, so perhaps with a longer holding time these would work for you),
 

def GoLong(self, symbol, ratio):

# Make sure we can trade this
security = self.Securities[symbol]
if not security.IsTradable:
self.Debug("{} is not tradable.".format(symbol))
return

# Setup vars
orderQuantity = self.CalculateOrderQuantity(symbol, ratio)
limit = 1.001 # +0.1% Limit Order above current price
limitPrice = round( security.Price * d.Decimal(limit), 2 )
openOrders = self.Transactions.GetOpenOrders(symbol)

if(openOrders):
# Cancel all outstanding orders, then do a Market Order
self.Transactions.CancelOpenOrders(symbol)
self.SetHoldings(symbol, ratio)
self.Log('Going long, canceled all open orders, did a Market Order')

else:
# No open orders, try a limit order then
self.LimitOrder(symbol, orderQuantity, limitPrice)
self.Log( str(security.Price) )
self.Log('Going long. Placed a limit order at ' + str(limitPrice))


def CloseLong(self, symbol):

# Make sure we can trade this
security = self.Securities[symbol]
if not security.IsTradable:
self.Debug("{} is not tradable.".format(symbol))
return

# Setup vars
quantity = security.Holdings.Quantity
limit = 1.001 # +0.1% Limit Order below current price
limitPrice = round( security.Price / d.Decimal(limit), 2 )
openOrders = self.Transactions.GetOpenOrders(symbol)

if(openOrders):
# Liquidate (which also cancels all outstanding orders)
self.Liquidate(symbol)
self.Log('Closing long, liquidated')

else:
# Try a limit order
self.LimitOrder(symbol, -quantity, limitPrice)
self.Log( str(security.Price) )
self.Log('Closing long. Placed a limit order at ' + str(limitPrice))

Author