static async Task <long?> PlaceMarketOrder(string side = "buy") { WriteNewLine("Creating a EUR_USD market BUY order ..."); var oandaInstrument = (await Rest20.GetAccountInstrumentsAsync(AccountID, INSTRUMENT)).First(); long orderUnits = side == "buy" ? 10 : -10; var request = new MarketOrderRequest(oandaInstrument) { units = orderUnits }; OrderPostResponse response = null; try { response = await Rest20.PostOrderAsync(AccountID, request); WriteNewLine("Congrats! You've put on a trade! Let it run! :)"); } catch { WriteNewLine("Oops. Order creation failed."); } return(response?.orderFillTransaction?.tradeOpened?.tradeID); }
public async Task <long> CreateMarketOrder(string accountId, string instrument, long units) { MarketOrderRequest request = new MarketOrderRequest() { instrument = instrument, units = units, }; OrderPostResponse response = await Rest20.PostOrderAsync(accountId, request); return(response.orderFillTransaction.id); }