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

How to Implement the below function points? #20

Open
memoryfraction opened this issue Jun 5, 2024 · 2 comments
Open

How to Implement the below function points? #20

memoryfraction opened this issue Jun 5, 2024 · 2 comments

Comments

@memoryfraction
Copy link
Contributor

memoryfraction commented Jun 5, 2024

How to implement the below function points?
1 List GetOpeningOrders(string symbol, startDt, endDt = DateTime.Now)
2 Order CancelOrder(int orderId), GetCanceledOrders()
3 List GetCompletedOrders(startDt, endDt = DateTime.Now)
4 List GetSymbols(int number = 500) // get all the valid symbols, e.g. ranking by market cap

thinking, if I can have a sample code, I can implement the rest of the order function , and Pull Request

Thanks

@memoryfraction
Copy link
Contributor Author

memoryfraction commented Jun 6, 2024

For example, I tested using a paper account. found that

Contract contract = new()
{
    SecurityType = ContractSecurityType.Stock,
    Symbol = "AMZN",
    Currency = "USD",
    Exchange = "SMART"
};

int orderId = Client.Request.GetNextId();

Order order = new()
{
    Action = OrderAction.Buy,
    TotalQuantity = 1,
    OrderType = OrderTypes.Limit,
    LimitPrice = 1,
    TimeInForce = OrderTimeInForce.GoodUntilCancelled
};

Task<Execution?> task1 = Client
.Response
.OfType<Execution>()
.Take(TimeSpan.FromSeconds(5))
.FirstOrDefaultAsync()
.ToTask();

Client.Request.PlaceOrder(orderId, order, contract);
Execution? execution1 = await task1;

The below code is able to create the order, but how to get the response? e.g. created orderId? order creation result? failed or succeed? since the execution1 is null

Client.Request.PlaceOrder(orderId, order, contract);

@memoryfraction
Copy link
Contributor Author

Added a Pull Request: #21
Needs review and some input

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

1 participant