# OOP with conn.on

**URL:** <https://forum.alpaca.markets/t/oop-with-conn-on/3624>\
**Category:** Alpaca Questions\
**Created:** [December 14, 2020, 6:41pm UTC](https://forum.alpaca.markets/t/oop-with-conn-on/3624 "2020-12-14T18:41:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![X\_Hilbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/x_hilbe/32/1229_2.png) [@X\_Hilbe](https://forum.alpaca.markets/u/X_Hilbe)\
**Post date:** [December 14, 2020, 6:41pm UTC](https://forum.alpaca.markets/t/oop-with-conn-on/3624/1 "2020-12-14T18:41:50Z")

</div>

Hi,

I have a python script that calls conn.run(“trade\_updates”). I also have the following async function to receive the trade updates…

@conn.on(r’^trade\_updates$’)  
async def on\_msg(conn, channel, positions\_data):

However, inside the async function I need to access an attribute (using the word self), so I need a function like this…

@conn.on(r’^trade\_updates$’)  
async def on\_msg(_self_, conn, channel, positions\_data):

However, when I run the function above, I get the error message: missing 1 required positional argument. Do you know how I can fix this?

Short Version: How do I pass self into the following function without causing an argument error?

@conn.on(r’^trade\_updates$’)  
async def on\_msg(SELF, conn, channel, positions\_data):

I really appreciate any help you can provide!
