Open chipkent opened 1 year ago
As reported in https://deephavencommunity.slack.com/archives/C036HT73T43/p1694639036590999, it is possible for the account_positions table to have duplicate entries.
account_positions
This appears to happen because position data is requested for the base account as well as all accounts.
At the same time, the raw data is aggregated using .last_by(["RequestId", "Account", "ModelCode", "ContractId"]).
.last_by(["RequestId", "Account", "ModelCode", "ContractId"])
.last_by(["Account", "ModelCode", "ContractId"])
ALL
account_*
Supporting files: requests.csv positions.csv
from ibapi.contract import Contract from ibapi.order import Order import deephaven_ib as dhib from deephaven import time_table from deephaven.plot import Figure from deephaven.plot.selectable_dataset import one_click from deephaven.plot import PlotStyle print("========== Create a client and connect.=========") # Socket Port: TWS:: live:7496 paper:7497 | IB:: live:4001 paper:4002 client = dhib.IbSessionTws(host="host.docker.internal", port=4002,client_id=0, download_short_rates=False, read_only=False) print(f"IsConnected: {client.is_connected()}") client.connect() print(f"IsConnected: {client.is_connected()}") # Setup account = "XXXXXXXXXXXXXX" max_position_dollars = 200000.0 #per security ema_t = "00:02:00" errors = client.tables["errors"] requests = client.tables["requests"] positions = client.tables["accounts_positions"].where("Account = account") ticks_bid_ask = client.tables["ticks_bid_ask"] orders_submitted = client.tables["orders_submitted"].where("Account = account") orders_status = client.tables["orders_status"] orders_exec_details = client.tables["orders_exec_details"].where( "Account = account") pnl = client.tables["accounts_pnl"].where("Account = account") tmp= client.tables["accounts_summary"].where("Account=account")
To work around this problem in the short term:
As reported in https://deephavencommunity.slack.com/archives/C036HT73T43/p1694639036590999, it is possible for the
account_positions
table to have duplicate entries.This appears to happen because position data is requested for the base account as well as all accounts.
At the same time, the raw data is aggregated using
.last_by(["RequestId", "Account", "ModelCode", "ContractId"])
..last_by(["Account", "ModelCode", "ContractId"])
?ALL
?account_*
tables need a similar code change?Supporting files: requests.csv positions.csv