background

The stock is trapped, so I hope that while writing the code, it is very convenient to take a look at the situation of the stock, and turn the grief and anger into strength, in order to motivate themselves to write more hard code.

Currently, I’m basically using VScode to type code. Therefore, it is a good choice to develop a plug-in that can watch stocks in real time.

Development tutorial

The official documentation

VScode official has a relatively complete documentation, which allows developers to quickly develop a VScode plug-in, which will not be described here.

Implementation effect

In the VScode extension, search for “stock watch” and try it as soon as you install it.

View the source code

configuration

// Configure the stock symbol to monitor"stock-watch.stocks": [
    "000001"], // Set the interval between polling requests for the latest data, in milliseconds"stock-watch.updateInterval": 10000
Copy the code

After configuring the stocks to watch, you can see real-time information about the stocks on the statusBar:

The key point

1. Data sources

This plugin USES the baidu stock API:gupiao.baidu.com/api/rails/s…

2. VScode related API

  • Access to configuration: vscode. Workspace. GetConfiguration ()
  • Create statusBarItem: vscode. Window. CreateStatusBarItem ()

3. Configure and start time

In package.json, set

"activationEvents": [
    "*"// start the plugin when vscode starts.Copy the code

Configure the configuration required for this plug-in:

"contributes": {
        "configuration": {
            "properties": {
                "stock-watch.stocks": {
                    "type": "array"."default": ["000001"]."description": "Assign stock symbol to monitor"
                },
                "stock-watch.updateInterval": {
                    "type": "number"."default": 10000,
                    "description": "Configure the interval between polling requests for the latest data, in milliseconds."}}}}Copy the code

Afterword.

The above realized a simple stock plug-in, only the function of information display, if there is time, you can add the alarm function of stock rise and fall.

With this in mind, you can develop some fun plug-ins based on your personal interests. For example, follow NBA scores in real time.

Above individual toss record, welcome to correct.