Is there a way to place crypto orders for BTCUSD in fractions of 1? The link below says it supports minimum qty 0.0001 for BTC but the api seems to only accept Long integers and not decimal amounts?? here is my example code for the order but i want to be able to purchase 0.0001 or similar instead. Any help is appreciated.
var order = await alpacaTradingClient.PostOrderAsync(
side.Market(symbol, 1));
You are right @Michael_D - some extension methods don’t properly support the OrderQuantity type as an argument for order placement object creation. I’ll fix in the upcoming release (you can track progress in the newly created GitHub issue).
As a temporary workaround, you can use static methods of the MarketOrder type:
var order = await alpacaTradingClient.PostOrderAsync(
MarketOrder.Buy(symbol, OrderQuantity.Fractional(0.01)));
or
var order = await alpacaTradingClient.PostOrderAsync(
MarketOrder.Sell(symbol, OrderQuantity.Notional(0.01)));
The first problem (validation exception) is my fault - my last merge into the 5.x branch was incorrect and miss one important line. The updated 5.2.14 version is already available on NuGet.
The second problem (REST error) is a server-side limitation - AFAIK the crypto API supports only a limited set of order types and brackets not in this list yet.
Perfect the fractional piece works now, thanks for the quick response! Do you know when crypto orders will support the bracket orders or if its in the road map?
@Michael_D Unfortunately, I’m unable to answer your question - I don’t have enough information. I’m not working in Alpaca - just do maintenance/support work for their .NET SDK on GitHub.
var position = await alpacaTradingClient.GetPositionAsync(Symbol);
var order = await alpacaTradingClient.PostOrderAsync(
MarketOrder.Sell(Symbol, OrderQuantity.Fractional(position.Quantity)));
Thank you for contributing! We have a dedicated discord focused solely on Crypto related queries with an active community and more engagement. Feel free to join via the invite link below;
@Michael_D I’m not an Alpaca employee so I don’t know exact timelines for planned features. I’ve made changes in C# SDK and now it supports fractional quantity for all order types but any client-side feature depends on server support of course.