Announcement

Collapse
No announcement yet.

Order.state return the number 32

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Order.state return the number 32

    PHP Code:
    nQty Math.round(100000/open(0));
    orderID Trade.buyMarket({qtynQty});
    orderState Order.state orderID ); 
    This returns:
    orderState - 32
    orderID - 9b26bfd9002c48c7a941c2aebb403cb4

    What am I doing wrong?

  • #2
    Can someone help me with this please? I'm following the guides and not getting anywhere.

    Cheers

    Comment


    • #3
      Try something like the following where the argument “o” is your Order.state(orderID).

      function GET_ORDER_STATE(o) {
      switch(o) {
      case Order.STATE_PARTIALFILL :
      return "STATE_PARTIALFILL";
      case Order.STATE_PLACING :
      return "STATE_PLACING";
      case Order.STATE_CANCELING :
      return "STATE_CANCELING";
      case Order.STATE_UPDATING :
      return "STATE_UPDATING";
      case Order.STATE_FILLED :
      return "STATE_FILLED";
      case Order.STATE_CANCELED :
      return "STATE_CANCELED";
      case Order.STATE_REJECTED :
      return "STATE_REJECTED";
      case Order.STATE_WORKING :
      return "STATE_WORKING";
      default:
      return "Unknown ORDERSTATE";
      }
      }

      Comment


      • #4
        Hello KingSerk,

        This is a valid behavior. Order states are represented by an enumeration where each state corresponds to a number. You can use your variable 'orderState' further in the code and compare it to state constants, e.g.:

        Code:
        ---------
        if (orderState == Order.STATE_PLACING)
        {
        // do something
        }
        ---------
        If you want to see the string representation of your variable you can write an additional function and use it. It can be as follows:

        Code:
        ---------
        function toStr(orderState)
        {
        if (orderState == Order.STATE_PLACING) return "PLACING";
        if (orderState == Order.STATE_WORKING) return "WORKING";
        if (orderState == Order.STATE_REJECTED) return "REJECTED";
        if (orderState == Order.STATE_CANCELED) return "CANCELED";
        if (orderState == Order.STATE_PARTIALFILL) return "PARTIALFILL";
        if (orderState == Order.STATE_FILLED) return "FILLED";
        if (orderState == Order.STATE_CANCELING) return "CANCELING";
        if (orderState == Order.STATE_UPDATING) return "UPDATING";
        return "UNKNOWN";
        }
        ---------
        And use it in your code:

        Code:
        ---------
        nQty = Math.round(100000/open(0));
        orderID = Trade.buyMarket({qty: nQty});
        orderState = Order.state ( orderID );
        debugPrintln("Current state: " + toStr(orderState));
        ---------

        Comment


        • #5
          I feel silly! Thanks odgo! Thanks Avery! Much appreciated!

          Comment

          Working...
          X