place Order
fun placeOrder(accountIdKey: String, previewRequest: PreviewRequest, previewResponse: PreviewOrderResponse): PlaceOrderResponse?
Content copied to clipboard
Place an order
Samples
import com.seansoper.batil.OptionsCalendar
import com.seansoper.batil.brokers.etrade.auth.Authorization
import com.seansoper.batil.brokers.etrade.services.Accounts
import com.seansoper.batil.brokers.etrade.services.Alerts
import com.seansoper.batil.brokers.etrade.services.Market
import com.seansoper.batil.brokers.etrade.services.Orders
import com.seansoper.batil.brokers.etrade.services.TransactionSortOrder
import com.seansoper.batil.brokers.etrade.services.orderPreview.buyButterflyCalls
import com.seansoper.batil.brokers.etrade.services.orderPreview.buyBuyWrite
import com.seansoper.batil.brokers.etrade.services.orderPreview.buyCallOptionMarket
import com.seansoper.batil.brokers.etrade.services.orderPreview.buyCallSpread
import com.seansoper.batil.brokers.etrade.services.orderPreview.buyCondorPuts
import com.seansoper.batil.brokers.etrade.services.orderPreview.buyEquityLimit
import com.seansoper.batil.brokers.etrade.services.orderPreview.sellCallOptionMarket
import com.seansoper.batil.brokers.etrade.services.orderPreview.sellEquityLimit
import com.seansoper.batil.brokers.etrade.services.orderPreview.sellIronCondor
import com.seansoper.batil.config.ClientConfig
import com.seansoper.batil.config.GlobalConfig
import java.time.LocalDate
import java.time.LocalTime
import java.time.ZoneId
import java.time.ZonedDateTime
import java.util.GregorianCalendar
fun main() {
//sampleStart
val configuration = GlobalConfig.parse(runtime)
val client = Authorization(configuration, runtime.production, runtime.verbose)
val session = client.renewSession() ?: client.createSession()
val accounts = Accounts(session, runtime.production, runtime.verbose)
accounts.list()?.let {
it.first().accountIdKey.let { accountIdKey ->
val service = Orders(session, runtime.production, runtime.verbose)
val previewRequest = buyEquityLimit("PLTR", 21f, 1)
service.createPreview(accountIdKey, previewRequest)?.let { previewOrderResponse ->
service.placeOrder(accountIdKey, previewRequest, previewOrderResponse)?.let {
println("Purchased equity")
println(it)
}
}
}
}
//sampleEnd
}
Parameters
accountIdKey
The unique account key
previewRequest
Request used to create the order preview
previewResponse
Response from creating the order preview
Sources
jvm source
Link copied to clipboard