Coder Social home page Coder Social logo

iktrading's People

Contributors

ilyakipnis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iktrading's Issues

Error message on IKTrading Build

Hi Ilya, thanks so much for offering your datacamp course. I'm just having an issue building the IKTrading and DSTrading package.

My computer runs R on Windows 7, 64bit version. I have loaded RTools40 and devtools. I've installed Quantstrat and Blotter but can't install IKTrading or DSTrading from your github. I'm wondering if you might know why? This is the output in my console when I attempt to install from Github. It appears to be hung up on compilation. Any help would be much appreciated:

` install_github("IlyaKipnis/IKTrading")
Downloading GitHub repo IlyaKipnis/IKTrading@HEAD
√ checking for file 'C:\Users\blhodder\AppData\Local\Temp\RtmpioKKbu\remotes4ec73d5414e\IlyaKipnis-IKTrading-0b4e0e5/DESCRIPTION' (806ms)

  • preparing 'IKTrading': (375ms)
    √ checking DESCRIPTION meta-information ...
  • cleaning src
  • checking for LF line-endings in source and make files and shell scripts
  • checking for empty or unneeded directories
  • building 'IKTrading_1.0.tar.gz'

Installing package into ‘\file086/A14$/My Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
'\file086\A14$\My Documents'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.

  • installing source package 'IKTrading' ...
    ** using staged installation
    ** libs

*** arch - i386
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11 -I"C:/PROGRA1/R/R-401.2/include" -DNDEBUG -I'\file086/A14My Documents/R/win-library/4.0/xts/include' -I'\file086/A14My Documents/R/win-library/4.0/Rcpp/include' -I'\file086/A14My Documents/R/win-library/4.0/inline/include' -I'\file086/A14My Documents/R/win-library/4.0/TTR/include' -I'\file086/A14My Documents/R/win-library/4.0/quantmod/include' -I'C:/Program Files/R/R-4.0.2/library/stats/include' -I'\file086/A14My Documents/R/win-library/4.0/digest/include' -I'\file086/A14My Documents/R/win-library/4.0/roxygen2/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
RcppExports.cpp:4:10: fatal error: Rcpp.h: No such file or directory
#include <Rcpp.h>
^~~~~~~~
compilation terminated.
make: *** [C:/PROGRA1/R/R-401.2/etc/i386/Makeconf:229: RcppExports.o] Error 1
ERROR: compilation failed for package 'IKTrading'

  • removing '\file086/A14$/My Documents/R/win-library/4.0/IKTrading'
    Error: Failed to install 'IKTrading' from GitHub:
    (converted from warning) installation of package ‘C:/Users/blhodder/AppData/Local/Temp/RtmpioKKbu/file4ec240f52a0/IKTrading_1.0.tar.gz’ had non-zero exit status

`

How to plot Ichimoku Cloud using ichimoku indicator, so as to render the future cloud in the chart?

Using the ichimoku indicator, I am attempting to plot Ichimoku Cloud, with the below implementation:

require(quantmod)
require(IKTrading)
getSymbols('IBM', src='google', from='2014-04-01')
ibm_ic = ichimoku(IBM)
ibm_icPlot <- ibm_ic[,1:5]
chart.TimeSeries(ibm_icPlot, legend.loc = "topleft")

After running the above code, all the five lines are rendered in the Chart (i.e. turning line, base line, Span A, Span B, plotSpan), here's the screenshot of my RStudio with the plot:

Alt text

Well, the problem is with the 'Span A' & 'Span B' lines (i.e. future cloud), which are not projected ('nMed=26') into the future. This projection is very important aspect of visualizing an Ichimoku Cloud in its entirety. Any suggestion on how to make the ichimoku indicator to plot the future cloud? Or is there something wrong in the above implementation?

using sigAND with doParallel results in error when combining

If you use the sigAND signal in sequential mode, there are no problems using doParallel, but in parallel mode, it results in this error. Apparently this is not compatible, but I'd think many users of this handy signal would want to run tests in parallel. Cod below reproduces the issue

error calling combine function:
<simpleError in results[[r$portfolio.st]] <- r: attempt to select less than one element>

`####################################################################

Load packages

library(dplyr)
suppressMessages(require(quantstrat))
require(IKTrading)

remove objects

rm(list = ls(all.names = T))

if(!exists(".instrument")) .instrument <<- new.env()
if(!exists(".blotter")) .blotter <<- new.env()
if(!exists(".strategy")) .strategy <- new.env()

DEFINE VARIABLES or parameters

initDate = "2000-01-01"
symbol.st = 'CYB_DAY'
portf.st = 'bug'
acct.st = 'colony'
strat.st = 'bee'
initEq = 100000
nFast = 10
nSlow = 30
nSd = 1

GET DATA

set your working directory where the data is stored

setwd("/Users/tyamada/Google Drive/CFRM551/supplemental/")
currency('USD') # initiate currency
stock(symbol.st ,currency='USD', multiplier=1) # initiate stock

getSymbols(Symbols = symbol.st, src = "csv")

initPortf(
portf.st,
symbol.st,
initDate=initDate) # initiate portfolio

initAcct(
acct.st,
portf.st,
initEq=initEq,
initDate=initDate) # initiate account

initOrders(
portf.st,
initDate=initDate ) # initiate order_book

bee = strategy(strat.st) # create strategy object

addPosLimit(
portfolio=portf.st,
symbol=symbol.st,
timestamp=initDate,
maxpos=300, longlevels = 3) # only trade in one direction once

bee <- add.indicator(
strategy = strat.st,
name = 'BBands', # TA name
arguments = list(HLC=quote(HLC(mktdata)),
n=nSlow,
sd=nSd),
label = 'BBand')

SMA column

bee <- add.indicator(
strategy = strat.st,
name = 'SMA', # TA name
arguments = list(x=quote(Cl(mktdata)),
n=nFast),
label = 'MA' )

bee <- add.signal(
strategy = strat.st,
name = 'sigCrossover',
arguments = list(columns=c('MA','dn'),
relationship='lt'),
label = 'MA.lt.dn')

SMA cross over upperBand

bee <- add.signal(
strategy = strat.st,
name = 'sigCrossover',
arguments = list(columns=c('MA','up'),
relationship='gt'),
label = 'MA.gt.up')

add.signal(strat.st, name="sigAND",arguments=list(columns=c("MA.lt.dn","MA.gt.up"),cross=TRUE),label="unlikleyCross")

bee <- add.rule(
strategy = strat.st,
name = 'ruleSignal',
arguments = list(sigcol = 'MA.gt.up',
sigval = TRUE,
replace = F,
orderqty = 100,
ordertype = 'market',
# one of "market","limit","stoplimit", "stoptrailing", or "iceberg"
orderside = 'long',
osFUN = 'osMaxPos'),

type = 'enter',
label = 'EnterLONG')

bee <- add.rule(
strategy = strat.st,
name = 'ruleSignal',
arguments = list(sigcol = 'unlikleyCross',
sigval = TRUE,
replace = F,
orderqty = 500,
ordertype = 'market',
# one of "market","limit","stoplimit", "stoptrailing", or "iceberg"
orderside = 'long',
osFUN = 'osMaxPos'),

type = 'enter',
label = 'EnterLONGBIG')

exitLong when SMA cross under LowerBand

bee <- add.rule(
strategy = strat.st,
name = 'ruleSignal',
arguments = list(sigcol = 'MA.lt.dn',
sigval = TRUE,
replace = F,
orderqty = 'all',
ordertype = 'market',
orderside = 'long'),
type = 'exit',
label = 'ExitLONG')

enterShort when SMA cross under LowerBand

bee <- add.rule(
strategy = strat.st,
name = 'ruleSignal',
arguments = list(sigcol = 'MA.lt.dn',
sigval = TRUE,
replace = F,
orderqty = -100,
ordertype = 'market',
orderside = 'short',
osFUN = 'osMaxPos'),
type = 'enter',
label = 'EnterSHORT')

exitShort when SMA cross over upperBand

bee <- add.rule(
strategy = strat.st,
name = 'ruleSignal',
arguments = list(sigcol = 'MA.gt.up',
sigval = TRUE,
replace = F,
orderqty = 'all',
ordertype = 'market',
orderside = 'short'),
type = 'exit',
label = 'ExitSHORT')

applyStrategy(
strat.st,
portf.st,
prefer='Open', # why prefer='Open'
verbose=T)

updatePortf(
portf.st) #,

updateAcct(
acct.st) # ,

updateEndEq(
Account = acct.st)#,

User Set up pf parameter ranges to test

.nFastList = 5:13
.nSlowList = 10:40
.nSdList = 1:3

number of random samples of the parameter distribution to use for random run

.nsamples = 10

add.distribution(strat.st,
paramset.label = 'SMA_BBparams',
component.type = 'indicator',
component.label = 'BBand', #this is the label given to the indicator in the strat
variable = list(n = .nSlowList),
label = 'BBandMA'
)

add.distribution(strat.st,
paramset.label = 'SMA_BBparams',
component.type = 'indicator',
component.label = 'BBand', #this is the label given to the indicator in the strat
variable = list(sd = .nSdList),
label = 'BBandSD'
)

add.distribution(strat.st,
paramset.label = 'SMA_BBparams',
component.type = 'indicator',
component.label = 'MA', #this is the label given to the indicator in the strat
variable = list(n = .nFastList),
label = 'MAn'
)

add.distribution.constraint(strat.st,
paramset.label = 'SMA_BBparams',
distribution.label.1 = 'BBandMA',
distribution.label.2 = 'MAn',
operator = '>',
label = 'BBandMA>MAn'
)

parallel computing to speed up

if( Sys.info()['sysname'] == "Windows" )
{
library(doParallel)
registerDoParallel(cores=detectCores())
registerDoSEQ()
} else {
library(doMC)
registerDoMC(cores=detectCores())
}

results <- apply.paramset(strat.st,
paramset.label='SMA_BBparams',
portfolio.st=portf.st,
account.st=acct.st,
samples= 0, # take all options
#.nsamples, only take 10 samples
verbose=TRUE)

results$tradeStats %>% View()
`

quandClean

Needs to be updated to work with the new columns in the ICE futures contracts.

Error in colnames<-(*tmp*, value = c("O", "H", "L", "C", "V", "OI" :
length of 'dimnames' [2] not equal to array extent

IKTrading and DSTrading installation for R3.3.0

Hi there,

sorry to bother - I can't install IKTrading and DSTrading for R3.3.0 because they're built under a previous version of R. I downloaded the zips from github.com (IKTrading-master.zip and DSTrading -master.zip), but after installation from local files they are still not recognised by R (GUI and also RStudio).

Is there a way to solve this (I'm actually trying to run the 'Nuts & Bolts I-IV examples - maybe there's a newer library instead of those to use)?

Best

Installing error

Hi,

I'm trying to install this package from source. Unfortunately, no luck.
Can you please tell me how to fix this. Alternatively, if you have a precompiled version, that would be great.

Thanks.

Warning: running command 'make -f "C:/PROGRA1/R/R-311.1/etc/i386/Makeconf" -f "C:/PROGRA1/R/R-311.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="IKTrading.dll" OBJECTS="RcppExports.o RcppFuns.o"' had status 127
ERROR: compilation failed for package 'IKTrading'

FAAreturns loses date info

I get the error in line 124.

Error in as.Date.numeric(dates) : 'origin' must be supplied

I cloned the repository and added some cats

cat(head(dates))
cat(str(dates))
cat(head(index(returnsData)))

originalOld <- FAAreturns(adPrices, riskFreeName="VFISX")
10165 10193 10226 10256 10284 10316
num [1:205] 10165 10193 10226 10256 10284 ...
16251 16252 16253 16254 16258 16259
Show Traceback
Rerun with Debug
Error in as.Date.numeric(dates) : 'origin' must be supplied

ATR <- stats::lag(ATR, lag)

Hi,

I am using tidyquant which loads dplyr. Unfortunately, the lag function from dplyr is masking the lag from stats. Would you consider updating your lagATR function to explicitly call stats::lag(ATR,lag)?

I currently have the following hack prior to applyIndicators:

lag <- stats::lag
applyIndicators(strategy.st, mktdata=OHLC(MSFT))

Thank you for this great package!

Can't install IKTrading

I am on Windows 10. Following the R bloggers code recently published on Quantstrat.

install_github("IKTrading", username = "IlyaKipnis")

When I run this code I get this:

install_github("IKTrading", username = "IlyaKipnis")
Downloading GitHub repo IlyaKipnis/IKTrading@master
from URL https://api.github.com/repos/IlyaKipnis/IKTrading/zipball/master
Installing IKTrading
Installing 1 package: digest
Installing package into ‘C:/Users/Matt/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/digest_0.6.12.zip'
Content type 'application/zip' length 172732 bytes (168 KB)
downloaded 168 KB

package ‘digest’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘digest’

The downloaded binary packages are in
C:\Users\Matt\AppData\Local\Temp\RtmpOaRqoz\downloaded_packages
Installing 1 package: quantmod
Installing package into ‘C:/Users/Matt/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
Warning: package ‘quantmod’ is in use and will not be installed
"C:/PROGRA1/R/R-331.3/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL
"C:/Users/Matt/AppData/Local/Temp/RtmpOaRqoz/devtools2b946dd67cef/IlyaKipnis-IKTrading-0b4e0e5"
--library="C:/Users/Matt/Documents/R/win-library/3.3" --install-tests

ERROR: dependency 'digest' is not available for package 'IKTrading'

  • removing 'C:/Users/Matt/Documents/R/win-library/3.3/IKTrading'
    Error: Command failed (1)
    In addition: Warning message:
    Username parameter is deprecated. Please use IlyaKipnis/IKTrading

When I try the username "IllyKipnis/IKTrading" I get this error:

nstall_github("IKTrading", username = "IlyaKipnis/IKTrading")
Downloading GitHub repo IlyaKipnis/IKTrading/IKTrading@master
from URL https://api.github.com/repos/IlyaKipnis/IKTrading/IKTrading/zipball/master
Error in stop(github_error(request)) : Not Found (404)
In addition: Warning message:
Username parameter is deprecated. Please use IlyaKipnis/IKTrading/IKTrading

Any ideas how to proceed?

Error while installing IKTrading

Hi,
I tried installing IKTrading. I am getting the error below. Could you please help? You have an excellent blog. Thanks.

install_github("ilyakipnis/iktrading")

package ‘inline’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\sjs\AppData\Local\Temp\Rtmpaoujit\downloaded_packages
"C:/PROGRA1/R/R-311.2/bin/x64/R" --vanilla CMD INSTALL
"C:/Users/sjs/AppData/Local/Temp/Rtmpaoujit/devtools13cc3fe0360e/IlyaKipnis-IKTrading-0b4e0e5"
--library="C:/Users/sjs/Documents/R/win-library/3.1" --install-tests

  • installing source package 'IKTrading' ...
    ** libs

*** arch - i386
Warning: running command 'make -f "C:/PROGRA1/R/R-311.2/etc/i386/Makeconf" -f "C:/PROGRA1/R/R-311.2/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="IKTrading.dll" OBJECTS="RcppExports.o RcppFuns.o"' had status 127
ERROR: compilation failed for package 'IKTrading'

  • removing 'C:/Users/sjs/Documents/R/win-library/3.1/IKTrading'
    Error: Command failed (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.