Announcement

Collapse
No announcement yet.

Get position information

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

  • Get position information

    I am considering automating my strategy to the point where it will take the trade and exit the trade completely on its own. I understand how to get eSignal to send the order to enter the trade. My problem is that my entry price is not always filled meaning that entries can potentially become invalid (this is critical to the system). As a result, I would need eSignal to be able to determine wether or not my original entry order was actually filled or not before sending the profit target and stop loss orders.

    So, here is the question - is it possible for eSignal to determine wether or not my order was actually filled before sending my profit target and stop loss orders? If so, how would I go about doing this?

    If it makes any difference, I will most likely be using Interactive Brokers as my broker.
    Last edited by naifwonder; 03-09-2007, 08:55 PM.

  • #2
    Hello naifwonder,

    At this time eSignal does not have the built-in EFS functions needed to request the specific information about orders. This is an area we will look to improve on in the future.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Hi
      I use TWSLink and it can do that with options ( should work with anything). To buy, I submit a limit order at the mid (Bid +Ask)/2 and if after 5 seconds it does not fill. I modify the order, first I get the current mid and add $0.01 to the limit order and then if it does not fill in 5 sec I add $0.02. to the current mid this time and modify the order with the new limit price. And so on to a max of the Ask price. To sell, I do the opposite (subtract from the mid). I call it "Auto_Chase()".

      Note: IB charges you $1.25 everytime you change and order. But I buy 10 option contracts at a time and if I can save $0.05 ($50.00 USD) by spending $1.25 a few times, it is worth it. Then when I sell if I can save another $0.05 ($100 in and out on 10 contracts) and I do that say 20 times a day and 200 days per year, it adds up to real big money in a year.

      PHP Code:
      function Check_on_Order() {
          if (
      nrTradeStatus != && Order_Status != 9) {
              
      get_Order_Status();
              if (
      Order_Status == && Auto_Chase && (Time_of_Day Order_Time) >= nOrder_Time_Limit) {
                  
      Auto_Chase();
              }
      .
      .
      .
      function 
      Auto_Chase() {
          
      get_market_data(Order_Contract_ID);
          
      mid get_Mid_Price(Bid,Ask,Option_Price_Increment,Side);
          if (
      Last_Mid != mid) {
              
      buyOrderId twslink.call("PLACE_ORDER"Order_Contract_IDbuyOrderIdSide"LMT"Order_quantitymid, -1"DAY"10"""", -1);
              
      Order_Status twslink.call("WAIT_FOR_ORDER_STATUS_RNG"buyOrderId,5,8,3000,12);
              
      debugPrintln("buyOrderId = " buyOrderId+" Order Status="+Order_Status );
              
      Order_Error twslink.call("GET_ORDER_ERROR"buyOrderId);
              
      debugPrintln("buyOrderId = " buyOrderId+" Order Error="+Order_Error );
              if (
      Order_Error == && Order_Status 0) {
                  
      Order_Time 0;
              }
          }
          
      Last_Mid mid;    
          
      Auto_Chase_ct ++;

      return;
      }
      function 
      get_Mid_Price(Bid,Ask,Option_Price_Increment,Side) {
          
      debugPrintln("**** Executing get_Mid_Price("+Bid+","+Ask+","+Option_Price_Increment+","+Side+")");    
          
      Mid = (Math.floor(((Ask Bid)/.02).toFixed(2))/100).toFixed(2);
          
      Mid_Inc_Times Math.floor((Mid/Option_Price_Increment).toFixed(2)*1);    
          
      Mid Mid_Inc_Times*Option_Price_Increment;
          if (
      Side == "BUY"
              
      Mid = (Ask Mid).toFixed(2)*1;
          else    
              
      Mid = (Bid Mid).toFixed(2)*1;
          
      debugPrintln("Mid="+Mid+" M Times="+Mid_Inc_Times+" Auto ct="+Auto_Chase_ct);    
          if (
      Auto_Chase_ct 0) {
              if (
      Side == "BUY") {
                  
      Mid += (Auto_Chase_ct/100).toFixed(2)*1;
                  
      Mid Math.min(Ask,Mid);
              }
              else {
                  
      Mid -= (Auto_Chase_ct/100).toFixed(2)*1;
                  
      Mid Math.max(Bid,Mid);
              }    
          } 
          
      debugPrintln("Mid="+Mid+" M Times="+Mid_Inc_Times+" Auto ct="+Auto_Chase_ct);    
      return 
      Mid;
      }
      function 
      get_Order_Status() {
          
      Order_Status twslink.call("GET_ORDER_STATUS"buyOrderId);
          switch( 
      Order_Status)
          {
            case  
      0display_Status_Msg("Order Not Found"); 
              break;
            case  
      1display_Status_Msg("Order Inital"); 
              break;
            case  
      2display_Status_Msg("Order Transmited"); 
              break;
            case  
      3display_Status_Msg("Order Cancel Transmited"); 
              break;
            case  
      4display_Status_Msg("Order Inactive"); 
              break;
            case  
      5display_Status_Msg("Order Pending Submit"); 
              break;
            case  
      6display_Status_Msg("Order Pending Cancel"); 
              break;
            case  
      7display_Status_Msg("Order Pre-Submited"); 
              break;
            case  
      8display_Status_Msg("Order Working");
                  if (
      Order_Time == 0)  
                      
      Order_Time Time_of_Day
              break;
            case  
      9
                  if (
      nrTradeStatus 0) {
                      
      display_Status_Msg("Order Filled");
                      
      Position =  Order_quantity;
                  }
                  else {
                      
      nrTradeStatus 0;
                      
      display_Status_Msg("Order Flattened");
                      
      Order_Status 0;
                      
      Position =  0;
                  }
                  
      displayBuySellButtons();
                  
      Alert.playSound("Chimes.wav");
              break;
            case  
      10display_Status_Msg("Order Canclled"); 
                  
      nrTradeStatus 0;
                  
      Order_Status 0;
              break;
            case  
      11display_Status_Msg("Order Partial Filled"); 
              break;
            case  
      12display_Status_Msg("Order Invalid"); 
              break;
          }
      return;

      With the cut and paste, I lost the indenting, hope you can read it.
      Tom
      Last edited by windswepttom; 03-16-2007, 03:51 PM.

      Comment

      Working...
      X