You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using either sync or async options for PostOrderAsync:
var order = alpacaTradingClient.PostOrderAsync(LimitOrder.Buy(symbol, 1, limitPrice));
var order = await alpacaTradingClient.PostOrderAsync(LimitOrder.Buy(symbol, 1, limitPrice));
We notice the first order placed in a batch of orders takes much longer than subsequent orders. See below for timing results for both methods. Why does this happen and is there any way we can reduce latency on the first order?
Hi @rshahrabani, I'm sorry for the delayed response. The JSON serialization library is the cause of this significant delay in the first-order sending request. Currently, the library uses the Newtonsoft.JSON library for JSON handling. This library is reflection-based, so any attempt to serialize/deserialize any type requires type inspection and code generation.
We plan to replace this library with the more modern System.Text.Json library. This library supports code generation, and it should solve a problem. However, I don't have any estimations for this upgrade for now.
Is there an existing issue for this?
What is your question?
Using either sync or async options for PostOrderAsync:
var order = alpacaTradingClient.PostOrderAsync(LimitOrder.Buy(symbol, 1, limitPrice));
var order = await alpacaTradingClient.PostOrderAsync(LimitOrder.Buy(symbol, 1, limitPrice));
We notice the first order placed in a batch of orders takes much longer than subsequent orders. See below for timing results for both methods. Why does this happen and is there any way we can reduce latency on the first order?
Async timing
symbol: AAPL, limitPrice: 212.00, Elapsed time: 70
symbol: MSFT, limitPrice: 400.00, Elapsed time: 0
symbol: TSLA, limitPrice: 200.00, Elapsed time: 1
symbol: T, limitPrice: 20.00, Elapsed time: 2
symbol: F, limitPrice: 10.00, Elapsed time: 0
symbol: GOOG, limitPrice: 170.00, Elapsed time: 7
symbol: META, limitPrice: 500.00, Elapsed time: 6
symbol: NVDA, limitPrice: 110.00, Elapsed time: 0
symbol: AMZN, limitPrice: 170.00, Elapsed time: 1
symbol: GM, limitPrice: 50.00, Elapsed time: 0
Sync timing
symbol: AAPL, limitPrice: 212, Elapsed time: 262
symbol: MSFT, limitPrice: 400, Elapsed time: 41
symbol: TSLA, limitPrice: 200, Elapsed time: 29
symbol: T, limitPrice: 20, Elapsed time: 30
symbol: F, limitPrice: 10, Elapsed time: 30
symbol: GOOG, limitPrice: 170, Elapsed time: 29
symbol: META, limitPrice: 500, Elapsed time: 25
symbol: NVDA, limitPrice: 110, Elapsed time: 28
symbol: AMZN, limitPrice: 170, Elapsed time: 35
symbol: GM, limitPrice: 50, Elapsed time: 31
Anything else?
No response
The text was updated successfully, but these errors were encountered: