Python Code Example

Discussion in 'Automated Trading' started by newdog, Jan 3, 2016.

  1. newdog

    newdog

    No 2rosy's was just a code. jj1111 do you mind sharing a small piece of code doing what I intend to achieve. I feel I am working in a totally wrong direction coming from mostly Matlab coding.
     
    #11     Jan 7, 2016
  2. 2rosy

    2rosy

    i updated the github gist to display accountUpdates

    gist.github.com/audubon/b14eeda1c2cad704b333
     
    #12     Jan 7, 2016
  3. I don't know ibpy works, but in swigibpy you'd need to do this:

    Instead of:

    Code:
        
    def updateAccountValue(self, key,  value,  currency,  accountName):
            showmessage('updateAccountValue', vars())
    
    you'd have

    Code:
        
    updateAccountValue(self, key,  value,  currency,  accountName):
            self._store_account_value.append(vars())
    
    then

    Code:
        
    import time
    setattr(tws_conn, "_store_account_value", [])
    tws_conn.reqAccountUpdates(True,'DU15211') 
    
    ## after waiting for a while - use the accountDownloadEnd to do this properly
    time.sleep(30)
    print tws_conn._store_account_value
    
    GAT
     
    #13     Jan 7, 2016
  4. newdog

    newdog

    Is this really supposed to work as you have coded ? I get an empty array on the print statement.
     
    #14     Jan 7, 2016
  5. newdog

    newdog

    I was able to make your code work with some modification and got an education in abstract classes in the process. I almost forgot C++ rules.

    But I have two questions regarding that:
    (1) I am still not able to save the position information in a variable
    (2) reqAccountUpdates seems updates account information every 3 min (based on a google group thread). How do I make it update only once and stop.
     
    #15     Jan 7, 2016
  6. Like I said I don't use Ibpy, so this was a punt. If you're willing to switch to swigibpy then you can, as I said, get a complete working example from here http://qoppac.blogspot.co.uk/2014/05/getting-accounting-data-out-of.html. That also means if you have any other problems then I can probably help with them.

    Otherwise, you're on your own, unless there is someone willing and able to get an ibpy version working.

    GAT
     
    #16     Jan 7, 2016
  7. newdog

    newdog

    I would have used swigibipy but I dont have permission to install it on the machine I am working on.

    Is there a way to implement swigibipy without installation ?
     
    #17     Jan 7, 2016
  8. Not as far as I know. Weird you can install ibpy but not swgibpy

    GAT
     
    #18     Jan 7, 2016
  9. newdog

    newdog

    No I didn't install IbPy. I am calling it using "import"
     
    #19     Jan 7, 2016
  10. For your second question
    tws_conn.reqAccountUpdates(False,'DU15211')

    GAT
     
    #20     Jan 8, 2016