Esempio n. 1
0
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)
Esempio n. 2
0
    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))
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
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)
Esempio n. 6
0
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)
Esempio n. 7
0
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)
Esempio n. 8
0
 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))