createPreview

fun createPreview(accountIdKey: String, request: PreviewRequest): PreviewOrderResponse?

Create an order preview

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 service = Orders(session, runtime.production, runtime.verbose)
val accountIdKey = "ACCOUNT_ID_KEY"
val expiry = ZonedDateTime.of(
    LocalDate.of(2021, 10, 15),
    LocalTime.of(16, 0),
    ZoneId.of("America/New_York")
)

val request = buyButterflyCalls(
    symbol = "CHPT",
    strikes = Triple(18f, 19f, 20f),
    limitPrice = .19f,
    quantity = 10,
    expiry = expiry
)

service.createPreview(accountIdKey, request)?.let {
    println("Preview of Buy to Open butterfly calls on CHPT")
    println(it)
} 
   //sampleEnd
}

Parameters

accountIdKey

The unique account key

request

The preview request

Sources

jvm source
Link copied to clipboard