dBCooper2/dBI

Refactor Classes and Files

Closed this issue · 3 comments

Once you have a grasp of TabPy, design to fit around that and refactor

Figure out how to structure your classes and then change the format. Some ideas I have now:

  • Stock() is a superclass with Stock_nb() and the current Stock() becoming subclasses
  • new Stock() has params for viewing data(and can choose to show cash amounts in its constructor), current Stock() becomes Stock_a() for analysis and contains more parameters
  • Decide on Whether or not to use CUSIP's as a parameter
  • Decide on what Parameters in each class need to be kept and which ones should be discarded.

Ok, I took some time to think about the Structure from the perspective of gathering the Data.

The program wants to analyze portfolios or a single stock, so...

  • Portfolios should be the 'parent' object that everything else extends from
  • Portfolios are either from the TDA user's account or a simulated, made-up portfolio. These made-up portfolios will not have access to position data, therefore positions should be nested within Stocks, which is stored as a list in the portfolio.
  • Stock Objects contain an Instrument, a HistData Object, and a Position Object ONLY IF Portfolio Analysis is being performed, this may become another Position object like 'class Position_Sim' if the params need to change

Ignore the old description, this is what I'm going with for now

on second thought, stock and position will be detached from each other(but still nested under portfolio) and can be linked together via their symbol, so portfolios will contain a list of positions and a list of stocks, I think I will change Stock to Stock_Data to avoid confusion

Ok I think I have a final format to go with:

  • Portfolios contain a dataframe with rows of stock symbols and columns of both position and instrument data. This contains every stock in the portfolio, real or simulated.
  • Price Histories are a separate Object that is only called if you need the price data, and only contain 1 stock's data

Additionally:

  • functions.py should only general helper methods for connecting to API's and other Programs. Portfolios and Price Histories should have their own to_csv and to_excel functions, and the only functionality I need to connect to functions right now is a connection to TabPy(Still TBD)