New answers tagged

0

From https://github.com/gbeced/pyalgotrade/issues/47 Hello, it will be nice to provide bracket orders (a bracket order is composed of 3 orders a "master" order (market or pending order) and 2 others orders (pending orders) : a stop loss a take profit You might be interested by ...


0

I used an example from the paper: An Introduction to Shrinkage Estimation of the Covariance Matrix: A Pedagogic Illustration I was able to get the same Shrinkage matrix. I have provided the same matrix they use in their paper. Hope this helps import numpy as np import pandas from math import pow def get_shrunk_covariance_matrix(obs, c, zeros): ...


2

Because your python script ends and with it the socket that ibpy has opened to connect to TWS. The demo samples in the sources of ibpy use simple time.sleep(x) to make sure some information has been delivered (for example fancy_marketdata.py) before the script ends. Try to remove the time.sleep(x) lines and see how the script also ends instantly. Have a ...


2

backtrader (https://github.com/mementum/backtrader) can do 1 and 3 and is in the process of getting 2 ironed out. A live data feed from IB will make it into the next release (due in the next few days) and it will then be down to mapping of orders. On the project page you can see a list of other similar (some more, some less) python projects and may prove to ...


1

Convex Optimisation - CVXOpt and CVXPy. Textbook by Boyd & Vandenberghe Aside from CVXOPT (known for its cone programming, see http://cvxopt.org/) with extensive documentation by the authors, Boyd and Vandenberghe http://stanford.edu/~boyd/cvxbook/, there is CVXPY which provides an easier front end. CVXPY was designed and implemented by Steven ...


0

I would suggest the qq-pat library (https://github.com/QuriQuant/qq-pat) with this library you can presently do minimum variance portfolio optimization using some simple code. This is a simple example with three assets: import pandas as pd from pandas_datareader import data import datetime import qqpat aapl = data.get_data_yahoo('AAPL', ...


4

In the call to Bisection.solve, the question mark must be the Python function whose zero you want to find. In your case, it should be something reproducing the logic of IRRSolver::operator() in Mick Hittesdorf's code, i.e., something like this (which I haven't tested): cashflows = fixedRateBond.cashflows() npv = fixedRateBond.NPV() def ...


-2

Say you want to optimize for max sharpe ratio, you could do something like this with scipy: import scipy.optimize as spopt allocations = [] #allocations def Sharpe(): #An function to compute Sharpe ratio, return negative SR compute Sharpe_Ratio return -1*Sharpe_Ratio bnd = [] #bounds cns [] #constraints result = spopt.minimize(Sharpe, ...


3

Remember that all back testing is full of lies assumptions. Latency (both line latency and latency internal to the exchanges), adverse selection, market impact (yes, even you have market impact), etc, are all based on assumptions. These assumptions are educated guesses at best, but more often terrible models are used (you always get filled at at mid!) and ...



Top 50 recent answers are included