I saw in the documentation that trailing stop orders are to come.
Any help with code (python) that could monitor 1 minute price moves and create a market sell order when the ‘trailing stop’ has been reached?
For example:
Buy SPY @ $300
Currently, I could open a limit sell at $270 (down 10%).
If SPY runs to $350, I’d like to have code that is checking every minute if SPY falls below $315 (down 10% from $350). Once the current price hits $315, I’d automatically enter a market sell order.
I’m learning python, so my rough logic would be:
def high_price()
executed_order_price = [get from orders]
current_price = [get from market]
if(current_price > executed_order_price):
return current_price
def price_trigger
if current_price < (high_price * 0.9)
api.submit_order(‘SPY’,qty=100,side=‘sell’,type=‘market’)
My algo runs ~ every minute, so it will update with the last trade and compare to the last completed minute. If a stock is rising, the current_position_price will be greater than the previous minute. At the next refresh, the price_1m_ago will then be higher, and ‘trail’ the current price on its way up.
Finally, we are ready for a Beta program for the Trailing Stop. Please see the draft document here.
As of today, we plan to spend a couple of weeks doing a beta test for the Trailing Stop until the full launch. We are looking for 20-30 beta users for Trailing Stop.
If you are interested in this, please fill out your information in this google form so that we can invite you to the private Slack channel.