如何确定在IBKR是模拟交易还是真实交易。

huangapple go评论88阅读模式
英文:

How to findout if paper trading or real trading at IBKR

问题

像许多在交互经纪公司的人一样,我有一个用于模拟交易的账户,另一个用于使用真实资金进行交易。

使用VB,我可以向交易工作站(TWS)发送订单到IB并获取有关这些订单状态的信息。

由于我不想混淆模拟交易和真实交易的订单,我希望我的软件能够识别我是使用模拟交易账户登录还是使用真实交易账户登录。

我如何在VB和API中区分这两者?

英文:

Like many others at Interactive-Brokers I have an account for papertrading and another for trading with real money.

Using VB I can send orders for Trader Workstation (TWS) to IB and receive info about the status of these orders.

As I don't want to mix up orders for papertrading and trading with real money I want my software to identify if I'm logged in with my papertrading account or with my account for trading with real money.

How can I distinguish using VB and the API ?

答案1

得分: 1

以下是翻译好的部分:

Your paper and real accounts have different ids.
你的模拟账户和真实账户有不同的ID。

TWS will automatically send a list of managed accounts once the connection is established. The list can also be fetched at any other time via
一旦连接建立,TWS将自动发送托管账户列表。该列表还可以在任何其他时间通过以下方式获取:

client.reqManagedAccts()
client.reqManagedAccts()

See https://interactivebrokers.github.io/tws-api/managed_accounts.html
请参阅https://interactivebrokers.github.io/tws-api/managed_accounts.html

In my case the paper account starts with "DU" while the real account starts with "U", so I simply check for the initial letters and throw a warning or exit.
在我的情况下,模拟账户以“DU”开头,而真实账户以“U”开头,因此我只需检查初始字母并发出警告或退出。

The string 'accountsList' is a comma-separated string of account ids, unless you have multiple accounts there should only be a single string received.
字符串'accountsList'是一个由逗号分隔的账户ID字符串,除非您有多个账户,否则应只接收到一个字符串。

Public Sub managedAccounts(accountsList As String) Implements IBApi.EWrapper.managedAccounts
公共子 managedAccounts(accountsList As String) 实现 IBApi.EWrapper.managedAccounts

' Split the string on the comma character.
' 在逗号字符上拆分字符串。
Dim ids As String() = accountsList.Split({","c})

' Loop through result strings with For Each.
' 使用 For Each 循环遍历结果字符串。
For Each id As String In ids
If id.StartsWith("DU") Then
MsgBox("Paper account")
ElseIf id.StartsWith("U") Then
MsgBox("Real account")
End If
Next
End Sub
End Sub

英文:

Your paper and real accounts have different ids.

TWS will automatically send a list of managed accounts once the connection is established. The list can also be fetched at any other time via

> client.reqManagedAccts()

See https://interactivebrokers.github.io/tws-api/managed_accounts.html

In my case the paper account starts with "DU" while the real account starts with "U", so I simply check for the initial letters and throw a warning or exit.

The string 'accountsList' is a comma-separated string of account ids, unless you have multiple accounts there should only be a single string received.

 Public Sub managedAccounts(accountsList As String) Implements IBApi.EWrapper.managedAccounts

      ' Split the string on the comma character.
      Dim ids As String() = accountsList.Split({","c})

      ' Loop through result strings with For Each.
      For Each id As String In ids
           If id.StartsWith("DU") Then
                MsgBox("Paper account")
           ElseIf id.StartsWith("U") Then
                MsgBox("Real account")
           End If
      Next
 End Sub

huangapple
  • 本文由 发表于 2023年6月26日 18:32:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76555856.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定