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 ..
At work, I run numerous sensitivity analyses on relatively complex financial models. The models I work with are 15-40 MB large and I am currently working on a laptop with an Intel I7-8650U CPU processor. My current process is very manual and time consuming: 1: I open the model in Excel (takes between 1:30 – ..
https://github.com/apananya/pythonforfinance I need solution to finance data analysis problems using Python. Please help. The link contains problem statement doc and csv. Source: Python..
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)))) # ..
I have entry boxes in my code. I would want my code to check if what has been entered in the entry boxes meets the condition, if not it outputs an error message. if the conditions are met it goes ahead to make the computations. My problems is the message box is working correctly if ..
DataFrame I have the above dataframe, which shows Assets A, B …Z’s MONTHLY return +1. I need to find the cumulative product for each year, meaning i want to find the sum of product of monthly returns, annually. I’ve been using: df.groupby(df.index.year).cumproduct() But this cannot work as cumproduct isn’t an aggregator. Can someone suggest another ..
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 < ..
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, ..
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, ..
I was wondering if someone could share some ideas for why my training loss begins at a higher level than the test loss? I am trying to run an LSTM on daily stock return data as the only input and using the 10 previous days to predict the price on the next day. Training/test/validation sets ..