Path: blob/master/ invest-robot-contest_sirius-master/api_calls/prod_buy.py
5932 views
import logging1import uuid23from api_calls.common_requests import make_api_request45orders_path = "tinkoff.public.invest.api.contract.v1.OrdersService/"678def prod_place_order(account_id, figi, quantity, deal_type):9if deal_type == 'buy':10direction = "ORDER_DIRECTION_BUY"11elif deal_type == 'sell':12direction = "ORDER_DIRECTION_SELL"13else:14return1516data = {17"figi": figi,18"quantity": quantity,19"direction": direction,20"accountId": account_id,21"orderType": "ORDER_TYPE_MARKET",22"orderId": str(uuid.uuid4())23}24res = make_api_request(orders_path + 'PostOrder', data)25logging.debug("Prod place order: {}".format(res))26return res272829def prod_get_order_state(account_id, order_id):30data = {31"accountId": account_id,32"orderId": order_id33}34res = make_api_request(orders_path + 'GetOrderState', data)35logging.debug("Sandbox order state: {}".format(res))36return res373839def prod_cancel_order(account_id, order_id):40data = {41"accountId": account_id,42"orderId": order_id43}44res = make_api_request(orders_path + 'CancelOrder', data)45logging.debug("Sandbox cancel order: {}".format(res))46return res474849