1) Magics are just simple function not difficult to define, you could have a look here Customizing IPython - Config.ipynb
if I remember correctly. still I'm not sure it is worth definig a magic in your case.
2) Most of the time, no. You have to import the module as we need live code to know where it is defined.
In general, finding the code of a function is not always super easy. On python 3 you can always access the code object, but most of the time, as soon as you have things like decorated function, or dynamically generated function, it becomes difficult. I suppose you could also inspire from psource
/pinfo2
and have them return info instead of paging it.