algo2t / alphatrade

Python APIs for SAS Online Alpha Trade Web platform for creating algo trading using python

Home Page:https://algo2t.github.io/alphatrade

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getting Error in place_order in alphatrade 1.0

vinaydde opened this issue · comments

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"}

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

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

image

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

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