def setUp(self) -> None:
        """Set up the Session."""

        # Grab configuration values.
        config = ConfigParser()
        file_path = pathlib.Path('config/config.ini').resolve()
        config.read(file_path)

        # Load the details.
        self.paper_account = config.get('main', 'PAPER_ACCOUNT')
        self.paper_username = config.get('main', 'PAPER_USERNAME')

        # Initalize the Client
        self.ibw_client = IBClient(username=self.paper_username,
                                   account=self.paper_account)
Beispiel #2
0
    def _create_session(self) -> IBClient:
        """Start a new session. Go to initiate an IBClient object and the session will be passed onto trader object
        Creates a new session with the IB Client  API and logs the user into
        the new session.
        Returns:
        ----
        IBClient -- A IBClient object with an authenticated sessions.
        """
        ib_client = IBClient(username=self.username,
                             account=self.account,
                             is_server_running=True)

        #Start a new session
        ib_client.create_session()

        return ib_client
Beispiel #3
0
from ibw.client import IBClient
from ibw.configAlex import REGULAR_ACCOUNT, REGULAR_PASSWORD, REGULAR_USERNAME, PAPER_ACCOUNT, PAPER_PASSWORD, PAPER_USERNAME

# Create a new session of the IB Web API.
ib_client = IBClient(username=PAPER_USERNAME,
                     password=PAPER_PASSWORD,
                     account=PAPER_ACCOUNT)
'''
    SESSIONS
'''

# create a new session.
ib_client.create_session()

# close the current session.
# ib_client.close_session()
'''
    ACCOUNT DETAILS
'''

# grab the account data.
account_data = ib_client.portfolio_accounts()
print(account_data)
print('')

# grab account portfolios
account_positions = ib_client.portfolio_account_positions(
    account_id=PAPER_ACCOUNT, page_id=0)
print(account_positions)
print('')
Beispiel #4
0
import pathlib
from configparser import ConfigParser
from ibw.client import IBClient

# Grab configuration values.
config = ConfigParser()
file_path = pathlib.Path(__file__).parent.parent.joinpath(
    'config', 'config.ini').resolve()
config.read(file_path)

# Load the details.
PAPER_ACCOUNT = config.get('main', 'PAPER_ACCOUNT')
PAPER_USERNAME = config.get('main', 'PAPER_USERNAME')

# Create a new session of the IB Web API.
ib_client = IBClient(username=PAPER_USERNAME, account=PAPER_ACCOUNT)
'''
    SESSIONS
'''

# create a new session
ib_client.create_session()

# Logout of the client.
logout_response = ib_client.logout()
print(logout_response)

# close the current session.
ib_client.close_session()

# '''
from pprint import pprint
from ibw.client import IBClient

# Create a new session of the IB Web API.
ib_client = IBClient(username="******",
                     account="PAPER_ACCOUNT_ACCOUNT_NUMBER",
                     is_server_running=True)

# create a new session
ib_client.create_session()

# grab the account data.
account_data = ib_client.portfolio_accounts()
pprint(account_data)
pprint('')

# grab account portfolios
account_positions = ib_client.portfolio_account_positions(
    account_id="PAPER_ACCOUNT_ACCOUNT_NUMBER", page_id=0)
pprint(account_positions)
pprint('')

# grab account PNL
account_pnl = ib_client.server_account_pnl()
pprint(account_pnl)
pprint('')

# grab server accounts
server_accounts = ib_client.server_accounts()
pprint(server_accounts)
pprint('')
Beispiel #6
0
from pprint import pprint
from ibw.client import IBClient

# Create a new session of the IB Web API.
ib_client = IBClient(username="******",
                     account="PAPER_ACCOUNT_ACCOUNT_NUMBER")

# create a new session
ib_client.create_session()

# grab the account data.
account_data = ib_client.portfolio_accounts()
pprint(account_data)
pprint('')

# grab account portfolios
account_positions = ib_client.portfolio_account_positions(
    account_id="PAPER_ACCOUNT_ACCOUNT_NUMBER", page_id=0)
pprint(account_positions)
pprint('')

# grab account PNL
account_pnl = ib_client.server_account_pnl()
pprint(account_pnl)
pprint('')

# grab server accounts
server_accounts = ib_client.server_accounts()
pprint(server_accounts)
pprint('')
Beispiel #7
0
from pprint import pprint
from ibw.client import IBClient
from configparser import ConfigParser

# Grab configuration values.
config = ConfigParser()
file_path = pathlib.Path('config/config.ini').resolve()
config.read(file_path)

# Load the details.
paper_account = config.get('main', 'PAPER_ACCOUNT')
paper_username = config.get('main', 'PAPER_USERNAME')

# Create a new session of the IB Web API.
ib_client = IBClient(username=paper_username, account=paper_account)

# create a new session
ib_client.create_session()

# grab the account data.
account_data = ib_client.portfolio_accounts()
pprint(account_data)
pprint('')

# grab account portfolios
account_positions = ib_client.portfolio_account_positions(
    account_id=paper_account, page_id=0)
pprint(account_positions)
pprint('')