Category : finance

I have a data frame full of my recent trades. It is 7 columns across and 40ish columns down containing date time ticker price quantity side and to open/to close. I want to eventually create my own trading journal that will keep track of my open positions, closed positions, P/L, etc. In the DataFrame there ..

Read more

Context I am currently trying to build a function to select a portfolio based on a set of parameters. The dataframe has a group of portfolios based on the below function: for x in range (10000): weights = np.random.random(num_assets) weights /= np.sum(weights) Portfolio_returns_earnings_1.append(np.sum(weights * Portfolio_rtns_earnings_1.mean() * 250)) # expected returns Portfolio_Volatilities_earnings_1.append(np.sqrt(np.dot(weights.T,np.dot(Portfolio_rtns_earnings_1.cov() * 250, weights)))) # ..

Read more

Runnign the following pybacktest code: import matplotlib import matplotlib.pyplot as plt import pybacktest import pandas as pd short_ma = 50 long_ma = 200 ohlc = pybacktest.load_from_yahoo(‘AAPL’, start=2000) ohlc.tail() ms = ohlc.C.rolling(short_ma).mean() ml = ohlc.C.rolling(long_ma).mean() buy = cover = (ms > ml) & (ms.shift() < ml.shift()) # ma cross up sell = short = (ms < ..

Read more

I am working on algorithmic trading using python with the IIFL securities account for which we are using the xts-pythonclient-api-sdk I am running the Example.py file #Marketdata API Credentials API_KEY = "YOUR_API_KEY_HERE" API_SECRET = "YOUR_API_SECRET_HERE" XTS_API_BASE_URL = "https://xts-api.trading" source = "WEBAPI" """Make the XTSConnect Object with Marketdata API appKey, secretKey and source""" xt = XTSConnect(API_KEY, ..

Read more

Hoping I could have some help converting this pinescript to a backtrader strategy. My goal is to just create a simple EMA crossover strategy where if the EMA is positive than we buy and hold until the EMA goes negative. Below is my PineScript code. strategy(title = "test", overlay=true, initial_capital = 10000, pyramiding = 0, ..

Read more