Tufterhandout package. Knit to html in RStudio, initial example.
Some charts in quantmod draw multiple chunks. Knitr returns error when it can not find all of the corresponding files. This is of course a wider problem than quantmod.
# instead of | |
if <cond> <statement> end | |
# could use | |
<cond> && <statement> | |
# which could be read as: must have <cond> to do <statement> | |
# similarly | |
if ! <cond> <statement> end | |
<cond> || <statement> | |
# read: either <cond> is met or do <statement> (e.g. throw error) |
## first verify python-sympy Ubuntu package is installed, | |
## and Pkg.add("SymPy") in Julia | |
using Gadfly # before SymPy to have automatic plotting as below | |
using SymPy | |
# declare symbols: one of several ways | |
# see https://github.com/jverzani/SymPy.jl | |
x, a, b, c = @syms x a b c | |
typeof(x) | |
f(x) = a*exp(-(x - b)^2/c) |
# if using custom places for keeping Julia modules | |
push!(LOAD_PATH, "/home/path/tothatplace") | |
# defining new env variables | |
ENV["NEWVAR_NAME"] = "/home/path/newvar" |
## QCQP problem in a convex sub-domain | |
a = 77.5625 | |
F = [ 351.0 26255.2 -6647.07 1282.81 | |
26255.2 2.23819e6 -780203.0 80689.2 | |
-6647.07 -780203.0 1.25858e6 151221.0 | |
1282.81 80689.2 151221.0 979604.0] | |
V = [375.77,11564.5,18360.6,3891.82] | |
# unconstrained min |
## QCQP problem in a convex sub-domain | |
a = 77.5625 | |
F = [ 351.0 26255.2 -6647.07 1282.81 | |
26255.2 2.23819e6 -780203.0 80689.2 | |
-6647.07 -780203.0 1.25858e6 151221.0 | |
1282.81 80689.2 151221.0 979604.0] | |
V = [375.77,11564.5,18360.6,3891.82] | |
# unconstrained min |
## RCall data exchange between Julia and R | |
using DataFrames | |
using RCall | |
# example DataFrame | |
df = DataFrame(coln1 = 1:4, coln2 = ["M", "F", "F", "M"], coln3 = [false, true, false, true], coln4 = int8([1, 0, 1, 1])) | |
# R environment in a session started from Julia | |
g = globalEnv | |
reval(rparse("dfls <- NULL")) |
Tufterhandout package. Knit to html in RStudio, initial example.
Some charts in quantmod draw multiple chunks. Knitr returns error when it can not find all of the corresponding files. This is of course a wider problem than quantmod.
## http://julialang.org/Reactive.jl/ | |
using Reactive | |
x = Input(0) | |
xsquared = lift(a -> a*a, Int, x) | |
push!(x,5) | |
xsquared.value | |
a = Input(randn(25,3)) |
## signal difference | |
using Reactive | |
s = Input(0.0) | |
function difference(prev, x) | |
prev_diff, prev_val = prev | |
# x becomes prev_val in the next call | |
return (x-prev_val, x) | |
end |
## concurrent signal updates | |
using Reactive | |
# trading system case: target and actual position | |
pact = Input(0) | |
buy = Input(false) | |
fptarg(b::Bool) = b ? 10 : 0 | |
ptarg = lift(fptarg, buy) |