Longbridge Developers
Get Started

Add Securities to Sharelist

Add one or more securities to a sharelist.

>_ CLI
longbridge sharelist add 123 TSLA.US AAPL.US

Parameters

SDK method parameters.

NameTypeRequiredDescription
idintegerYESSharelist ID
symbolsstring[]YESSecurity symbols to add

Request Example

from longbridge.openapi import SharelistContext, Config, OAuthBuilder

oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = SharelistContext(config)

ctx.add_securities(123, ["TSLA.US", "AAPL.US"])
import asyncio
from longbridge.openapi import AsyncSharelistContext, Config, OAuthBuilder

async def main() -> None:
    oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url))
    config = Config.from_oauth(oauth)
    ctx = AsyncSharelistContext.create(config)

    await ctx.add_securities(123, ["TSLA.US", "AAPL.US"])

if __name__ == "__main__":
    asyncio.run(main())
const { Config, SharelistContext, OAuth } = require('longbridge')

async function main() {
  const oauth = await OAuth.build('your-client-id', (_, url) => {
    console.log('Open this URL to authorize: ' + url)
  })
  const config = Config.fromOAuth(oauth)
  const ctx = SharelistContext.new(config)
  await ctx.addSecurities(123, ['TSLA.US', 'AAPL.US'])
}
main().catch(console.error)
import com.longbridge.*;
import com.longbridge.sharelist.*;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws Exception {
        try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get();
             Config config = Config.fromOAuth(oauth);
             SharelistContext ctx = SharelistContext.create(config)) {
            ctx.addSecurities(123, Arrays.asList("TSLA.US", "AAPL.US")).get();
        }
    }
}
use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, sharelist::SharelistContext, Config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let oauth = OAuthBuilder::new("your-client-id").build(|url| println!("Open: {url}")).await?;
    let config = Arc::new(Config::from_oauth(oauth));
    let ctx = SharelistContext::new(config);
    ctx.add_securities(123, vec!["TSLA.US".into(), "AAPL.US".into()]).await?;
    Ok(())
}
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/longbridge/openapi-go/config"
	"github.com/longbridge/openapi-go/oauth"
	"github.com/longbridge/openapi-go/sharelist"
)

func main() {
	o := oauth.New("your-client-id").
		OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
	if err := o.Build(context.Background()); err != nil {
		log.Fatal(err)
	}
	conf, err := config.New(config.WithOAuthClient(o))
	if err != nil {
		log.Fatal(err)
	}
	c, err := sharelist.NewFromCfg(conf)
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()
	if err := c.AddSecurities(context.Background(), 123, []string{"TSLA.US", "AAPL.US"}); err != nil {
		log.Fatal(err)
	}
}

Response

Response Example

{
  "code": 0,
  "message": "success"
}

Response Status

StatusDescriptionSchema
200SuccessNone
400Bad requestNone