IB量化博客


1 2 3 4 5 2 54


Quant

API Case Study in Pair Trades - IBKR Traders' Academy Python API Course


Python

 

This lesson offers a practical way to wrap your knowledge of Python and IBKR API by exploring a case study with advanced order types. Be sure to consult the Study Notes to learn about Pair-trading, a popular strategy in algorithmic trading, where an instrument is bought and a related instrument is sold short.

Finish the course by testing your knowledge with the Final Exam!

https://gdcdyn.interactivebrokers.com/en/index.php?f=25228&course=22

 

Trading on margin is only for sophisticated investors with high risk tolerance. You may lose more than your initial investment.

The order types available through Interactive Brokers LLC’s Trader Workstation are designed to help you limit your loss and/or lock in a profit. Market conditions and other factors may affect execution.  In general, orders guarantee a fill or guarantee a price, but not both.  In extreme market conditions, an order may either be executed at a different price than anticipated or may not be filled in the marketplace.

The analysis in this material is provided for information only and is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad-based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation by IBKR to buy, sell or hold such investments. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.


23115




Quant

Five Indicators To Build A Trend Following Strategy - Part III


See part II in this series to learn more about Bollinger Bands.

MACD (Moving Average Convergence Divergence)

The Moving Average Convergence Divergence indicator (MACD) is a comparative analysis of two moving averages for two different datasets. Depending on the bandwidth of the time series, you can assess the price fluctuations for two different stretches of time. Say one for a span of a month and another for 200 days. Comparison of the moving average for these two data sets is done based on three main observations viz. convergence, divergence and dramatic rise.

 
How to use MACD in trend following strategies:
If the price fluctuations for one data set is less than the moving average, while for the other data the fluctuations are above the moving average, it is wiser to take a short position on the stock because the price variation is not stable. 

Plotting MACD in python for trend following strategies:
The Python code is given below: 

# MACD

data['macd'], data['macdsignal'], data['macdhist'] = ta.MACD(data.close, fastperiod=12, slowperiod=26, signalperiod=9)

data[['macd','macdsignal']].plot(figsize=(10,5))

plt.show()


The graph plotted is shown below:

 

Quant

 

In the next article, Rekhit will discuss RSI (Relative Strength Index).

 

*Any trading symbols displayed are for illustrative purposes only and are not intended to portray recommendations.

Learn more QuantInsti here https://www.quantinsti.com

To learn more about Python and R, visit QuantInsti website and their educational offerings at their Executive Programme in Algorithmic Trading (EPAT™).

Trading on margin is only for sophisticated investors with high risk tolerance. You may lose more than your initial investment.


This material is from QuantInsti and is being posted with QuantInsti’s permission. The views expressed in this material are solely those of the author and/or QuantInsti and IBKR is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation to buy, sell or hold such security. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.

 


23062




Quant

Towards Better Keras Modeling - Part I


 

Quant

 

The field of deep learning is frequently described as a mix of art and science. One of the most "art-sy" parts of the field, in my experience, is the subject of network topology design - i.e., choosing the right geometry, size, depth, and type of network.

Machine learning practitioners develop rules of thumb for reasonable starting points - and learn heuristics for how to iterate towards optimality.

In this post, I'll walk you through my early exploration with Talos, a simple framework that automates the workflow of conducting hyperparameter optimization on Keras models. I'm relatively new to Talos, so this brief tutorial should be no substitute for the project's documentation or support forum.

 

As a sample dataset, I'll make use of data from a recent contest at Numerai, an interesting project that is best thought of as Kaggle, Quantopian, and Ethereum all rolled into one.

Numerai provides datasets to any data scientists interested in developing prediction models - much like Kaggle. Those who feel they have trained useful models can choose to enter a weekly contest for a chance to win cash prizes.

To access this sample dataset, I'll make use of Numerox, an API interface to Numerai's data contests.

This post will cover:

  • Installing Talos and Numerox
  • Downloading and preparing data from Numerai
  • Setting up and executing a coarse parameter sweep on a Keras model
  • Analyzing the results
  • Conducting a second, "finer" scan on the parameter space
  • Reaching a final model

    If you'd like to replicate and experiment with the below code, you can download the source notebook for this post by right-clicking on the below button and choosing "save link as"

 

Python

 

In the next post, the author will show us how to set up Talos and Numerox.

 

----------------

About The Alpha Scientist

I'm Chad, aka The Alpha Scientist. I've created The Alpha Scientist blog to explore the intersection of my two professional passions: locating "alpha" in market inefficiencies and applying data science methods. If you've found this post useful, please follow @data2alpha on Twitter and forward to a friend or colleague who may also find this topic interesting. https://alphascientist.com/

 

This material is from The Alpha Scientist and is being posted with The Alpha Scientist’s permission. The views expressed in this material are solely those of the author and/or The Alpha Scientist and IBKR is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation to buy, sell or hold such security. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.


23190




Quant

Placing Orders - IBKR Traders' Academy Python API Course


Python

In this lesson, the instructor discusses how orders can be placed, monitored, modified, and cancelled from the TWS API.

To provide a picture of the essential components necessary to place an order, he demonstrates a simple Python program: Program.py

Finish the lesson by testing your knowledge with a short quiz!

https://gdcdyn.interactivebrokers.com/en/index.php?f=25228&course=22

 

The analysis in this material is provided for information only and is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad-based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation by IBKR to buy, sell or hold such investments. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.


23061




Quant

Top 10 Machine Learning Algorithms for Beginners - Part 3


See the previous part of this series to learn more about KNN Classification and Support Vector Machine (SVM).

 

Decision Trees

Decision trees are basically a tree-like support tool, which can be used to represent a cause and its effect. Since one cause can have multiple effects, we list them down (quite like a tree with its branches).

Quant

We can build the decision tree by organizing the input data and predictor variables, and according to some criteria that we will specify.

The main steps to build a decision tree are:

  1. Retrieve market data for a financial instrument.
  2. Introduce the Predictor variables (i.e., Technical indicators, Sentiment indicators, Breadth indicators, etc.)
  3. Setup the Target variable or the desired output.
  4. Split data between training and test data.
  5. Generate the decision tree training the model.
  6. Test and analyze the model.

The disadvantage of decision trees is that they are prone to overfitting due to their inherent design structure.

 

Stay tuned for the fourth installment in this series to learn about Random Forest!

 

 

Learn more QuantInsti here https://www.quantinsti.com

To learn more about Python and R, visit QuantInsti website and their educational offerings at their Executive Programme in Algorithmic Trading (EPAT™).

This material is from QuantInsti and is being posted with QuantInsti’s permission. The views expressed in this material are solely those of the author and/or QuantInsti and IBKR is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation to buy, sell or hold such security. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.

 

 

 


23114




1 2 3 4 5 2 54

披露

感谢您给予我们反馈。如您有任何关于IB量化博客的问题或意见,请联系ibkrquant@ibkr.com

IBKR量化博客上提供的材料(包括文章与点评)仅供参考。此等材料不代表盈透证券(IB)推荐您或您的客户采用任何在IBKR量化博客上发布内容的独立顾问、对冲基金或其他实体之服务或在此类个人/实体处投资,也不代表盈透证券推荐您在任何顾问或对冲基金处投资。在IBKR量化博客上发布内容的顾问、对冲基金及其他分析师独立于IB,IB不就此等顾问、对冲基金及其他个人/实体的历史及未来业绩、或其提供的信息的准确性做任何称述与担保。盈透证券不会开展“适合性审查”来确保任意顾问、对冲基金或其他个人/实体的交易适合您。

IB量化博客上提及的证券或其他金融产品并不适合所有投资者。发布的材料并未考虑您特定的投资目标、财务状况或需求,也不构成任意证券、金融产品或策略之推荐。在进行任意投资或交易前,您应考虑该投资或交易是否适合您特定的情况,且在必要时寻求专业建议。过去的业绩不保证将来的业绩。

任何第三方提供的信息均来自我们认为可靠及准确的来源;然而,IB不担保其准确性且不对任何错误或遗漏承担责任。

盈透或其关联公司的雇员发布的任何信息基于一般认为的真实可信的信息。然而,IB及其关联公司无法保证信息的完整性、准确性或适当性。IB不对任何金融产品过去或将来的表现作出任何声明或担保。在IB量化博客上发布内容不代表IB认为特定的金融产品或交易策略适合您。