#! /usr/bin/gawk -f # Last edited on 2014-03-18 01:43:40 by stolfilocal BEGIN \ { # Caller must define (with "-v") {DB,D0,D1,H0,H1,P0,P1,R} # Outputs "-line" commands from {D0-0.5} to {D1+0.5}. # The horiz position is {h(D) = H0 + H1*(d-DB)}. # The Huobi price is {pH(D) = P0 + P1*(d - DB)}. # The Bitstamp price is {pB(D) = pH(D)/R}. # Will plot from {D0-0.25} tp {D1+0.25} if (DB == "") { arg_error(("must define {DB}")); } # Reference day. if (D0 == "") { arg_error(("must define {D0}")); } # First day to plot. if (D1 == "") { arg_error(("must define {D1}")); } # Last day to plot. if (H0 == "") { arg_error(("must define {H0}")); } # H-coordinate of day {DB} (before "-hshift") if (H1 == "") { arg_error(("must define {H1}")); } # Increment in H-coordinate for 1 day. if (P0 == "") { arg_error(("must define {P0}")); } # Price at day {DB}. if (P1 == "") { arg_error(("must define {P1}")); } # Price increment per day. if (R == "") { arg_error(("must define {R}")); } # Currency conversion factor. for (k = 0; k < 2; k++) { d = (k == 0 ? D0 - 0.5 : D1 + 0.5); # Day number. h = int(H0 + H1*(d - DB) + 0.5); p = int((P0 + P1*(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