FreeLeek: Extensible Financial Data-Push Backend

2 minute read

Published:

Recently I reconstructed my push financial message push robot, previously written in PHP, you can get some concerned financial news and fund, stock data, and push to subscribers through WeChat public account, this project as a demonstration of the use of Tushare Pro big data open community to provide news, with everyone likes to see Python WeChat public account template message interface encapsulation, Implemented a message surface timing push program ~ welcome leek friends to pay attention to this project and develop based on this platform o(* ̄▽ ̄*) ブ

0x00 Project Website

https://gitee.com/qian_zehao/free-leek

0x01 Introduction and Features

  • FreeLeek is an open-source server-side framework that unifies the back-end services of the Free Leek Foundation by using Python Flask, Tushare Pro, and Akshare to transfer financial data to the application backend and WeChat platform.
  • FreeLeek can automatically push financial news to the WeChat public platform to which users subscribe.
  • Function expansion: By editing Python scripts and docker files, you can quickly start multiple services, such as quantitative trading algorithms, position management systems, etc., and you can easily customize more functions.

For the encapsulation of WeChat template information

The FreeLeekWeChat() class is defined in the src/wx_send_msg.py file, instantiates the class where it needs to be called, and passes in appid, secret, openid, template_id, template_data 5 parameters, and implements the information by executing post_data(). There is a detailed document in the project documentation explaining how to obtain the 5 parameters:

Functional extensions through Docker

Custom functions can be added directly by writing Python scripts and dockerfile files, filling in the container name, local port number, etc. in the docker-compose.yaml file in the root directory, and directly running sudo docker-compose up -d in the terminal without affecting the operation of other functions.

Run the project

It runs the sample function in the warehouse and regularly pushes financial news to WeChat, but leek friends can customize the function according to their needs!

Step 1 clone the project to the local computer

git clone https://gitee.com/qian_zehao/free-leek.git

Step 2 Modify the configuration file & message template (config.yaml and message_template.json)

wx_interface:
  appid: "<server appid>"
  secret: "<server secret>"
  openid: "<user wechat id>"
  template_id: "<user template_id>"

tushare_tocken: "<Your tushare token>"

time_interval: <set wx_msg_send interval>

Make sure that the json variables in message_template.json are consistent with those in the WeChat template message.

{
    "title0": {
        "value": "FreeLeek Unit Test 0",
        "color": "#173177"
    },
    "content0": {
        "value": "This is freeleek quant trade foundation, welcome your coming!"
    },
    "title1": {
        "value": "FreeLeek Unit Test 1",
        "color": "#173177"
    },
    "content1": {
        "value": "This is freeleek quant trade foundation, welcome your coming!"
    }
}

Step 3 Run this project

Execute the following command in the root directory of the project, it’s as simple as that~

# build images
$ sudo docker-compose build
# Run
$ sudo docker-compose up -d
# stop & delete
$ sudo docker-compose down