November 2019
Beginner
394 pages
10h 31m
English
Now, before we get into the main strategy loop, let's define some final variables and thresholds we will need to build our StatArb trading strategy:
# Variables for Trading Strategy trade, position & pnl management:orders = [] # Container for tracking buy/sell order, +1 for buy order, -1 for sell order, 0 for no-actionpositions = [] # Container for tracking positions, positive for long positions, negative for short positions, 0 for flat/no positionpnls = [] # Container for tracking total_pnls, this is the sum of closed_pnl i.e. pnls already locked in and open_pnl i.e. pnls for open-position marked to market pricelast_buy_price = 0 # Price at which last buy trade was made, used to prevent over-trading at/around ...