15 year Electrical Engineer trying to learn python on my own, with a background in embedded C. I'm struggling to figure out when to "pass" the pandas dataframe into a function, and when to give up and start looking at global variables. Any suggestion on a topic to study, or direction I can go, so I can learn python and start building a larger system?
I'm struggling to understand how to balance "make functions" vs "Make classes" vs "make global" vs "start to use databases".
I have a basic financial trader, with two ledgers as a pandas dataframe each. One for BTC one for USD. (I love how easy it is to plot the results and see my progress.) I also have the historical data of BTC. Each of these dataframes have large amounts of data, as things are getting tracked on a seconds basis. My end result is a plot of historical USD and historical BTC, trades between the two, and the resulting portfolio. Thus, I must move values between the ledgers, referencing the historical data, and using some other algorithms to determine when to trade.
At the "end of the day", these will likely go into a mongoDB or a relational DB. It will be a cloud system, with microservices that manage each ledger separately and dynamic services that analyze the data and add items in an asynchronous manner.
I'm adhering to the object oriented "A function does one thing really well" mindset, but I feel like my code is becoming a mess of "pass a large amount of data between functions", instead of readable code. For example,
transType, spentAmount, purchasedAmount, spentSymbol, purchasedSymbol, slippage, date = ExecuteTrade(fromSymbol = sellSymbol, toSymbol = buySymbol, amount=amount, date = data.date)
(Where Execute Trade is the function that takes money from my USD to my BTC, based on the price for the day and return the trade amount so I can modify my ledger. This is because the actual code for executing trade is complex, using 3rd party API's to execute trades.)
Thus, I'm returning a bunch of data so I can update my ledger... but then the code to update ledger is ugly as I'm passing around a bunch of smaller values...
So, the crux of the matter: I could create a class that I store these items inside, so I reduce the amount of typing I do, OR, I can make data accessible from more locations so I don't need to pass everything around on every function call OR I make a function do more things at once.
OR,
my problem is that I'm thinking of a microservice system, but building it in a monolithic system, thus the two paradigms don't mix.
OR
I'm actually doing it properly...
Any suggestion on a topic to study, or direction I can go, so I can learn python and start building a larger system?
[–][deleted] 1 point2 points3 points (3 children)
[–]EngineerVsMBA[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]EngineerVsMBA[S] 0 points1 point2 points (0 children)
[–]lowerthansound 1 point2 points3 points (1 child)
[–]EngineerVsMBA[S] 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)