Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何拉取期权的信息? #12

Open
Endt4sk opened this issue Feb 25, 2024 · 5 comments
Open

如何拉取期权的信息? #12

Endt4sk opened this issue Feb 25, 2024 · 5 comments
Assignees

Comments

@Endt4sk
Copy link

Endt4sk commented Feb 25, 2024

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);
}

拉取不到期权的信息。

@huacnlee
Copy link
Contributor

huacnlee commented Feb 26, 2024

@Endt4sk
Copy link
Author

Endt4sk commented Feb 26, 2024

@huacnlee

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

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

@sunli829
Copy link
Collaborator

@Endt4sk
Copy link
Author

Endt4sk commented Mar 20, 2024

@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

@QFCG
Copy link

QFCG commented May 31, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants