if (FALSE) {
# Get stored refresh token
refreshToken = readRDS('/secure/location/')
# generate a new access token
accessTokenList = schwab_auth3_accessToken('AppKey', 'AppSecret', refreshToken)
# Set Account Number
account_number = 1234567890
# Standard market buy order
# Every order must have at least these 4 paramters
schwab_placeOrder(account_number = account_number,
ticker = 'AAPL',
quantity = 1,
instruction = 'buy')
# Stop limit order - good until canceled
schwab_placeOrder(account_number = account_number,
ticker = 'AAPL',
quantity = 1,
instruction = 'sell',
duration = 'good_till_cancel',
orderType = 'stop_limit',
limitPrice = 98,
stopPrice = 100)
# Trailing Stop Order
schwab_placeOrder(account_number = account_number,
ticker='AAPL',
quantity = 1,
instruction='sell',
orderType = 'trailing_stop',
stopPriceBasis = 'BID',
stopPriceType = 'percent',
stopPriceOffset = 10)
# Option Order with a limit price
}
Run the code above in your browser using DataLab