alienbrett / PyAlly

Ally Invest API Module for Python3
https://alienbrett.github.io/PyAlly/
MIT License
57 stars 28 forks source link

Trailing Stop order returns 500 Error #62

Closed la289 closed 3 years ago

la289 commented 3 years ago
import ally

class AllyTrader():
    def __init__(self, use_real_money):
        self.ally = ally.Ally()

        # True preview_order means we will only preview
        # the order, not exectute it.
        # False means the order will execute
        self.preview_order = not use_real_money

    def place_trailing_limit_order(self, ticker, trailing_percent, quantity):

        order_price = ally.Order.TrailingStop(True, trailing_percent)

        order = ally.Order.Order(
            buysell = 'sell',
            symbol = ticker,     
            price = order_price,
            time = 'gtc',
            qty = quantity
        )

        print(str(order))
        self.ally.submit(order, preview=self.preview_order)
        print(order.orderid)
        return order

ally_trader=AllyTrader(False)
order = ally_trader.place_trailing_limit_order("AAPL",5,5)
print(order.id)

Is the trailing stop order type implemented in this library or are you trying to use the deprecated Ally functionality, resulting in an error?

alienbrett commented 3 years ago

It looks like the trailing stop was dropped upstream. This needs to be removed from the library. Thanks Leor for pointing this out