algo2t / alphatrade

Python APIs for SAS Online Alpha Trade Web platform for creating algo trading using python
https://algo2t.github.io/alphatrade
MIT License
45 stars 25 forks source link

HTTPError: {"data":{},"error_code":44000,"message":"`order_side` can't be blank","status":"error"} #68

Open vikashpissey opened 4 months ago

vikashpissey commented 4 months ago

sas.place_order(transaction_type=TransactionType.Buy,

instrument=sas.get_instrument_by_symbol(n_call.exchange,n_call.symbol),

                    instrument=sas.get_instrument_by_symbol('NFO', 'BANKNIFTY MAY 49300.0 CE'),
                    quantity=15,
                    order_type=OrderType.StopLossLimit,
                    product_type=ProductType.BracketOrder,
                    price=float(400),
                    trigger_price=float(400),
                    stop_loss=float(380),
                    square_off=float(420),
                    trailing_sl=None,
                    is_amo=False)

########################################################## Traceback (most recent call last):

File C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels[py3compat.py:356](https://py3compat.py:356/) in compat_exec exec(code, globals, locals)

File c:\users\vikash.spyder-py3\bank[untitled4.py:43](https://untitled4.py:43/) sas.place_order(transaction_type=TransactionType.Buy,

File C:\ProgramData\Anaconda3\lib\site-packages\alphatrade[alphatrade.py:687](https://alphatrade.py:687/) in place_order return self.__api_call_helper(helper, Requests.POST, None, order)

File C:\ProgramData\Anaconda3\lib\site-packages\alphatrade[alphatrade.py:1086](https://alphatrade.py:1086/) in __api_call_helper raise requests.HTTPError(response.text)

HTTPError: {"data":{},"error_code":44000,"message":"product can't be blank","status":"error"}

coolprafulpl commented 3 months ago

open alphatrade.py find and replace all transaction_type with order_side

and change this code

order = {'exchange': instrument.exchange,
         'order_type': order_type.value,
         'instrument_token': instrument.token,
         'quantity': quantity,
         'disclosed_quantity': 0,
         'price': price,
         'transaction_type': transaction_type.value,
         'trigger_price': trigger_price,
         'validity': 'DAY',
         'product': prod_type,
         'source': 'web',
         'order_tag': order_tag}

with this

order = {'exchange': instrument.exchange,
         'order_type': order_type.value,
         'instrument_token': instrument.token,
         'quantity': quantity,
         'disclosed_quantity': 0,
         'price': price,
         'order_side': order_side.value,
         'trigger_price': trigger_price,
         'validity': 'DAY',
         'product': prod_type,
         "device": 'web',
         "market_protection_percentage":0,
         "user_order_id": order_tag}

and in

def place_order(self, order_side, instrument, quantity, order_type, product_type, price=0.0, trigger_price=None, stop_loss=None, square_off=None, trailing_sl=None, is_amo=False, order_tag=10001): change order_tag value instead of 'python' to numbers