Path: blob/master/ invest-robot-contest_sirius-master/api_calls/sandbox_buy.py
5932 views
import logging12from api_calls.common_requests import make_api_request34sandbox_service_path = "tinkoff.public.invest.api.contract.v1.SandboxService/"567def sandbox_place_order(account_id, figi, quantity, deal_type):8if deal_type == 'buy':9direction = "ORDER_DIRECTION_BUY"10elif deal_type == 'sell':11direction = "ORDER_DIRECTION_SELL"12else:13return1415data = {16"figi": figi,17"quantity": quantity,18"direction": direction,19"accountId": account_id,20"orderType": "ORDER_TYPE_MARKET",21"orderId": ""22}23res = make_api_request(sandbox_service_path + 'PostSandboxOrder', data)24logging.debug("Sandbox place order: {}".format(res))25return res262728def sandbox_get_order_state(account_id, order_id):29data = {30"accountId": account_id,31"orderId": order_id32}33res = make_api_request(sandbox_service_path + 'GetSandboxOrderState', data)34logging.debug("Sandbox order state: {}".format(res))35return res363738def sandbox_cancel_order(account_id, order_id):39data = {40"accountId": account_id,41"orderId": order_id42}43res = make_api_request(sandbox_service_path + 'CancelSandboxOrder', data)44logging.debug("Sandbox cancel order: {}".format(res))45return res464748