#! /usr/bin/gawk -f # Last edited on 2014-03-29 21:12:21 by stolfilocal BEGIN \ { # Caller must define (with "-v") {D0}, {D1}, {H0}, {H1}, {P0}, {P1}, {Q}, {R} # Outputs "-line" commands from {D0-0.5} to {D1+0.5}. # The horiz position is {h(D) = H0 + H1*(d-D0)}. # The Huobi price is {pH(D) = P0 + P1*Q^(d - D0)}. # The Bitstamp price is {pB(D) = pH(D)/R}. if (DB == "") { arg_error(("must define {DB}")); } # Reference day. if (D0 == "") { arg_error(("must define {D0}")); } if (D1 == "") { arg_error(("must define {D1}")); } if (H0 == "") { arg_error(("must define {H0}")); } if (H1 == "") { arg_error(("must define {H1}")); } if (P0 == "") { arg_error(("must define {P0}")); } if (P1 == "") { arg_error(("must define {P1}")); } if (Q == "") { arg_error(("must define {Q}")); } if (R == "") { arg_error(("must define {R}")); } N = 4*(D1 - D0) + 5; # Number of plot points. for (k = 0; k < N; k++) { d = D0 + (k - 2)*0.25; # Day number. h = int(H0 + H1*(d - DB) + 0.5); p = int((P0 + P1*exp(log(Q)*(d - DB)))/R + 0.5); if (k > 0) { printf " -line \"+\" %5d %5d %5d %5d \\\n", h_ant, p_ant, h, p; } h_ant = h; p_ant = p; } } # echo 'd = 27.25; h = 2168 + 120*(d - 24); p = 9881.67 - 263*d; d; h; p; p/6.12'| bc -lq