Skip to content

[feature request] Add support for Trailing Stop Limit Order via CLIENT_VERSION Upgrade #145

Open

Description

@hydrosquall

This is the order type documented under the Trailing Stop Limit heading here, with the code of TRAIL LIMIT. It would have fields for

  • action
  • quantity
  • trailStopPrice
  • lmtPriceOffset
  • auxPrice

I imagine this would be added as a new file inside of ./lib/order with a name like trailLimit.js.

Activity

  1. hydrosquall commented on Aug 10, 2019

    @hydrosquall
    Author

    From looking at the code further, the primary in-depth change needed to make this work is to support the lmtPriceOffset field, which is currently not handled in the outgoing.js file. Specifically, this section of the EClient.java file would need to be ported for this to work correctly.

    // send orderMiscOptions parameter
    if(m_serverVersion >= MIN_SERVER_VER_LINKING) {
    StringBuilder orderMiscOptionsStr = new StringBuilder();
    List<TagValue> orderMiscOptions = order.orderMiscOptions();
    int orderMiscOptionsCount = orderMiscOptions == null ? 0 : orderMiscOptions.size();
    if( orderMiscOptionsCount > 0) {
    for( TagValue tagValue : orderMiscOptions ) {
    orderMiscOptionsStr.append(tagValue.m_tag).append("=").append(tagValue.m_value).append(";");
    }
    }
    b.send( orderMiscOptionsStr.toString());
    }
    if (m_serverVersion >= MIN_SERVER_VER_ORDER_SOLICITED) {
    b.send(order.solicited());
    }
    if (m_serverVersion >= MIN_SERVER_VER_RANDOMIZE_SIZE_AND_PRICE) {
    b.send(order.randomizeSize());
    b.send(order.randomizePrice());
    }
    if (m_serverVersion >= MIN_SERVER_VER_PEGGED_TO_BENCHMARK) {
    if (order.orderType() == OrderType.PEG_BENCH) {
    b.send(order.referenceContractId());
    b.send(order.isPeggedChangeAmountDecrease());
    b.send(order.peggedChangeAmount());
    b.send(order.referenceChangeAmount());
    b.send(order.referenceExchangeId());
    }
    b.send(order.conditions().size());
    if (order.conditions().size() > 0) {
    for (OrderCondition item : order.conditions()) {
    b.send(item.type().val());
    item.writeTo(b);
    }
    b.send(order.conditionsIgnoreRth());
    b.send(order.conditionsCancelOrder());
    }
    b.send(order.adjustedOrderType());
    b.send(order.triggerPrice());
    b.send(order.lmtPriceOffset());
    b.send(order.adjustedStopPrice());
    b.send(order.adjustedStopLimitPrice());
    b.send(order.adjustedTrailingAmount());
    b.send(order.adjustableTrailingUnit());
    }

  2. nemozny commented on Aug 19, 2019

    @nemozny

    You don't need to use /lib/orders, those are just for your convenience. You can construct the order by yourself, which is what I do.

    const parent = orderId++
    ib.placeOrder(parent, contract, {
    				action : "BUY",
    				orderType : "MKT",
    				transmit : false
    			})
    ib.placeOrder(orderId++, contract, {
    				action : "SELL",
    				orderType : "TRAIL",
    				auxPrice : 10,
                                    parentId : parent,
    				transmit : true
    			})
    

    The important here is the transmit and parentId keys.
    Similarly you can build your TRAIL LIMIT.

  3. hydrosquall commented on Aug 19, 2019

    @hydrosquall
    Author
  4. changed the title [-][feature request] Add support for Trailing Stop Limit Order[/-] [+][feature request] Add support for Trailing Stop Limit Order via CLIENT_VERSION Upgrade[/+] on Aug 31, 2019
  5. hydrosquall commented on Aug 31, 2019

    @hydrosquall
    Author

    Update:

    Upon closer inspection, it appears that adding these fields was probably part of the jump from API version 9.70.01 from 9.73

    (Compare what the Java client supports)

    (to what the JS code implements)

    Adding support for newer versions of the client would address these sibling issues:

    I have a hunch about how to adjust this part of the code with outgoing.js, but am unsure about the extent of the other API changes needed for deserializing incoming payloads.

  6. tredondo commented on Aug 18, 2021

    @tredondo
    Contributor

    @pilwon: how can we add fields to the code that deserializes them from the server?

    For example, in placeOrder, orderState misses many of the newer fields like initMarginChange.

    I tried adding orderState.foo = this.dequeue() after the last assignment (to .warningText) but that caused the client to time out.

  7. ceddybi commented on Aug 20, 2021

    @ceddybi

    @tredondo @hydrosquall - you are late to the party, we have everything here https://github.com/stoqey/ib,

    @pilwon you must update the readme and point to this new version, clearly, this node-ib is very outdated and you barely merge changes, which is very misleading to other developers

  8. GithubJaimeLee commented on Nov 30, 2023

    @GithubJaimeLee

    This is such a genius project, I want to join in!! I'm currently using your program and if I find any bugs, I will provide feedback on the open-source platform!!! The author is incredible!!! Please give me the PayPal of the owner, I want to make a donation!!!! My email is [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions