期權成交量
獲取今日認購/認沽期權成交量快照,包含總量、未平倉量和認沽/認購比率。
SDK Links
Python | longport.openapi.QuoteContext.option_volume |
Rust | longport::quote::QuoteContext#option_volume |
Go | QuoteContext.OptionVolume |
Node.js | QuoteContext#optionVolume |
Parameters
SDK 方法參數。
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | string | YES | US stock symbol, e.g. AAPL.US, TSLA.US |
Request Example
python
from longport.openapi import QuoteContext, Config, OAuthBuilder
oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = QuoteContext(config)
resp = ctx.option_volume("AAPL.US")
print(resp)python
import asyncio
from longport.openapi import AsyncQuoteContext, 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 = AsyncQuoteContext.create(config)
resp = await ctx.option_volume("AAPL.US")
print(resp)
if __name__ == "__main__":
asyncio.run(main())javascript
const { Config, QuoteContext, OAuth } = require('longport')
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 = QuoteContext.new(config)
const resp = await ctx.optionVolume('AAPL.US')
console.log(resp)
}
main().catch(console.error)java
import com.longport.*;
import com.longport.quote.*;
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);
QuoteContext ctx = QuoteContext.create(config)) {
var resp = ctx.getOptionVolume("AAPL.US").get();
System.out.println(resp);
}
}
}rust
use std::sync::Arc;
use longport::{oauth::OAuthBuilder, quote::QuoteContext, 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, _) = QuoteContext::new(config);
let resp = ctx.option_volume("AAPL.US").await?;
println!("{:?}", resp);
Ok(())
}cpp
#include <iostream>
#include <longport.hpp>
using namespace longport;
using namespace longport::quote;
int main() {
OAuthBuilder("your-client-id").build(
[](const std::string& url) { std::cout << "Open: " << url << std::endl; },
[](auto res) {
if (!res) return;
Config config = Config::from_oauth(*res);
QuoteContext ctx = QuoteContext::create(config);
ctx.option_volume("AAPL.US", [](auto resp) {
if (resp) std::cout << "OK" << std::endl;
});
});
std::cin.get();
}go
package main
import (
"context"
"fmt"
"log"
"github.com/longportapp/openapi-go/config"
"github.com/longportapp/openapi-go/oauth"
"github.com/longportapp/openapi-go/quote"
)
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)
}
qctx, err := quote.NewFromCfg(conf)
if err != nil {
log.Fatal(err)
}
defer qctx.Close()
resp, err := qctx.OptionVolume(context.Background(), "AAPL.US")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", resp)
}Response
Response Example
json
{
"code": 0,
"message": "success",
"data": {
"symbol": "AAPL.US",
"call_volume": 284512,
"put_volume": 195830,
"call_open_interest": 1824500,
"put_open_interest": 1532100,
"pc_vol": "0.6886",
"pc_oi": "0.8398"
}
}Response Status
| Status | Description | Schema |
|---|---|---|
| 200 | Success | option_volume_rsp |
| 400 | Bad request | None |
Schemas
option_volume_rsp
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | string | true | Security symbol |
| call_volume | int64 | true | Total call volume for today |
| put_volume | int64 | true | Total put volume for today |
| call_open_interest | int64 | true | Total call open interest |
| put_open_interest | int64 | true | Total put open interest |
| pc_vol | string | true | Put/call volume ratio |
| pc_oi | string | true | Put/call open interest ratio |