mirror of
https://github.com/wassname/catalyst.git
synced 2026-09-12 12:12:04 +08:00
Fixed a bug with sell orders and added documentation
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user