Skip to content

Instantly share code, notes, and snippets.

Avatar

Jasen Mackie jaymon0703

View GitHub Profile
View EDA_logistic_torch_DL.Rmd
---
title: "Jane_Street_Kaggle"
author: "Jasen Mackie"
date: "18/12/2020"
output: html_document
---
```{r setup, include=FALSE}
require(data.table)
require(ggplot2)
@jaymon0703
jaymon0703 / macd_sig_yahoo.R
Created Jul 13, 2020
macd_sig fun - silly maybe not so silly strategy
View macd_sig_yahoo.R
# Simple MACD signal strategy
#
# blotter v 0.10.0
# quantstrat v 0.9.1739
# FinancialInstrument v 1.2.0
# Rblpapi v 0.3.4
#
#
# Author: Jasen
###############################################################################
@jaymon0703
jaymon0703 / quantstrat_test.ipynb
Created May 30, 2020
Running an R package's (quantstrat) demo in a Jupyter notebook using a Python3 Kernel
View quantstrat_test.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jaymon0703
jaymon0703 / Bitcoin.cpp
Created Oct 8, 2018
Satoshi Nakamoto's C code from the Bitcoin whitepaper for determining an attacker on the network's probability of success
View Bitcoin.cpp
#include "math.h"
#include "stdio.h"
double AttackerSuccessProbability(double q, int z)
{
double p = 1.0 - q;
double lambda = z * (q / p);
double sum = 1.0;
int i;
int k;
@jaymon0703
jaymon0703 / CSCV3.Rmd
Last active Oct 6, 2018
Marcos Lopez de Prado - CSCV_3 program from Financial Charlatanism paper- http://www.ams.org/notices/201405/rnoti-p458.pdf
View CSCV3.Rmd
---
title: A replication of the Practical Application section in 'The Probability of Backtest
Overfitting' - Bailey et al.
output:
html_notebook:
# html_document:
# df_print: paged
---
In their paper "The Probability of Backtest
@jaymon0703
jaymon0703 / random_strategy_builder.R
Last active Oct 12, 2017
In preparation of my next blog post about txnsim, i would like to compare the txnsim output for some standard TTR backtests with the txnsim output for a purely randomised strategy. To do this, it makes sense to build a random strategy builder based on user specified stylized facts sampled from predefined distributions. Thanks Brian Peterson for …
View random_strategy_builder.R
require(blotter)
# Remove portfolio and account data if run previously
try(rm("portfolio.txnsim_rnorm_port","account.txnsim_rnorm_acct",pos=.blotter), silent = TRUE)
# load the example data
currency("USD")
stock("GSPC",currency="USD",multiplier=1)
getSymbols('^GSPC', src='yahoo', index.class=c("POSIXt","POSIXct"),from='1998-01-01')
@jaymon0703
jaymon0703 / profit.hurdle.R
Last active Aug 14, 2017
This is the Profit Hurdle implementation in R from Harvey & Liu's 'Backtesting' paper, Exhibit 6. It works as expected, so putting the code here for safekeeping until i complete the roxygen documentation and create a branch for issue 66 in braverock/quantstrat
View profit.hurdle.R
###############################################################################
# R (http://r-project.org/) Quantitative Strategy Model Framework
#
# Copyright (c) 2009-2017
# Peter Carl, Dirk Eddelbuettel, Brian G. Peterson, Jeffrey Ryan, and Joshua Ulrich
#
# This library is distributed under the terms of the GNU Public License (GPL)
# for full details see the file COPYING
#
# $Id$
@jaymon0703
jaymon0703 / perTradeStats_InitQty_EndQty.R
Created Mar 9, 2017
perTradeStats with added columns Init.Qty and End.Qty
View perTradeStats_InitQty_EndQty.R
#' calculate trade statistics for round turn trades.
#'
#' One 'trade' is defined as a series of transactions which make up a 'round turn'.
#' It may contain many transactions. This function reports statistics on these
#' round turn trades which may be used on their own or which are also used
#' by other functions, including \code{\link{tradeStats}} and \code{\link{tradeQuantiles}}
#'
#' @details
#' Additional methods of determining 'round turns' are also supported.
#'
@jaymon0703
jaymon0703 / perTradeStats_with_Increased.to.Reduced.R
Last active Jan 24, 2017
perTradeStats with "increased.to.reduced" assuming FIFO to line up start and end dates for round turn trades
View perTradeStats_with_Increased.to.Reduced.R
#' calculate flat to flat per-trade statistics
#'
#' One 'trade' is defined as the entire time the symbol is not flat.
#' It may contain many transactions. From the initial transaction that
#' moves the position away from zero to the last transaction that flattens the
#' position is all one 'trade' for the purposes of this function.
#'
#' This is sometimes referred to as 'flat to flat' analysis.
#'
#' Note that a trade that is open at the end of the measured period will
View mcsim_wCI.R
#' Monte Carlo simulate strategy results
#'
#' This function resamples the daily transaction, cash equity, or percent-return
#' P&L from a portfolio of trading results. It may be applied to both real
#' (post-trade) and backtested transactions.
#'
#' The general argument here is that you can compare the performance of real
#' portfolio equity or a backtest equity curve to a sampled version of the same.
#'
#' We've chosen to use daily frequency for the resampling period. If your holding