Stop receiving account summary updates for the accounts that are members of of groups specified in groupName.

cancel_account_summary(groupNames)

Arguments

groupNames

Character vector of length 1 or 2 containing the names of the subscriptions you wish to cancel -- which, in the case of req_account_summary(), are always GROUP names. If groupName is not supplied, then cancel_account_summary() will cancel all active subscription made by req_account_summary().

Value

TRUE upon success (invisible), FALSE or error otherwise.

Details

If groupNames is not supplied, then cancel_account_summary() will cancel all Account Summary subscriptions.

See also

Examples

# Fetch ACCOUNTS for all tags and groupName = "All", without creating # a subscription. req_account_summary()
#> # A tibble: 137 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 AccountType INDIVIDUAL "" #> 2 DF1267859 Cushion 1 "" #> 3 DF1267859 LookAheadNextChange 0 "" #> 4 DF1267859 AccruedCash 0.00 "USD" #> 5 DF1267859 AvailableFunds 0.00 "USD" #> 6 DF1267859 BuyingPower 0.00 "USD" #> 7 DF1267859 EquityWithLoanValue 0.00 "USD" #> 8 DF1267859 ExcessLiquidity 0.00 "USD" #> 9 DF1267859 FullAvailableFunds 0.00 "USD" #> 10 DF1267859 FullExcessLiquidity 0.00 "USD" #> # … with 127 more rows
# View the updated ACCOUNTS object in the treasury treasury$ACCOUNTS
#> # A tibble: 137 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 AccountType INDIVIDUAL "" #> 2 DF1267859 Cushion 1 "" #> 3 DF1267859 LookAheadNextChange 0 "" #> 4 DF1267859 AccruedCash 0.00 "USD" #> 5 DF1267859 AvailableFunds 0.00 "USD" #> 6 DF1267859 BuyingPower 0.00 "USD" #> 7 DF1267859 EquityWithLoanValue 0.00 "USD" #> 8 DF1267859 ExcessLiquidity 0.00 "USD" #> 9 DF1267859 FullAvailableFunds 0.00 "USD" #> 10 DF1267859 FullExcessLiquidity 0.00 "USD" #> # … with 127 more rows
# Reset the ACCOUNTS object when you're ready treasury$ACCOUNTS <- NULL # Fetch just the TotalCashValue, BuyingPower, and GrossPositionValue for # groupName = "All", again without creating a subscription req_account_summary( tags = c("TotalCashValue", "BuyingPower", "GrossPositionValue") )
#> # A tibble: 18 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 BuyingPower 0.00 USD #> 2 DF1267859 GrossPositionValue 0.00 USD #> 3 DF1267859 TotalCashValue 0.00 USD #> 4 DU1267860 BuyingPower 4074106.40 USD #> 5 DU1267860 GrossPositionValue 4562.53 USD #> 6 DU1267860 TotalCashValue 1014815.02 USD #> 7 DU1267861 BuyingPower 3803879.54 USD #> 8 DU1267861 GrossPositionValue 178829.46 USD #> 9 DU1267861 TotalCashValue 818305.42 USD #> 10 DU1267862 BuyingPower 4077241.78 USD #> 11 DU1267862 GrossPositionValue 1784.18 USD #> 12 DU1267862 TotalCashValue 1021574.88 USD #> 13 DU1267863 BuyingPower 4082950.47 USD #> 14 DU1267863 GrossPositionValue 472.45 USD #> 15 DU1267863 TotalCashValue 1020092.16 USD #> 16 DU1267864 BuyingPower 4078489.54 USD #> 17 DU1267864 GrossPositionValue 31292.92 USD #> 18 DU1267864 TotalCashValue 997367.27 USD
# See that the data is stored in the treasury: treasury$ACCOUNTS
#> # A tibble: 18 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 BuyingPower 0.00 USD #> 2 DF1267859 GrossPositionValue 0.00 USD #> 3 DF1267859 TotalCashValue 0.00 USD #> 4 DU1267860 BuyingPower 4074106.40 USD #> 5 DU1267860 GrossPositionValue 4562.53 USD #> 6 DU1267860 TotalCashValue 1014815.02 USD #> 7 DU1267861 BuyingPower 3803879.54 USD #> 8 DU1267861 GrossPositionValue 178829.46 USD #> 9 DU1267861 TotalCashValue 818305.42 USD #> 10 DU1267862 BuyingPower 4077241.78 USD #> 11 DU1267862 GrossPositionValue 1784.18 USD #> 12 DU1267862 TotalCashValue 1021574.88 USD #> 13 DU1267863 BuyingPower 4082950.47 USD #> 14 DU1267863 GrossPositionValue 472.45 USD #> 15 DU1267863 TotalCashValue 1020092.16 USD #> 16 DU1267864 BuyingPower 4078489.54 USD #> 17 DU1267864 GrossPositionValue 31292.92 USD #> 18 DU1267864 TotalCashValue 997367.27 USD
# As above, using some example $LEDGER tags: treasury$ACCOUNTS <- NULL req_account_summary(tags = c("TotalCashValue", "BuyingPower", "$LEDGER"))
#> # A tibble: 156 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 BuyingPower 0.00 USD #> 2 DF1267859 TotalCashValue 0.00 USD #> 3 DF1267859 Currency BASE BASE #> 4 DF1267859 CashBalance 0.00 BASE #> 5 DF1267859 TotalCashBalance 0.00 BASE #> 6 DF1267859 AccruedCash 0.00 BASE #> 7 DF1267859 StockMarketValue 0.00 BASE #> 8 DF1267859 OptionMarketValue 0.00 BASE #> 9 DF1267859 FutureOptionValue 0.00 BASE #> 10 DF1267859 FuturesPNL 0.00 BASE #> # … with 146 more rows
treasury$ACCOUNTS
#> # A tibble: 156 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 BuyingPower 0.00 USD #> 2 DF1267859 TotalCashValue 0.00 USD #> 3 DF1267859 Currency BASE BASE #> 4 DF1267859 CashBalance 0.00 BASE #> 5 DF1267859 TotalCashBalance 0.00 BASE #> 6 DF1267859 AccruedCash 0.00 BASE #> 7 DF1267859 StockMarketValue 0.00 BASE #> 8 DF1267859 OptionMarketValue 0.00 BASE #> 9 DF1267859 FutureOptionValue 0.00 BASE #> 10 DF1267859 FuturesPNL 0.00 BASE #> # … with 146 more rows
treasury$ACCOUNTS <- NULL req_account_summary(tags = c("TotalCashValue", "BuyingPower", "$LEDGER:ALL"))
#> # A tibble: 84 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 BuyingPower 0.00 USD #> 2 DF1267859 TotalCashValue 0.00 USD #> 3 DU1267860 BuyingPower 4074106.40 USD #> 4 DU1267860 TotalCashValue 1014815.02 USD #> 5 DU1267861 BuyingPower 3803879.54 USD #> 6 DU1267861 TotalCashValue 818305.42 USD #> 7 DU1267862 BuyingPower 4077241.78 USD #> 8 DU1267862 TotalCashValue 1021574.88 USD #> 9 DU1267863 BuyingPower 4082950.47 USD #> 10 DU1267863 TotalCashValue 1020092.16 USD #> # … with 74 more rows
treasury$ACCOUNTS
#> # A tibble: 84 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 BuyingPower 0.00 USD #> 2 DF1267859 TotalCashValue 0.00 USD #> 3 DU1267860 BuyingPower 4074106.40 USD #> 4 DU1267860 TotalCashValue 1014815.02 USD #> 5 DU1267861 BuyingPower 3803879.54 USD #> 6 DU1267861 TotalCashValue 818305.42 USD #> 7 DU1267862 BuyingPower 4077241.78 USD #> 8 DU1267862 TotalCashValue 1021574.88 USD #> 9 DU1267863 BuyingPower 4082950.47 USD #> 10 DU1267863 TotalCashValue 1020092.16 USD #> # … with 74 more rows
################################################################################ #### Update Behavior Example: Async Mode ####################################### ################################################################################ #### This example involves setting up account summary subscriptions. Make sure #### that you actually have positions whose values are changing; i.e., #### accounts aren't empty, the market is currently open, etc. ## Open up a socket connection (unless you have one open already): create_new_connections(1) # Start an account summary subscription for the default group ("All") using # all of the possible tags: req_account_summary(channel = "async") # Within three minutes of starting the subscription, take a look at the # ACCOUNTS object in the treasury: treasury$ACCOUNTS
#> # A tibble: 209 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 AccountType INDIVIDUAL "" #> 2 DF1267859 Cushion 1 "" #> 3 DF1267859 LookAheadNextChange 0 "" #> 4 DF1267859 AccruedCash 0.00 "USD" #> 5 DF1267859 AvailableFunds 0.00 "USD" #> 6 DF1267859 BuyingPower 0.00 "USD" #> 7 DF1267859 EquityWithLoanValue 0.00 "USD" #> 8 DF1267859 ExcessLiquidity 0.00 "USD" #> 9 DF1267859 FullAvailableFunds 0.00 "USD" #> 10 DF1267859 FullExcessLiquidity 0.00 "USD" #> # … with 199 more rows
# See when it was last updated: acc_sum_update_time <- attr(treasury$ACCOUNTS, "last_updated") acc_sum_update_time
#> [1] "2020-03-17 13:08:29 EDT"
# Soon after creating the subscription, try to update the ACCOUNTS # object in the treasury by calling read_sock_drawer(): read_sock_drawer() # If you're quick enough, you won't get any updated information because IB has # not sent updated data to the socket. # So, wait a while. For example's sake, let's wait a little over 3 minutes: Sys.sleep(200) # Keep calling... read_sock_drawer() # ...a few times, waiting 10 or 20 seconds in between calls. After 3 minutes # have passed -- and probably before that -- you should see the # ACCOUNTS object update. # After updating, take a look in your treasury... treasury$ACCOUNTS
#> # A tibble: 209 x 4 #> account tag tag_value currency #> * <chr> <chr> <chr> <chr> #> 1 DF1267859 NetLiquidation 0.00 "USD" #> 2 DU1267860 Cushion 0.998882 "" #> 3 DU1267860 EquityWithLoanValue 1019666.30 "USD" #> 4 DU1267860 NetLiquidation 1019666.30 "USD" #> 5 DU1267860 BuyingPower 4074103.59 "USD" #> 6 DU1267860 GrossPositionValue 4561.60 "USD" #> 7 DU1267860 InitMarginReq 1140.40 "USD" #> 8 DU1267860 MaintMarginReq 1140.40 "USD" #> 9 DU1267860 AvailableFunds 1018525.90 "USD" #> 10 DU1267860 ExcessLiquidity 1018525.90 "USD" #> # … with 199 more rows
# ...and compare your old ACCOUNTS update time -- stored in the variable # "acct_sum_update_time" -- with your newly updated ACCOUNTS: acc_sum_update_time
#> [1] "2020-03-17 13:08:29 EDT"
attr(treasury$ACCOUNTS, "last_updated")
#> [1] "2020-03-17 13:11:49 EDT"
# You can also take a look at the "account_summary" element of your # subscriptions object: subscriptions$account_summary
#> # A tibble: 1 x 5 #> req_name tags req_id conn_row client_id #> <chr> <chr> <dbl> <dbl> <int> #> 1 All AccountType, NetLiquidation, TotalCashValu… 4 4 1
subscriptions$account_summary$tags
#> [1] "AccountType, NetLiquidation, TotalCashValue, SettledCash, AccruedCash, BuyingPower, EquityWithLoanValue, PreviousEquityWithLoanValue, GrossPositionValue, ReqTEquity, ReqTMargin, SMA, InitMarginReq, MaintMarginReq, AvailableFunds, ExcessLiquidity, Cushion, FullInitMarginReq, FullMaintMarginReq, FullAvailableFunds, FullExcessLiquidity, LookAheadNextChange, LookAheadInitMarginReq, LookAheadMaintMarginReq, LookAheadAvailableFunds, LookAheadExcessLiquidity, HighestSeverity, DayTradesRemaining, Leverage"
dplyr::glimpse(subscriptions$account_summary)
#> Observations: 1 #> Variables: 5 #> $ req_name <chr> "All" #> $ tags <chr> "AccountType, NetLiquidation, TotalCashValue, SettledCash, … #> $ req_id <dbl> 4 #> $ conn_row <dbl> 4 #> $ client_id <int> 1
# Finally, cancel the subscription. In this case, we want to cancel the one # subscribed to the groupName "All". cancel_account_summary("All") # The subscription no longer appears in the subscription object: subscriptions$account_summary
#> NULL
# From this point in time onward (until you create another subscription and/or # unless there is an update on the socket left over from before you cancelled # the subscription in this example), the account summary will no longer update # no matter how many times you call read_sock_drawer()