RUVIDEO
Поделитесь видео 🙏

Implementing Code Structure for IBridgePy | Interactive Brokers | Python for Trading

This video is from a free course on Automated Trading: https://quantra.quantinsti.com/course/Automated-Trading-IBridgePY-Interactive-Brokers-Platform

Timestamp:
00:00 - 00:43 - Initialization
00:43 - 01:05 - Define handle_data
01:05 - 01:28 - Functions used to generate trading signal
01:29 - 02:30 - Input parameters
02:34 - 03:03 - Implementing the same in Spyder


In this video, we will understand the code structure to create a trading algorithm using IBridgePy.
First, we define initialize. initialize is a built-in-method which is called once when our algorithm starts running. It requires context as input. Any parameter initialization and one-time startup logic should go here. context is an augmented Python dictionary used for maintaining state during your backtest or live trading session. context variables can be accessed and initialized using dot notation. For example, (context.some_property).

Next, we define handle_data, which is also a built-in method where the trading decision is made. Two inputs are given here: context, data. “context” contains the variables claimed in initialize. “data” contains account information and near real-time quotes received from Interactive brokers.
There are two other functions that you can use to generate a trading signal: before_trading_start: before_trading_start is called once per day before the market opens and requires context and data as input. schedule_function. schedule function can only be called from initialize function.

Now, let us look at each of the input parameters in detail. func: The name of the function to run. This function must accept context and data as parameters, which will be the same as those passed to handle_data. date_rule: Specifies the date portion of the schedule. This can be every day, week, or month and has an offset parameter to indicate days from the first or the last date of the month. The default is daily, and the default offset is 0 days. time_rule: Specifies the time portion of the schedule. This can be set as market_open or market_close and has an offset parameter to indicate how many hours or minutes from the market open or close. The default is market_open, and 1 minute before close. calendar: Specifies the US equities and US future calendar on which the time rules will be based.

Now you have a basic understanding of functions used in the algorithm. Let’s see the implementation of the same in the Spyder. First, we define initialize which takes the context as input. In initialize function, my_func is scheduled to run every day, 30 minutes after the market opens. Then, we define my_func which takes context and data as input.

Next, we define before_trading_start and handle_ data which takes context and data as input. In this video, we saw the basic code structure. In the next video, we will learn how to retrieve data.

Quantra is an online education portal that specializes in Algorithmic and Quantitative trading. Quantra offers various bite-sized, self-paced and interactive courses that are perfect for busy professionals, seeking implementable knowledge in this domain.

Find more info on - https://quantra.quantinsti.com/
Like us on Facebook: https://www.facebook.com/goquantra/
Follow us on Twitter: https://twitter.com/GoQuantra

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Implementing Code Structure for IBridgePy | Interactive Brokers | Python for Trading», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.