Hi
I am using ib_insync version 0.9.59 and nest_asyncio==1.3.0
This is a toy example that was working for me on ib_insync version 0.9.58 and nest_asyncio==1.0.0 and stopped working on latest version:
import pandas as pd
from ib_insync import IB, Forex, Contract, Index, util
import os.path
import datetime
from apscheduler.schedulers.asyncio import AsyncIOScheduler
import asyncio
util.patchAsyncio()
util.logToFile("df.log")
async def tick_10(c):
print('Tick! The time for the 10 second job is: {}'.format(datetime.datetime.now()))
if not ib.isConnected():
pass
else:
bars = ib.reqHistoricalData(c,
endDateTime=pd.to_datetime("2018-04-01"),
durationStr='1 D',
barSizeSetting='1 min',
whatToShow='MIDPOINT',
formatDate=2,
useRTH=True)
df = util.df(bars)
if not df is None:
print(df.tail().loc[:,["date","close"]])
scheduler = AsyncIOScheduler()
ib = IB()
ib.connect('127.0.0.1', 7496, clientId=1)
# define a contract
c = ib.qualifyContracts(Forex('EURUSD'))[0]
# define a scheduled task
scheduler.add_job(tick_10, args=[c],trigger='cron', minute='*',second='*/10')
scheduler.start()
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
# Execution will block here until Ctrl+C (Ctrl+Break on Windows) is pressed.
try:
asyncio.get_event_loop().run_forever()
except (KeyboardInterrupt, SystemExit):
pass
Hi I am using ib_insync version 0.9.59 and nest_asyncio==1.3.0
This is a toy example that was working for me on ib_insync version 0.9.58 and nest_asyncio==1.0.0 and stopped working on latest version:
Could you please have a look?
Thanks! Idan