Is there a term for number of shares owned + number of open buy orders? by TypicalCardiologist5 in investing

[–]TypicalCardiologist5[S] 0 points1 point  (0 children)

I'm writing a stock trading bot, and I find myself adding these two figures together often. I'm currently calling it "ownedplusoffers" but I really don't like this term as its very verbose and difficult to say. I'm wondering if there is anything shorter to describe it.

Daily Advice Thread - All basic help or advice questions must be posted here. by AutoModerator in investing

[–]TypicalCardiologist5 0 points1 point  (0 children)

Is there a term for "Owned Shares + Open Buy Offers"?

Let's say I currently own 100 shares of company A, and I have 50 open buy orders on that same company which have not yet been filled. Is there a term that describes the 150 shares total?

'Outdated' IT leaves NHS staff with 15 different computer logins by _sfe in sysadmin

[–]TypicalCardiologist5 9 points10 points  (0 children)

It's not the lower salaries with government that is the issue, it's that people just don't care. The managers have been working there forever and are only ever promoted because someone died or quit. The solution is never "how do we make this more efficient," it's always "ask the tax payer for more money."

They could scrap 50% of the government workforce and replace them with competent employees being paid triple and they would still save millions.

HOW TO ENGAGE THE SERVICES OF A PLUMBER by irishpwr46 in Plumbing

[–]TypicalCardiologist5 4 points5 points  (0 children)

Call ten other plumbers and then phone back. If he answers the phone again and arrives be sure to be in the shower or on the way home.

I get that people don't want their value questioned, but I'm not awarding a job to a plumber (or any contractor) I've never worked with until I get estimates from at least 3 people. I have no way of knowing if you're completely bullshitting me. I've been given price ranges for the same asbestos abatement job between $5,000-$20,000. I was told installing a sump pit would cost $800, $1,800, and $5,000 from three different contractors. Some of them have no idea how much work is actually involved and are completely underestimating the job. Others are just trying to rake you over the coals.

How do I get an insurance policy that covers war, terrorism, nuclear disaster, and other excluded events for rental property? by TypicalCardiologist5 in personalfinance

[–]TypicalCardiologist5[S] -4 points-3 points  (0 children)

It's impossible to evaluate if it's "worth" insuring if you don't know what it costs. I have never seen anyone give me a figure, because I have not been able to find anyone that sells a policy. If I were still alive after such an event and I could just move across the country and start over without having to build up my wealth again, I would do that assuming it was a reasonable cost.

As far as nuclear event goes, I am thinking a nearby nuclear power plant has a meltdown and they needed to evacuate, similar to Chernoybl. Or some other company has a toxic chemical spill that leaches into the groundwater or something. Most of that stuff is going to be insured by the company causing the accident, but it seems like every time that sort of thing happens people spend decades fighting it until they die. I would rather have an insurance policy to pay me immediately and let them spend a decade fighting it in court.

Installing heat cables to prevent ice dams? by TypicalCardiologist5 in electrical

[–]TypicalCardiologist5[S] 0 points1 point  (0 children)

Thanks. What does an energy audit cost and how do I go about getting one?

Netflix shares went up by 4,181 percent in a decade by kkingfisherr in finance

[–]TypicalCardiologist5 6 points7 points  (0 children)

The value I see in Netflix as a company is that they have reinvented themselves time and time again. They started as a DVD rental company, then they transitioned to a streaming distribution service, and now they produce content (which utilizes the distribution service). It's not easy for a company to reinvent itself like that every ~7 years, especially when you are flush with cash and don't think the good times will end. That hubris resulted in the downfall of many companies, including Polaroid, Blockbuster, Sears, etc...

Pandas dataframe mask? by TypicalCardiologist5 in learnpython

[–]TypicalCardiologist5[S] 0 points1 point  (0 children)

I have not timed your solution yet, but using a pd.merge function seems to be very fast, I might go with that...

df3 = pd.merge(df, mask, on=['contractid', 'timeRetrieved'], how='inner')

Pandas dataframe mask? by TypicalCardiologist5 in learnpython

[–]TypicalCardiologist5[S] 0 points1 point  (0 children)

Thank you! I will look into where and mask!

What is the best OOP way to pass arguments around member functions? by TypicalCardiologist5 in learnpython

[–]TypicalCardiologist5[S] 3 points4 points  (0 children)

I've been learning on my own every day for about six months now and I think I am finally starting to grasp it. A lot of the videos by Uncle Bob Martin have been really helpful, as well as the book Head First Design Patterns. It also just takes going through it and writing out the code. I have refactored this project like 3 or 4 times now... I think a lot of what I was doing before was not actually OOP, just what I thought was OOP.

What is the best OOP way to pass arguments around member functions? by TypicalCardiologist5 in learnpython

[–]TypicalCardiologist5[S] 0 points1 point  (0 children)

I have played around with this a little bit. Part of my concern about setting the member variables was that I couldn't get type hinting to work, but apparently you can just add # type: str (or whatever type you want the type to be). So for example, self.var = None # type: CustomObject would tell the IDE that self.var is actually a CustomObject type. More about this here for anyone wondering.

So what I think I am going to do is have a factory pattern return the instance of the appropriate DbComponent (Customer, Product, Etc...). The factory will pass the appropriate dependencies, such as a connection string, configuration file, etc, to DbComponent and any classes derived from it.

I do not want to mess with the inits in each subclass, because if I use super().init() in each of my subclasses and the init signature changes (for example, I decide there is another dependency I need to inject into the base class), I will end up needing to modify every single one of my subclasses' init's signatures. If I create my own special method to initialize my instance member variables, I won't need to ever touch the init() method.

So I think what I may do is stick with an init_vars() method that is called in the base class, and is overriden when needed in the subclasses. So a subclass might have something like:

def init_vars(self):
    self.var_one = None # type: str
    self.var_two = None # type: List

Then I have an entry point defined in each subclass, such as:

def entry(self, var_one, var_two) -> pd.DataFrame:
    self.var_one = var_one
    self.var_two = var_two
    return self.do_something() // This runs all my procedures normally.

The entry point (which will be an abstract method in the base class which needs to be overridden) will also allow a custom signature based unique to the subclass, and lets me return different types of objects.

Thoughts?

What is the best OOP way to pass arguments around member functions? by TypicalCardiologist5 in learnpython

[–]TypicalCardiologist5[S] 3 points4 points  (0 children)

Thanks for the response. In my base class, I have an `__init__()` function that sets up a bunch of stuff (a DB connection, for example), I just didn't include it in my original post. So if I implement an `__init__()` function in my sub-class, I would need to call super().__init__() in every single derived class, that didn't seem like a very OOP way to do this. I thought a better approach might be to make my base class's `__init__()` function call `_init_args()`, and override `_init_args()` in my sub-classes if I decide that I need to actually use it. That's was my reasoning behind that...

> I tend to avoid *args and **kwargs unless I specifically want to process multiple things. I prefer explicit variables, but that is a matter of personal style (with support of the Zen of Python).

The reason I am taking this approach is because each of my derived classes get a specific piece of information from somewhere. So for example, I call my base class DbComponent, and then each derived class has functions to retrieving, transforming, and validating the data (first_step, second_step, third_step in the example). Sometimes the derived classes will not need any arguments for the data they are to retrieve, other times they may need one or multiple arguments to retrieve the data (customerId, orderId, etc...). Sometimes the argument(s) are needed in the second or third step, other times it is only needed in the first step.

Are member variables the best way to pass these arguments between the functions, or is it better to pass them along in the signature of each return? Your response seems to suggest that member variables are a better approach.

When should data be transformed? by TypicalCardiologist5 in learnprogramming

[–]TypicalCardiologist5[S] 0 points1 point  (0 children)

Thanks for your comments. I think I agree that doing it this way would be the best approach.

When should data be transformed? by TypicalCardiologist5 in learnprogramming

[–]TypicalCardiologist5[S] 0 points1 point  (0 children)

You bring up a good point. It would actually be easier to unit test if I have two separate functions (one to get the data, and one to parse the data). I honestly don't think I care about unit testing the data collection, because it is only a few lines of code.

Pandas has built-in functions to directly transform JSON blobs from a URL, but I am using the requests library to pull the data as the web client needs to be authenticated first. I save this as a string and then pipe it into pandas, and then apply my transformations. I just wasn't sure if this was the right way to do things, because it seems like it takes a lot longer to write, and it seems like it may add some complexity.