检查定投支持
Longbridge US 账户不支持
此方法需要 AP 数据中心账户(香港/新加坡)。美股数据中心账户将收到区域限制错误。AP 账户可操作任意标的,包括美股。
检查指定标的是否支持定投。
SDK Links
Python |
Rust |
Go |
Node.js |
Java |
C++ |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| symbols | string[] | 是 | 待检查的标的代码列表 |
Request Example
from longbridge.openapi import DCAContext, Config, OAuthBuilder
oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = DCAContext(config)
resp = ctx.check_support(["AAPL.US", "700.HK"])
print(resp)import asyncio
from longbridge.openapi import AsyncDCAContext, 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 = AsyncDCAContext.create(config)
resp = await ctx.check_support(["AAPL.US", "700.HK"])
print(resp)
if __name__ == "__main__":
asyncio.run(main())const { Config, DCAContext, 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 = DCAContext.new(config)
const resp = await ctx.checkSupport(['AAPL.US', '700.HK'])
console.log(resp)
}
main().catch(console.error)import com.longbridge.*;
import com.longbridge.dca.*;
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);
DCAContext ctx = DCAContext.create(config)) {
var resp = ctx.checkSupport(Arrays.asList("AAPL.US", "700.HK")).get();
System.out.println(resp);
}
}
}use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, dca::DCAContext, 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 = DCAContext::new(config);
let resp = ctx.check_support(vec!["AAPL.US".into(), "700.HK".into()]).await?;
println!("{:?}", resp);
Ok(())
}package main
import (
"context"
"fmt"
"log"
"github.com/longbridge/openapi-go/config"
"github.com/longbridge/openapi-go/oauth"
"github.com/longbridge/openapi-go/dca"
)
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 := dca.NewFromCfg(conf)
if err != nil {
log.Fatal(err)
}
defer c.Close()
resp, err := c.CheckSupport(context.Background(), []string{"AAPL.US", "700.HK"})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", resp)
}Response
Response Example
{
"code": 0,
"message": "success",
"data": {
"infos": [
{
"symbol": "AAPL.US",
"support_regular_saving": true
},
{
"symbol": "700.HK",
"support_regular_saving": false
}
]
}
}
Response Status
| Status | Description | Schema |
|---|---|---|
| 200 | 成功 | DcaSupportListResponse |
| 400 | 请求错误 | None |
Schemas
DcaSupportListResponse
| Name | Type | Required | Description |
|---|---|---|---|
| infos | object[] | true | 定投支持情况列表, |
| ∟ symbol | string | true | 证券代码 |
| ∟ support_regular_saving | boolean | true | 是否支持定投 |