# Import the library
from ib_insync import *
import pandas as pd
import numpy as np
import datetime
# Connect to the TWS
ib = IB()
ib.connect("127.0.0.1", 7496, clientId=1)
# Define the contract to trade
contract = Stock('QQQ', 'SMART', 'USD')
# Define the trading strategy
def trade_strategy(ib, contract, data):
![](https://cdn.lihkg.com/assets/faces/normal/hehe.gif)
![](https://cdn.lihkg.com/assets/faces/normal/hehe.gif)
![](https://cdn.lihkg.com/assets/faces/normal/hehe.gif)
![](https://cdn.lihkg.com/assets/faces/normal/hehe.gif)