Skip to content

Instantly share code, notes, and snippets.

@neilmillard
Created February 27, 2015 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilmillard/ab25c1f28bceab6f3bb3 to your computer and use it in GitHub Desktop.
Save neilmillard/ab25c1f28bceab6f3bb3 to your computer and use it in GitHub Desktop.
note to calculate price
<?php
$highMid ="1.55515";
$lowMid = "1.5534";
function toPips($price)
{
return is_int($price) ? $price / 10000 : $price;
}
$spread = 5;
$high = ((float) substr(sprintf("%.4f", $highMid),0,6)) + toPips($spread);
$low = ((float) substr(sprintf("%.4f", $lowMid),0,6)) - toPips($spread);
$range = (float) substr(sprintf("%.4f", $high - $low),0,6);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment