Announcement

Collapse
No announcement yet.

Erroneous Order Sent to IB test account.

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

  • Erroneous Order Sent to IB test account.

    Brent,


    I was doing some testing of an automated strategy using my simulated IB account. A strategy I was running placed an order to buy $15,000 of symbol GBP A0-FX.

    For some unknown reason at exactly the same time I sent the order to buy $15,000 GBP A0-FX another order to sell $850,000 GBP A0-FX also went out which was executed in the simulated account.

    I closed both both positions using TWS and again sent out the same buy order again using the esignal strategy, and once again another order to sell went out with my buy $15,000 GBP A0-FX.

    This time it was a sell order for $865,000, which added $15,000 to the last erroneous order amount of $850,000.

    I've noticed the account maintains historical information for past purchases of GBP A0-FX, apparently this value is being picked up from the account and used in a erroneously generated order.

    Given the ramifications should this occur in my real trading account, I would really appreciate if someone could investigate
    this problem.

    Until I find out what's happening, and if this error only occurs in the simulated trading account, or can also occur in an actual account, I am extremely reluctant to trade using an automated strategy.

    I attached the TWS message log.

    Thanks very much.

    Glen
    Attached Files
    Last edited by demarcog; 03-05-2007, 08:55 PM.
    Glen Demarco
    [email protected]

  • #2
    Hello Glen,

    If you are using EFS Generic Broker functions to submit these trades try commenting them out and adding Alert.addToList() calls. For the descriptions, add some text that describes the condition in your code that generated the trade signal. Or you could use debugPrintln() statements if you prefer. This should help you narrow down any logic issues in your code that are sending the unexpected trades.
    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
      Originally posted by JasonK
      Hello Glen,

      If you are using EFS Generic Broker functions to submit these trades try commenting them out and adding Alert.addToList() calls. For the descriptions, add some text that describes the condition in your code that generated the trade signal. Or you could use debugPrintln() statements if you prefer. This should help you narrow down any logic issues in your code that are sending the unexpected trades.
      Hi Jason,

      Thanks for the help, I took your suggestion and didn't see any logic error in the code. Apparently there is a year to date value that is maintained in the IB simulated account for prior currency positions.

      Somehow this value is being picked up and an order generated incrementing the value each time by the previous long position and an sell order is sent out for the entire cumulative value of all previously entered long positions.

      I haven't seen the same problem with my actual account, nor does it occur when using the eSignal paper trading account, which leads me to believe it's unrelated to my code.

      It was obviously very disturbing to see even for a simulated account and remains a concern even after I regained consciousness!

      If it would be helpful and one is not available to you, I can provide you with the simulated account number and password so the problem can be duplicated

      Thanks again,

      Glen
      Last edited by demarcog; 03-06-2007, 09:40 AM.
      Glen Demarco
      [email protected]

      Comment


      • #4
        Hello Glen,

        I have access to a simulated account. What would be most helpful is if you could post your formula or at least the code you're using for submitting the orders with example values of the parameters used.
        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


        • #5
          Originally posted by JasonK
          Hello Glen,

          I have access to a simulated account. What would be most helpful is if you could post your formula or at least the code you're using for submitting the orders with example values of the parameters used.
          Jason,

          I'm attaching 2 screenshots of my simulated IB account. In both cases there are no currently held positions. However notice when the "include FX positions in porfolio" check box is selected in the Account Option. A "position" shows up, which IB has explained to me is historical activity of some kind.

          I don't have the code on this PC but can send it later tonight.
          I wanted to get these screenshots out now, as after last nights error I reset the account balance and not sure when it actually takes effect and wanted you to see the values.

          I realized that the buy order I placed for $15000 GBP A0-FX was executed properly. However, that buy in my strategy is preceded by a closePosition(). It looks like perhaps that is the function that caused the additional sell order for $850,000 GBP-A0 FX to go out.

          You can see that I have no "real" posiiton of GBP in either of these screenshots, but clicking the check box shows that position. I don't usually click that box and it was not clicked when I experienced this error last night.. I did so in this case to show you where the value was coming from.

          Whatever condition exists that makes TWS "think" this is a real position such that it is listed in the Account screen of TWS may also be related to why the trade is going out.

          My guess is that if you have any historical long trades in your account that by checking the box they should show up in your account. Simply executing the closePosition() function by way of the generict_trade button efs you posted some time ago may recreate the error.

          If you still need my code, let me know as I can send it to you later this evening.

          As always thanks very much for all your assistance.

          Glen

          ps.

          Will atach one screenshot with this post and another with the next.
          Attached Files
          Last edited by demarcog; 03-06-2007, 02:16 PM.
          Glen Demarco
          [email protected]

          Comment


          • #6
            Jason,

            Here is the second screen shot with the check box, checked.
            Attached Files
            Glen Demarco
            [email protected]

            Comment


            • #7
              Jason,

              I verified what I suspected, by opening a chart with symbol GBP A0-FX and then loading gbroker_tester.efs, clicking the "closePosition" button sends out an order to sell $835,000 GBP A0-FX which is the amount displayed in Portfolio when the "Include FX Postiions in Portfolio box is checked.

              The order will erroneously get sent out every time closePosition() and closeAllPositions() are executed, really strange.

              This is something that I really hope doesn't occur with anyone's real account for obvious reasons.

              I can PM you with my account and password if you cannot easily reproduce the error. It is easily reproduced with my IB account, too easily.

              Thanks again

              Glen
              Glen Demarco
              [email protected]

              Comment


              • #8
                Hello Glen,

                As far as I can tell the EFS functions are working properly. If there isn't a position in TWS for a symbol, closePosition() will not generate an order. If there is an existing position in the account when closePosition() is called it will generate an order to close the position.

                From the EFS side, it does not care what options are checked or unchecked in the TWS application. The option you are referring to is simply a display option in the TWS account window. Having it unchecked does not mean that there isn't a current position for an FX symbol in the account. EFS still sees that there is a position and creates the offsetting order accordingly, which is the expected behavior.

                Are you saying that when the account does not have a position (regardless of TWS GUI options checked/unchecked) for a symbol and you execute closePosition() for that symbol an order is being created? Please confirm.
                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


                • #9
                  Originally posted by JasonK
                  Hello Glen,

                  As far as I can tell the EFS functions are working properly. If there isn't a position in TWS for a symbol, closePosition() will not generate an order. If there is an existing position in the account when closePosition() is called it will generate an order to close the position.

                  From the EFS side, it does not care what options are checked or unchecked in the TWS application. The option you are referring to is simply a display option in the TWS account window. Having it unchecked does not mean that there isn't a current position for an FX symbol in the account. EFS still sees that there is a position and creates the offsetting order accordingly, which is the expected behavior.

                  Are you saying that when the account does not have a position (regardless of TWS GUI options checked/unchecked) for a symbol and you execute closePosition() for that symbol an order is being created? Please confirm.
                  Jason,

                  That is absolutely what I am saying. In my case it's an $850,000 sell for GBP A0-FX, that goes out everytime I execute either the closePosition() or closeAllPositions() functions even though no such position exists, and will go out repeatedly every time those function are execute. Scarey stuff!

                  I'm fairly certain of what I'm seeing and unless it's some abberation in my particular account it will effect someone else.

                  Given the small margin for large currency positions, even the spread loss at $100 a pip can be significant and being on the wrong side of a trade can virtually wipe out a $10K account quickly.

                  I'll PM you the account name and password now. Unless they reset it you will see the error trade immediately when you execute the problem functions.

                  Thanks,

                  Glen
                  Last edited by demarcog; 03-07-2007, 11:27 AM.
                  Glen Demarco
                  [email protected]

                  Comment


                  • #10
                    Jason,

                    Thought I sent you a PM with account info, although I don't see it in the "sent" messages folder.

                    If you didn't receive it please let me know.
                    Glen Demarco
                    [email protected]

                    Comment


                    • #11
                      Hello Glen,

                      I did receive your PM. However, I cannot use your personal account. I did test this with my simulated account and closePosition() is not creating an order for GBP when there isn't a position. I don't believe that this problem is being generated by EFS.
                      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


                      • #12
                        Originally posted by JasonK
                        Hello Glen,

                        I did receive your PM. However, I cannot use your personal account. I did test this with my simulated account and closePosition() is not creating an order for GBP when there isn't a position. I don't believe that this problem is being generated by EFS.
                        Jason,



                        I opened a GBP A0-FX chart with no studies other then the gbroker_tester.efs. I also opened and connected my Simulated Trading IB account with no positions.

                        I click the closePosition() and closeAllPositions() buttons and 2 seperate sell $850,000 GBP orders got sent and executed in my IB account.

                        I don't know exactly wherer the error is occuring as it not in my code, as I'm not using any here, and also did not enter any commands in my TWS workstation.

                        It appears that somehow the error is being triggered by the closePosition() and closeAllPositions() functions in gbroker_tester.efs but the problem may be caused by something else.

                        I'm attaching all the documentation, including screen shots and code.

                        Do you have any suggestions for resolving this problem?

                        Thanks very much,

                        Glen

                        attached is the gbroker_tester.efs.
                        Attached Files
                        Glen Demarco
                        [email protected]

                        Comment


                        • #13
                          Jason,

                          Attached is the status of the account prior to clicking the closepostion button option with no open postions.
                          Attached Files
                          Glen Demarco
                          [email protected]

                          Comment


                          • #14
                            Jason,

                            Attached status of the account after one click of the gbroker_tester.efs closepistion option. Notice the new short position for $850,000 GBP which I did not send.
                            Attached Files
                            Glen Demarco
                            [email protected]

                            Comment


                            • #15
                              Jason,

                              Here is the status of the account after one more click of the closepostion button on the gbroker_tester.efs.

                              Notice the account is now short $1,700,000 GBP after another order to sell $850,000 GBP from unknown sources.

                              Please advise as to how I can proceed with this problem. I realize you did not experience the error but it's clear that I am and would like to avoid this happening in my or someone else's actual account.

                              Thanks again,

                              Glen
                              Attached Files
                              Glen Demarco
                              [email protected]

                              Comment

                              Working...
                              X