Fixed a bug with sell orders and added documentation

This commit is contained in:
fredfortier
2017-08-31 13:15:43 -04:00
parent 6e166383ed
commit a785607d8f
4 changed files with 224 additions and 3 deletions
+9 -1
View File
@@ -47,7 +47,7 @@ def _handle_data(context, data):
buy_increment = 50
elif rsi <= 40:
buy_increment = 20
elif rsi <= 70:
elif rsi <= 90:
buy_increment = 5
else:
buy_increment = None
@@ -72,6 +72,14 @@ def _handle_data(context, data):
cost_basis = None
if context.asset in context.portfolio.positions:
position = context.portfolio.positions[context.asset]
# TODO: temp test
if position.amount > 0:
order_target_percent(
asset=context.asset,
target=0,
limit_price=price * (1 - context.SLIPPAGE_ALLOWED),
)
return
cost_basis = position.cost_basis
log.info(