has anyone used google cloud functions?

harshtock
I am trying to configure google cloud functions to place an order when the function is triggered.
I have mentioned "kiteconnect" in the requirements.txt file
But the function doesn't get deployed. throws an error "Unknown resource type".

Does anyone have any experience dealing with cloud functions?

Following is the function that i have tried:

import logging
from kiteconnect import KiteConnect

logging.basicConfig(level=logging.DEBUG)

kite = KiteConnect(api_key="xxxxxxxxxxxxxxxxxxxxxxxx")

# Redirect the user to the login url obtained
# from kite.login_url(), and receive the request_token
# from the registered redirect url after the login flow.
# Once you have the request_token, obtain the access_token
# as follows.

data = kite.generate_session("xxxxxxxxxxxxxxxxxxxxxxxxx", secret="xxxxxxxxxxxxxxxxxxxxxxxxxx")
kite.set_access_token(data["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"])

# Place an order
def orderPlace():
order_id = kite.place_order(
variety=kite.VARIETY_REGULAR,
exchange=kite.EXCHANGE_NSE,
tradingsymbol="INFY",
transaction_type=kite.TRANSACTION_TYPE_BUY,
quantity=1,
product=kite.PRODUCT_CNC,
order_type=kite.ORDER_TYPE_MARKET
)

logging.info("Order placed. ID is: {}".format(order_id))
except Exception as e:
logging.info("Order placement failed: {}".format(e.message))
Sign In or Register to comment.