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

getting Error in place_order in alphatrade 1.0 #63

Open vinaydde opened 1 year ago

vinaydde commented 1 year ago

I am getting following error respsonse while placing order. Code: print( sas.place_order(transaction_type = TransactionType.Buy, instrument = sas.get_instrument_by_symbol('NSE', 'INFY'), quantity = 1, order_type = OrderType.Market, product_type = ProductType.Delivery, price = 0.0, trigger_price = 0.0, stop_loss = None, square_off = None, trailing_sl = None,
is_amo = False) )

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

jrdinesh commented 10 months ago

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}

transaction_type needs to be replaced with order_side in place_order method

PushkarSaxena commented 7 months ago

this is not working. I tried making changes as suggested in alphatrade.py but still getting same error:

image

nevatia commented 7 months ago

Plz try n check solution provided above transaction_type needs to be replaced with order_side in place_order method.

Or check here T e l e g r a m /sasonlineunofficial

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