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

[QUESTION]: Using the IOptionContract interface #739

Open
1 task done
cdeMonkey opened this issue Apr 1, 2024 · 1 comment
Open
1 task done

[QUESTION]: Using the IOptionContract interface #739

cdeMonkey opened this issue Apr 1, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@cdeMonkey
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

What is your question?

Hi, how can I get the current Asset Price of an options Contract? I can only see the last close price which is a day behind.

Anything else?

No response

@OlegRa OlegRa self-assigned this Apr 5, 2024
@OlegRa OlegRa added the question Further information is requested label Apr 5, 2024
@OlegRa
Copy link
Collaborator

OlegRa commented Apr 7, 2024

@cdeMonkey Sorry for the delayed answer, I was on vacation last week. I hope you've already figured out that SDK has the IAlpacaOptionsDataClient interface and this interface has the ListLatestTradesAsync method that allows you to get required data for one or many option contracts like this:

var key = new SecretKey("...", "...");
using var client = Environments.Live.GetAlpacaOptionsDataClient(key);

var trades= await client.ListLatestTradesAsync(new LatestOptionsDataRequest(["AAPL241220C00300000"]));
Console.WriteLine(trades["AAPL241220C00300000"]);

You can also use the ListLatestQuotesAsync method or even the ListSnapshotsAsync method for getting both the latest quote and trade information in a single response.

@OlegRa OlegRa assigned cdeMonkey and unassigned OlegRa Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants