From 396ca350211ed6cc69c243a88565ca30ba9808f3 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Fri, 15 Sep 2023 07:15:09 -0700 Subject: [PATCH] Modify package layout in order to support local module installation --- ibkr/__init__.py | 1 + client.py => ibkr/client.py | 4 ++-- exchange.py => ibkr/exchange.py | 0 market_data_type.py => ibkr/market_data_type.py | 0 option_chain_example.py | 2 +- option_chain_example_old.py | 2 +- setup.py | 11 +++++++++++ 7 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 ibkr/__init__.py rename client.py => ibkr/client.py (97%) rename exchange.py => ibkr/exchange.py (100%) rename market_data_type.py => ibkr/market_data_type.py (100%) create mode 100644 setup.py diff --git a/ibkr/__init__.py b/ibkr/__init__.py new file mode 100644 index 0000000..3ead93a --- /dev/null +++ b/ibkr/__init__.py @@ -0,0 +1 @@ +from .client import Client \ No newline at end of file diff --git a/client.py b/ibkr/client.py similarity index 97% rename from client.py rename to ibkr/client.py index 144f27c..1d6bec3 100644 --- a/client.py +++ b/ibkr/client.py @@ -1,10 +1,10 @@ import pandas as pd from datetime import datetime -from exchange import SMART +from .exchange import SMART from ib_insync import IB, Index, Option from ib_insync.util import isNan -from market_data_type import LIVE +from .market_data_type import LIVE from typing import Callable class Client: diff --git a/exchange.py b/ibkr/exchange.py similarity index 100% rename from exchange.py rename to ibkr/exchange.py diff --git a/market_data_type.py b/ibkr/market_data_type.py similarity index 100% rename from market_data_type.py rename to ibkr/market_data_type.py diff --git a/option_chain_example.py b/option_chain_example.py index e30def9..4d9e4b1 100644 --- a/option_chain_example.py +++ b/option_chain_example.py @@ -1,5 +1,5 @@ -from client import Client from datetime import datetime +from ibkr.client import Client ibkr_client = Client(host = '127.0.0.1', port = 7497) diff --git a/option_chain_example_old.py b/option_chain_example_old.py index 11713d2..aab13d7 100644 --- a/option_chain_example_old.py +++ b/option_chain_example_old.py @@ -5,8 +5,8 @@ import datetime import pandas as pd -from exchange import SMART from ib_insync import * +from ibkr.exchange import SMART ib = IB() ib.connect('127.0.0.1', 7497, clientId=1) # Assuming TWS is running on the current machine. diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..873f0f5 --- /dev/null +++ b/setup.py @@ -0,0 +1,11 @@ +from setuptools import setup, find_packages + +setup( + name="ibkr", + version="1.0", + packages=find_packages(), + install_requires=[ + 'ib_insync', + 'pandas' + ], +) \ No newline at end of file