Chavithra / degiro-connector

This is yet another library to access Degiro's API.
BSD 3-Clause "New" or "Revised" License
205 stars 46 forks source link

Order placement error #101

Closed ash21213 closed 9 months ago

ash21213 commented 1 year ago

Got the below errors while trying to place from order.py

DEBUG:degiro_connector.trading.api:setup_one_action : check_order DEBUG:degiro_connector.trading.api:setup_one_action : confirm_order DEBUG:degiro_connector.trading.api:setup_one_action : connect DEBUG:degiro_connector.trading.api:setup_one_action : create_favourite_list DEBUG:degiro_connector.trading.api:setup_one_action : delete_favourite_list DEBUG:degiro_connector.trading.api:setup_one_action : delete_favourite_list_product DEBUG:degiro_connector.trading.api:setup_one_action : delete_order DEBUG:degiro_connector.trading.api:setup_one_action : get_account_info DEBUG:degiro_connector.trading.api:setup_one_action : get_account_overview DEBUG:degiro_connector.trading.api:setup_one_action : get_agenda DEBUG:degiro_connector.trading.api:setup_one_action : get_cash_account_report DEBUG:degiro_connector.trading.api:setup_one_action : get_client_details DEBUG:degiro_connector.trading.api:setup_one_action : get_company_profile DEBUG:degiro_connector.trading.api:setup_one_action : get_company_ratios DEBUG:degiro_connector.trading.api:setup_one_action : get_config DEBUG:degiro_connector.trading.api:setup_one_action : get_estimates_summaries DEBUG:degiro_connector.trading.api:setup_one_action : get_favourites_list DEBUG:degiro_connector.trading.api:setup_one_action : get_financial_statements DEBUG:degiro_connector.trading.api:setup_one_action : get_latest_news DEBUG:degiro_connector.trading.api:setup_one_action : get_news_by_company DEBUG:degiro_connector.trading.api:setup_one_action : get_orders_history DEBUG:degiro_connector.trading.api:setup_one_action : get_position_report DEBUG:degiro_connector.trading.api:setup_one_action : get_products_config DEBUG:degiro_connector.trading.api:setup_one_action : get_products_info DEBUG:degiro_connector.trading.api:setup_one_action : get_top_news_preview DEBUG:degiro_connector.trading.api:setup_one_action : get_transactions_history DEBUG:degiro_connector.trading.api:setup_one_action : get_update DEBUG:degiro_connector.trading.api:setup_one_action : logout DEBUG:degiro_connector.trading.api:setup_one_action : product_search DEBUG:degiro_connector.trading.api:setup_one_action : put_favourite_list_product DEBUG:degiro_connector.trading.api:setup_one_action : update_favourite_list DEBUG:degiro_connector.trading.api:setup_one_action : update_order DEBUG:degiro_connector.core.models.model_session:session:getter: MainThread DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): trader.degiro.nl:443 DEBUG:urllib3.connectionpool:https://trader.degiro.nl:443 "POST /login/secure/login HTTP/1.1" 200 None INFO:degiro_connector.trading.actions.action_connect:get_session_id:response_dict: {'isPassCodeEnabled': True, 'locale': 'de_DE', 'redirectUrl': 'https://trader.degiro.nl/trader/', 'sessionId': 'DCA2034F95D4F26484B1EBDB7E024C2C.prod_a_168_4', 'status': 0, 'statusText': 'success'} DEBUG:degiro_connector.core.models.model_session:session:getter: MainThread DEBUG:urllib3.connectionpool:https://trader.degiro.nl:443 "POST /trading/secure/v5/checkOrder;jsessionid=DCA2034F95D4F26484B1EBDB7E024C2C.prod_a_168_4?intAccount=0&sessionId=DCA2034F95D4F26484B1EBDB7E024C2C.prod_a_168_4 HTTP/1.1" 404 None CRITICAL:degiro_connector.trading.actions.action_check_order:404 CRITICAL:degiro_connector.trading.actions.action_check_order:{"errors":[{"text":"No corresponding resource found"}]} Traceback (most recent call last): File "f:\degiro-connector-main\examples\trading\order.py", line 49, in confirmation_id = checking_response.confirmation_id AttributeError: 'NoneType' object has no attribute 'confirmation_id'

Salinatorimperator commented 9 months ago

Hi @ash21213 did you find the problem? Kind of a noob with these and I cant find what I am doing wrong. The petition ` request_stock = ProductSearch.RequestStocks( index_id=122001, # NASDAQ 100 exchange_id=663, # NASDAQ

You can either use index_id or exchange id

    # See which one to use in the `ProductsConfig` table
    is_in_us_green_list=True,
    stock_country_id=846,  # US
    offset=0,
    limit=100,
    require_total=True,
    sort_columns="name",
    sort_types="asc",
)`

works, and also this one: # SETUP REQUEST request = ProductSearch.RequestLookup( search_text=ticker, limit=10, offset=0, product_type_id=0, ) returning OK values if think:

`name: Activision Blizzard Inc qualitySwitchable: True vwdId: 350113856 productTypeId: 1.0 exchangeId: 663 sellOrderTypes: values { string_value: "LIMIT" } values { string_value: "MARKET" } values { string_value: "STOPLOSS" } values { string_value: "STOPLIMIT" }

vwdModuleId: 21.0 orderTimeTypes: values { string_value: "DAY" } values { string_value: "GTC" }

productBitTypes: values { string_value: "US_RAS_GREEN_LIST" }

feedQualitySecondary: BT contractSize: 1.0 active: True buyOrderTypes: values { string_value: "LIMIT" } values { string_value: "MARKET" } values { string_value: "STOPLOSS" } values { string_value: "STOPLIMIT" }

orderBookDepth: 0.0 qualitySwitchFreeSecondary: False closePrice: 92.01 symbol: ATVI id: 332109 isShortable: False closePriceDate: 2023-09-07 orderBookDepthSecondary: 0.0 qualitySwitchFree: False isin: US00507V1098 vwdIdentifierType: issueid vwdIdentifierTypeSecondary: vwdkey vwdIdSecondary: ATVI.BATS,E productType: STOCK feedQuality: D15 onlyEodPrices: False tradable: True qualitySwitchableSecondary: True category: B currency: USD vwdModuleIdSecondary: 31.0`

But I keep getting this error: 404 {"errors":[{"text":"No corresponding resource found"}]} I will ping also @Chavithra to see if he has some clues and thank you for the awesome library!

ash21213 commented 9 months ago

Hi @Salinatorimperator ,

Try this. Its working fine

ord = Order(action=Order.Action.BUY,order_type=Order.OrderType.LIMIT,price=round(float(bp),2),product_id=int(pid),size=int(qty),time_type=Order.TimeType.GOOD_TILL_DAY,) if BS=="B" else Order(action=Order.Action.SELL,order_type=Order.OrderType.LIMIT,price=round(float(bp),2),product_id=int(pid),size=int(qty),time_type=Order.TimeType.GOOD_TILL_DAY,)

print(ord) checking_response = trading_api.check_order(order=ord) confirmation_id = checking_response.confirmation_id

confirmation_response = trading_api.confirm_order(confirmation_id=confirmation_id, order=ord)
print(confirmation_response.order_id )

Salinatorimperator commented 9 months ago

Hi @ash21213 for me was that i was creating the tradingAPI without the int_account. Once I added that to the credentials creating the object, it worked fine. Thanks nevertheless!! I think this can be closed @Chavithra