openapi-sdk icon indicating copy to clipboard operation
openapi-sdk copied to clipboard

如何拉取期权的信息?

Open Endt4sk opened this issue 1 year ago • 5 comments

void on_quote_context_created(const struct lb_async_result_t* res)
{
	if (res->error) {
		printf("failed to create quote context: %s\n",
			lb_error_message(res->error));
		return;
	}

	*((const lb_quote_context_t**)res->userdata) = (const lb_quote_context_t*)res->ctx;

	const char* symbols[] = { "NVDA240301C800000.US" };
	lb_quote_context_quote((const struct lb_quote_context_t*)res->ctx, symbols, 1 on_quote, NULL);
}

拉取不到期权的信息。

Endt4sk avatar Feb 25 '24 03:02 Endt4sk

你调用这个是个股行情接口,期权行情是另外一个函数:

  • https://longportapp.github.io/openapi-sdk/cpp/classlongport_1_1quote_1_1_quote_context.html#a0671aa3a2b863d3e8b02e6501d8c0aa2
  • https://open.longportapp.com/docs/quote/pull/option-quote

huacnlee avatar Feb 26 '24 01:02 huacnlee

@huacnlee

你调用这个是个股行情接口,期权行情是另外一个函数:

  • https://longportapp.github.io/openapi-sdk/cpp/classlongport_1_1quote_1_1_quote_context.html#a0671aa3a2b863d3e8b02e6501d8c0aa2
  • https://open.longportapp.com/docs/quote/pull/option-quote

谢谢,那用那个API可以获取期权的Gamma Delta这些数值?

Endt4sk avatar Feb 26 '24 07:02 Endt4sk

https://open.longportapp.com/docs/quote/pull/calc-index

用这个接口

sunli829 avatar Mar 15 '24 10:03 sunli829

@sunli829 感谢回复,我使用的C语言,用下面的方式获取的期权信息,怎么数据都是错的?除了收盘价行权价,其他的IV DELTA这些数据都对不上:

void OnSecurityCalcIndexCreated(const struct lb_async_result_t* res)
{
	if (res->error)
	{
		printf("failed to create quote context: %s\n", lb_error_message(res->error));
		return;
	}

	*((const lb_quote_context_t**)res->userdata) = (const lb_quote_context_t*)res->ctx;

	std::vector<const char*> symbols;
	symbols.push_back("NVDA240419C900000.US");
	lb_quote_context_calc_indexes((const struct lb_quote_context_t*)res->ctx, symbols.data(), symbols.size(), indexes, indexes_size, [](auto result)
		{
			if (!result)
			{
				//auto msg = lb_error_message(result->error);
				printf("failed to get quote!\n");
				return;
			}

			lb_security_calc_index_t* data = (lb_security_calc_index_t*)result->data;
			printf("Symbol: %s\n", data->symbol);
			printf("LastDone: %f\n", lb_decimal_to_double(data->last_done));
			printf("StrikePrice: %f\n", lb_decimal_to_double(data->strike_price));
			printf("Implied Volatility: %f\n", *data->implied_volatility);
			printf("Delta: %f\n", *data->delta);
			printf("Gamma: %f\n", *data->gamma);
			printf("Theta: %f\n", *data->theta);
			printf("Vega: %f\n", *data->vega);

		}, NULL);
}

Screenshot 2024-03-20 143258

Endt4sk avatar Mar 20 '24 06:03 Endt4sk

目前过期的期权行情只会保留 7 天,服务端返回的数据没有这个标的,您可以检查一下本地代码,打印的数据是哪里来的。

QFCG avatar May 31 '24 10:05 QFCG

Hi, 我们正在努力清理问题,并关闭可能不再相关的旧问题。如果你依然还有类似的问题,请通过评论此问题让我们知道,我们会重新开启。如果您无法重现,请随时自行关闭问题,我们也有定期任务清理 14 天之前的旧问题。 We are actively cleaning up issues and closing those that may no longer be relevant. If you still have similar issues, please comment on this issue to reopen it. If you cannot reproduce the issue, please close it yourself, and we also have a scheduled task to clean up issues older than 14 days. Thank you!

github-actions[bot] avatar Mar 26 '25 05:03 github-actions[bot]

由于没有活动,此问题已关闭。如果您仍遇到此问题,请打开一个新问题并附上此问题的链接。 This issue was closed due to inactivity. If you still encounter this issue, please open a new issue and link to this issue. Thank you.

github-actions[bot] avatar Apr 07 '25 03:04 github-actions[bot]