# 日度成交量

獲取美股期權的歷史每日認購/認沽成交量和未平倉量數據。

<CliCommand>
longbridge option volume daily AAPL.US
longbridge option volume daily TSLA.US --count 60
</CliCommand>

## SDK Links

SDK 方法：`option_volume_daily`

- Python: [longbridge.openapi.QuoteContext.option_volume_daily](https://longbridge.github.io/openapi/python/reference_all/#longbridge.openapi.QuoteContext.option_volume_daily)
- Rust: [longbridge::quote::QuoteContext#option_volume_daily](https://longbridge.github.io/openapi/rust/longbridge/quote/struct.QuoteContext.html#method.option_volume_daily)
- Go: [QuoteContext.OptionVolumeDaily](https://pkg.go.dev/github.com/longbridge/openapi-go/quote#QuoteContext.OptionVolumeDaily)
- Node.js: [QuoteContext#optionVolumeDaily](https://longbridge.github.io/openapi/nodejs/classes/QuoteContext.html#optionvolumedaily)
- Java: [QuoteContext.getOptionVolumeDaily](https://longbridge.github.io/openapi/java/com/longbridge/quote/QuoteContext.html#getOptionVolumeDaily)
- C++: [longbridge::quote::QuoteContext::option_volume_daily](https://longbridge.github.io/openapi/cpp/classlongbridge_1_1quote_1_1_quote_context.html)


## Parameters

> **SDK 方法參數。**

| Name      | Type    | Required | Description                                                               |
| --------- | ------- | -------- | ------------------------------------------------------------------------- |
| symbol    | string  | YES      | Underlying US stock symbol, e.g. `AAPL.US`, `TSLA.US`                     |
| timestamp | integer | NO       | Start Unix timestamp (seconds); `0` returns the most recent (default `0`) |
| count     | integer | NO       | Number of trading days to return (default `30`)                           |

> Go SDK 使用 `start` / `end` 日期區間（`time.Time`）而非 `timestamp` / `count`。

## Request Example

<Tabs groupId="request-example">
  <TabItem value="cli" label="CLI" default>

<CliCommand>
longbridge option volume daily AAPL.US
longbridge option volume daily TSLA.US --count 60
</CliCommand>

  </TabItem>
  <TabItem value="python" label="Python">

```python
from longbridge.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_daily("AAPL.US", count=30)
print(resp)
```

  </TabItem>
  <TabItem value="python-async" label="Python (async)">

```python
import asyncio
from longbridge.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_daily("AAPL.US", count=30)
    print(resp)

if __name__ == "__main__":
    asyncio.run(main())
```

  </TabItem>
  <TabItem value="nodejs" label="Node.js">

```javascript
const { Config, QuoteContext, 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 = QuoteContext.new(config)
  const resp = await ctx.optionVolumeDaily('AAPL.US', 0, 30)
  console.log(resp)
}
main().catch(console.error)
```

  </TabItem>
  <TabItem value="java" label="Java">

```java
import com.longbridge.*;
import com.longbridge.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)) {
            OptionVolumeDailyOptions opts = new OptionVolumeDailyOptions();
            opts.symbol = "AAPL.US";
            opts.count = 30;
            var resp = ctx.getOptionVolumeDaily(opts).get();
            System.out.println(resp);
        }
    }
}
```

  </TabItem>
  <TabItem value="rust" label="Rust">

```rust
use std::sync::Arc;
use longbridge::{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_daily("AAPL.US", 0, 30).await?;
    println!("{:?}", resp);
    Ok(())
}
```

  </TabItem>
  <TabItem value="cpp" label="C++">

```cpp
#include <iostream>
#include <longbridge.hpp>

using namespace longbridge;
using namespace longbridge::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_daily("AAPL.US", 0, 30, [](auto resp) {
                if (resp) std::cout << resp->size() << std::endl;
            });
        });
    std::cin.get();
}
```

  </TabItem>
  <TabItem value="go" label="Go">

```go
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/longbridge/openapi-go/config"
	"github.com/longbridge/openapi-go/oauth"
	"github.com/longbridge/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()
	end := time.Now()
	start := end.AddDate(0, 0, -30)
	resp, err := qctx.OptionVolumeDaily(context.Background(), "AAPL.US", start, end)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", resp)
}
```

  </TabItem>
</Tabs>

## Response


### Response Example

```json
{
  "code": 0,
  "message": "success",
  "data": {
    "symbol": "AAPL.US",
    "stats": [
      {
        "symbol": "AAPL.US",
        "date": "2026-05-07",
        "call_volume": 284512,
        "put_volume": 195830,
        "call_open_interest": 1824500,
        "put_open_interest": 1532100,
        "total_volume": 480342,
        "total_open_interest": 3356600,
        "pc_vol": 0.6886,
        "pc_oi": 0.8398
      }
    ]
  }
}
```

### Response Status

| Status | Description | Schema |
| ------ | ----------- | ------ |
| 200    | Success     | [option_volume_daily_rsp](#option_volume_daily_rsp) |
| 400    | Bad request | None   |

## Schemas

### option_volume_daily_rsp

<a id="option_volume_daily_rsp"></a>

| Name                   | Type     | Required | Description                    |
| ---------------------- | -------- | -------- | ------------------------------ |
| symbol                 | string   | true     | Security symbol                |
| stats                  | object[] | true     | Daily volume records           |
| ∟ symbol               | string   | true     | Security symbol                |
| ∟ date                 | string   | true     | Date in `YYYY-MM-DD` format    |
| ∟ call_volume          | int64    | true     | Call volume on that day        |
| ∟ put_volume           | int64    | true     | Put volume on that day         |
| ∟ call_open_interest   | int64    | true     | Call open interest             |
| ∟ put_open_interest    | int64    | true     | Put open interest              |
| ∟ total_volume         | int64    | true     | Total options volume           |
| ∟ total_open_interest  | int64    | true     | Total options open interest    |
| ∟ pc_vol               | float    | true     | Put/call volume ratio          |
| ∟ pc_oi                | float    | true     | Put/call open interest ratio   |