question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bracket Order BUY with Limit type instead of Market

See original GitHub issue

When trying to buy using Bracket order , instead of doing Market order on BUY trying to do Limit, order type I get an error. is that excepted? I have verified that orderDto.BuyPrice has value and if I change LimitOrder.Buy to MarketOrder.Buy it works

    var order = await AlpacaTradingClientStrategy.GetAlpacaTradingClient().PostOrderAsync(
              LimitOrder.Buy(orderDto.Symbol, orderDto.Quantity, orderDto.BuyPrice)
                  .WithDuration(TimeInForce.Gtc)
                  .Bracket(
                      stopLossStopPrice: orderDto.BuyPrice * orderDto.StopLossPricePercent,
                      takeProfitLimitPrice: orderDto.BuyPrice * orderDto.TakeProfitLimitPricePercent
                  ));
Alpaca.Markets.RestClientErrorException: limit orders require a limit price
   at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
   at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
   at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson](HttpClient httpClient, HttpRequestMessage request, CancellationToken cancellationToken, IThrottler throttler)
   at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson,TContent](HttpClient httpClient, HttpMethod method, Uri endpointUri, TContent content, CancellationToken cancellationToken, IThrottler throttler)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
OlegRacommented, Nov 4, 2020

@citestaccount You can test the fix in the version 3.9.1 already available on the NuGet.

0reactions
r-ulakcommented, Nov 4, 2020

this works Thanks!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bracketed Buy Order
A bracketed order is a type of trade used by market professionals to limit potential loss and lock in profits by surrounding the...
Read more >
Bracket Orders
Bracket orders are designed to help limit your loss and lock in a profit by "bracketing" an order with two opposite-side orders. A...
Read more >
3 Order Types: Market, Limit and Stop Orders
A limit order is an order to buy or sell a stock with a restriction on the maximum price to be paid (with...
Read more >
How to Use Bracket Orders in Day Trading - DTTW™
A bracket order is an order type that combines a market order and limit orders. The goal is to make maximum returns and...
Read more >
Advanced Stock Order Types to Fine-Tune Your Market Trades
If you enter a long position, a bracket order will immediately place an OCO sell limit (take profit) and sell stop. If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found