Which way is the most elegant way to create a series of differences on PMI data. How do i get a change in the PMI data istead of the PMI data it self?
fetch_csv("https://www.quandl.com/api/v1/datasets/ISM/MAN_PMI.csv?&trim_start=1948-01-01&trim_end=2017-12-13&sort_order=desc",
symbol = "PMI",
date_column = "Date",
date_format = "%d/$m/%Y")
`
def my_rebalance(context, data):
PMI = data.current("PMI","Index")
weights= 0
if PMI >50:
weights = ((float(1)/len(context.longs)))
for stock in context.longs.index:
if stock in context.longs.index and data.can_trade(stock):
order_target_percent(stock, weights)
for stock in context.portfolio.positions:
if stock not in context.longs.index and data.can_trade(stock) and PMI:
order_target_percent(stock, 0)``