def example_of_sltp_group(): rest = get_client() cmd = helpers.limit_order(1012833458, id("limit-order-with-sltp"), "XBTUSD", constants.Side_Buy, "10000", "1") helpers.add_trailing_stop_loss(cmd, "500") helpers.add_take_profit(cmd, "10500") resp = rest.order(cmd) print(resp) # or cmd = helpers.limit_order(1012833458, id("limit-order-with-sltp"), "XBTUSD", constants.Side_Buy, "10000", "1", trailing_offset="500", take_profit_price="10500") resp = rest.order(cmd) print(resp)
async def limit_order(self, account, client_order_id, symbol, side, price, qty, **kwargs): """Create limit order and send request""" await self.send_cmd( helpers.limit_order(account, client_order_id, symbol, side, price, qty, **kwargs))
def example_of_take_profit_for_existing_position(): rest = get_client() # create limit order and fill PositionID and PositionEffect fields cmd = helpers.limit_order(1012833458, id("limit-order"), "XBTUSD", constants.Side_Sell, "10000", "1") helpers.for_position(cmd, 130723016) resp = rest.order(cmd) print(resp)
def example_of_limit_order(): rest = get_client() resp = rest.limit_order(8263118, id("limit-order"), "BTC/USDT", constants.Side_Buy, "10000", "0.01") print(resp) # or using helpers method cmd = helpers.limit_order(8263118, id("limit-order"), "BTC/USDT", constants.Side_Buy, "10000", "0.01") restp = rest.order(cmd) print(resp)
async def example_of_sltp_group(): ws = await get_client() async def handle(ws, msg): print(msg) ws.listen_type(constants.MsgType_ExecutionReportMsgType, handle) cmd = helpers.limit_order(1012833459, id("limit-order-with-sltp"), "XBTUSD", constants.Side_Sell, "10000", "1") helpers.add_trailing_stop_loss(cmd, "500") helpers.add_take_profit(cmd, "10500") await ws.send_cmd(cmd) # or cmd = helpers.limit_order(1012833459, id("limit-order-with-sltp"), "XBTUSD", constants.Side_Sell, "10000", "1", trailing_offset="500", take_profit_price="10500") await ws.send_cmd(cmd) # looop while True: await asyncio.sleep(20, loop=loop)
async def example_of_limit_order(): ws = await get_client() async def handle(ws, msg): print(msg) ws.listen_type(constants.MsgType_ExecutionReportMsgType, handle) await ws.limit_order(8263200, id("limit-order"), "BTC/USDT", constants.Side_Buy, "10000", "0.01", text="comment") # or using helpers method cmd = helpers.limit_order(8263200, id("limit-order"), "BTC/USDT", constants.Side_Buy, "10000", "0.01") await ws.send_cmd(cmd) # looop while True: await asyncio.sleep(20, loop=loop)
async def example_of_take_profit_for_existing_position(): ws = await get_client() async def handle(ws, msg): print(msg) ws.listen_type(constants.MsgType_ExecutionReportMsgType, handle) # create limit order and fill PositionId and PositionEffect fields cmd = helpers.limit_order(1012833459, id("limit-order"), "XBTUSD", constants.Side_Sell, "10000", "1") helpers.for_position(cmd, 123456) await ws.send_cmd(cmd) # looop while True: await asyncio.sleep(20, loop=loop)
def limit_order(self, account, client_order_id, symbol, side, price, qty, **kwargs): return self.new_order( helpers.limit_order(account, client_order_id, symbol, side, price, qty, **kwargs))