InterReact icon indicating copy to clipboard operation
InterReact copied to clipboard

How to Implement the below function points?

Open memoryfraction opened this issue 1 year ago • 2 comments

How to implement the below function points? 1 List<Order> GetOpeningOrders(string symbol, startDt, endDt = DateTime.Now) 2 Order CancelOrder(int orderId), GetCanceledOrders() 3 List<Order> 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 avatar Jun 05 '24 18:06 memoryfraction

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 avatar Jun 06 '24 00:06 memoryfraction

Added a Pull Request: https://github.com/dshe/InterReact/pull/21 Needs review and some input

memoryfraction avatar Jun 06 '24 01:06 memoryfraction