I am an utter noob and need help.
I managed to fetch options chain of a particular symbol and expiry from NSE, extracted it to excel.
But I thought it would be better if I can use TWS API.
Problem: Want to fetch normal data like Option chain for given symbol and expiry, and the last years historical data and then see that data in excel so that can do further calculations.
As, I am not familiar with pycharm community), I wanted to fetch data using ATOM editor and command prompt. I referred the code from here(
this video in ATOM along with the TWS API download from IB official site.)
used
pip install ibapi
in my command prompt & managed to install successfully.
now after this, I started TWS with paper trading account and made sure all the port settings and everything is correct. After that, I ran the code shown in video, which is:
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
class TestApp(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)
def error(self, reqId, errorCode, errorString):
print('Error: ', reqId, ' ', errorCode, ' ', errorString)
def contractDetails(self, reqId, contractDetails):
print('contractDetails: ', reqId, ' ', contractDetails)
def main():
app = TestApp()
app.connect('127.0.0.1', 7497, 0)
# need to figure out code to w8 for validation from TWS
contract = Contract()
contract.symbol = 'AAPL'
contract.secType = 'STK'
contract.exchange = 'SMART'
contract.currency = 'USD'
contract.primaryExchange = 'NASDAQ'
app.reqContractDetails(1, contract)
app.run()
if __name__ == '__main__':
main()
After running this code 1st time I got the executed message .
after that, I ran this program 2-3 times and all I get is the GREEN tick that we see after a program runs successfully in atom itself(ctrl+shift+b). But I do not see any output as shown in the video.
Now, I did the same thing with pycharm and I can see that out put as shown in the video. (I did select that pythonclient folder as root, as mentioned in the start of the video). But I have no idea what I am doing here.
All I care about is establishing a simple connection with TWS from running my program from ATOM or Command prompt and get that data in excel for further calculation. I think it would be easier to keep fetching live data and keep generating signals.
THANKS in Advance for any help.
EDIT from @bhucho The Problem: unable to see the output after running problem once, and all sees is the GREEN tick that we see after a program runs successfully in atom itself(ctrl+shift+b).