algorithmic-trading

Finding unusual value in an array, list

心已入冬 提交于 2019-12-21 04:39:27
问题 I have sales statistic data in array form to calc standard deviation or average from this data. stats = [100, 98, 102, 100, 108, 23, 120] let said +-20% differential is normal situation, 23 is obviously a special case. what's the best algorithm (in any language, pseudo or any principle) to find this unusual value? 回答1: You could convert them to Z-scores and look for outliers. >>> import numpy as np >>> stats = [100, 98, 102, 100, 108, 23, 120] >>> mean = np.mean(stats) >>> std = np.std(stats)

Getting stock's historical data

被刻印的时光 ゝ 提交于 2019-12-18 10:46:09
问题 We would like to check on stock's historical data, using HTTP request, and get JSON. Using the yahoo API ,I found it hard to not only clearly understand the HTTP request fields, but also to get the data of a certain day (not average for each day, but the values during a certain day), with this : http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22AAPL%22%20and%20startDate%20%3D%20%222012-09-11%22%20and%20endDate%20%3D%20

How fast is state of the art HFT trading systems today?

霸气de小男生 提交于 2019-12-18 09:59:19
问题 All the time you hear about high frequency trading (HFT) and how damn fast the algorithms are. But I'm wondering - what is fast these days? Update I'm not thinking about the latency caused by the physical distance between an exchange and the server running a trading application, but the latency introduced by the program itself. To be more specific: What is the time from events arriving on the wire in an application to that application outputs an order/price on the wire? I.e. tick-to-trade

NotImplementedError() what does this mean, event profiler pyalgotrade

跟風遠走 提交于 2019-12-12 23:00:52
问题 I'm trying to run pyalgotrade's event profiler. I'm using custom data, it works when I run it with the default stratergy/predicate 'BuyOnGap' however when I try and run it with a simple custom strategy it throw the error: Traceback (most recent call last): File "C:\Users\David\Desktop\Python\Coursera\Computational Finance\Week2\PyAlgoTrade\Bitfinex\FCT\FCT_single_event_test.py", line 43, in <module> main(True) File "C:\Users\David\Desktop\Python\Coursera\Computational Finance\Week2

Cumulative Return in Trading Strategy Test

只愿长相守 提交于 2019-12-12 05:51:00
问题 I have a Signal based on order imbalance that I want to test against historic stock data. I also have the price for each of these Signals and then I calculate a Trend on the price to see if the returns are rising or falling in the last previous 4 prices. From the Signal I have taken nSignal <- pnorm(Signal, mean = mean(Signal), sd = sd(Signal)) Now my idea is to buy/short each time nSignal rises above 0.70. If the trend is positive then I would place a buy and if it the trend is negative I

What is pandas syntax for lookup based on existing columns + row values?

北城以北 提交于 2019-12-12 02:38:55
问题 I'm trying to recreate a bit of a convoluted scenario, but I will do my best to explain it: Create a pandas df1 with two columns: 'Date' and 'Price' - done I add two new columns: 'rollmax' and 'rollmin' , where the 'rollmax' is an 8 days rolling maximum and 'rollmin' is a rolling minimum. - done Now I need to create another column 'rollmax_date' that would get populated through a look up rule: for the row n, go to the column 'Price' and parse through the values for the last 8 days and find

Does ShellExecuteW(…) work only once in MetaTrader 4 or not?

三世轮回 提交于 2019-12-12 01:27:06
问题 Trying to launch an .exe from MQL4 using ShellExecuteW() . Does this command work only once, or not? #import "shell32.dll" // MQL4-syntax-wrapper-Bo[#import]Container // v-------------- caller-side interface to DLL int ShellExecuteW( int hWnd, int lpVerb, string lpFile, int lpParameters, int lpDirectory, int nCmdShow ); #import // MQL4-syntax-wrapper-Eo[#import]Container if ( cond == true ){ ShellExecuteW( 0, "open", "D:\\Execute.exe", "", "", 1 ); } 回答1: A: a short version Maybe yes, maybe

Oandapy: Expecting property name enclosed in double quotes

ⅰ亾dé卋堺 提交于 2019-12-11 15:56:49
问题 I'm trying to use algo-trading as described in this tutorial: https://www.oreilly.com/learning/algorithmic-trading-in-less-than-100-lines-of-python-code class MomentumTrader(opy.Streamer): def __init__(self, momentum, *args, **kwargs): opy.Streamer.__init__(self, *args, **kwargs) self.ticks = 0 self.position = 0 self.df = pd.DataFrame() self.momentum = momentum self.units = 100000 def create_order(self, side, units): order = oanda.create_order(config["oanda"]["account_id"], instrument="EUR

How to Write a Custom Rule Function for Quantstrat in R - Replace trailing stop order with stoplimit with ruleOrderProc

我是研究僧i 提交于 2019-12-11 06:47:23
问题 My goal is to use the rule that I outline below to generate a signal to place a new 'stoplimit' order that replaces my trailing stop. I don't want my stop to trail indefinitely, only until it reaches my breakeven price (if this can be achieved somehow already, please let me know). I am hoping to write a custom rule in quantstrat with the following objective: If today's "Close" minus (-) the threshold value (a scalar) on the timestamp of trade open, is greater than (>) the "Open" price on

Rolling idxmax() in python?

回眸只為那壹抹淺笑 提交于 2019-12-10 22:36:20
问题 I have a python DataFrame containing some financial data that I am trying to create some technical indicators for. I am trying to figure out how to use a moving window function to speed up the process rather than going element by element. For each index I would like to return the maximum index for the last 30 days. I had implemented an element by element solution but as you can imagine it is dreadfully slow. for s_sym in ls_symbols: for i in range(refresh, len(ldt_timestamps)): #Aroon-Up = (