tags: Python Web Flask MongoDB
I was working on a quantitative investment trading platform before, and my main business was divided into backtesting and simulated trading.
The target is fund managers or private equity fund managers.
The use of specific products is to use transaction data of any year, try to run some backtests of trading strategies, and after you feel that the income is suitable, put it in a simulated transaction for simulation. If the income is still good, it may be adopted by the fund manager. In the real portfolio.
Of course, the above is an overview of my use of the product. In practice, fund managers may have more practical methods.
The project is separated from the front and the back. The front-end is developed by the front-end team, using React, the back-end is developed by us, and the back-end uses Flask, and only does business logic and provides API interfaces. For permissions and authentication functions, there are middle-level The cloud platform does not need to do this part of the content.
In addition, because of the storage of transaction records, it is possible to store information in a way of storing multiple dicts in a list. If traditional relational data is used, there may be subsequent adjustments to the data structure, which will be very inconvenient to operate, so Schemaless MongoDB is used to store all the information in the system and make it persistent. For the frequently changed on the disk, such as position information, it will be stored in Redis and synchronized with MongoDB on a regular basis. Redis only enables RDB persistence. Use pymongo to create a connection Pool, encapsulate API, and perform some operations of MongoDB.
So in fact, for the MVC web framework, it is considered to be disassembled and used in this project.Here is more of the C part of MVC, and the M part is not as strong as the relational data.Schema association.
For deployment, deploy in the form of pods in k8s, and Rancher does some visual management.
For the personnel, there are 3 back-end developers, and 2 people divide the development of each line of labor. The other is the developer at the beginning of the project, who has a comprehensive understanding of all business lines of the entire system. The first two people's code reviews need to pass the third Only with the approval of people can they be merged into the branch.
Test 1-2 people, because different lines of functions will be tested in parallel, so multiple testers may be connected at the same time.
1-2 product managers, consistent with the test, may be able to meet multiple requirements at the same time, and the requirements come from multiple product managers
There are 1-2 front-end people. Generally speaking, the development of this system does not need to be connected to the front-end, because it basically adds new functions to the original interface, only the output basis, the previous one can be used, unless there is a new demand and a new interface needs to be opened. There will be some front-end and back-end docking work.

The code structure in the entire project does not feel good personally, but it is considered to be a serious problem left over from history, and the test cases are outdated, which makes it difficult to change the structure of the previous code without causing a change in functionality.
The coupling between multiple trading varieties will be very serious, and it will occur frequently. Modifying the problem of one symbol causes problems with another symbol. It also makes troubleshooting errors very time-consuming. It may take a week in many cases. Only fix bugs.
What can be improved: At that time, in this set of codes, there were many personalized or customized project requirements, that is, the behavior of an interface in the face of different projects is not consistent. Therefore, each interface is caused The business in China is very complicated.
I personally feel that if an intermediate layer can be dismantled to distinguish between the calls of different projects or products, and build their own different return information, and in the current project, it may be more convenient to develop if only all available information is returned. Because the system The data processing in, and the information displayed by the real business are separated. So in fact, the MVC design pattern is not implemented well.
In the front page development, use the Layui's built-in module data table (TABLE) to show the data list, use it.Templet - Custom Column Template Function, code show as below: I have written it for Tem...
The databases used in Flask are generally managed using the Flask-SQLAlchemy extension. Install Flask-SQLAlchemy pycharm creates a new Flask project. Then File-Settings. Then select Project Interprete...
First come to the conclusion: Be sure to remember to use @functools.wraps(func) when customizing the python decorator This bug was encountered in a flask app development. code show as below: After reg...
1.Pipenv Profile Pipenv pip is based on the Python package management tools, and its usage is very similar to pip, pip can be seen as an enhanced version of it appears to solve the drawbacks of the ol...
Upset review One year ago studied the development of desktop applications with PywebView:Python Develops Desktop Apps with PywebVIEW At that time, it was just a taste, there was no complete implementa...
Vue3+TypeScript+Element-Plus+Flask development record 1. Cross -domain Flask back end solution /pip install flask-cors Global configuration use @cross_origin Configure one -way route Configuration par...
Python development is getting more and more popular. As a rookie, you should also learn it. It feels okay. Record it for easy reference. No matter what development you do, it must first be the install...
Flask with http Basic knowledge Professional noun Request response cycle Flask web workflow HTTP request URL Request packet REQUEST object Process request Routing match Set monitoring method URL proce...
Flask learning notes (1) ——Hello Flask Hello World Run settings Flask extension (Extension) Configuration variable URL with endpoints Template with sta...
Install python https://www.python.org/downloads/ Download and install Using a virtual environment Virtualenv is a Python tool that you can use to create a standalone Python environment. Execute the fo...