PHP Bittrex alert bot

Here’s a a little script I wrote to send me alerts when the prices of certain alt coins pass defined points. I have it running on a cron job and it creates a log file instead of using sessions in order to limit repeat alerts to once an hour. The directory will need to be writable for the log file. Obviously you have to set the alert points manually in the PHP but if anyone is interested I can set this up as a service with a web interface. It also sends an alert when new markets are added to Bittrex, never miss a pump and dump again!

$BittrexAlerts = new BittrexAlerts();

Class BittrexAlerts {
	private $sms = ""; //check with your mobile carrier
	private $email = ""; // alert sent to
	private $from_email = ""; // from address for all alerts
	private $identitifier = "BITTREX-ALERT"; // use to identify messages for smart mail boxes

	private $alerts = array(
		"BTC-AERO" 		=> array(.00004200,.00005000),
		// c-cex
		"dcn-btc"		=> array(.00000200, .00000200)

	private $log = array();
	private $log_file;

	public function __construct() {
		// create log file with empty array
		$this->log_file = dirname(__FILE__) . "/alerts.log";

			file_put_contents($this->log_file, serialize(array())) or die("can't create file");

		// load current log
		$this->log = unserialize(file_get_contents($this->log_file));


	private function send_alert($subject, $message) {
		$headers = 'From: ' . $this->from_email . "\r\n" .
	    	'X-Mailer: PHP/' . phpversion();

		$subject = $this->identitifier . " : " . $subject;

		mail($this->sms, $subject, $message, $headers) or die('cannot send sms');
		mail($this->email, $subject, $message, $headers) or die('cannot send mail');

	private function log_alert($alert_name, $repeat = true) {
		// log alert and return true if last alert was over an hour ago
		$limit = time() - (60 * 60);
		if(!isset($this->log[$alert_name]) || ($this->log[$alert_name] < $limit && $repeat)) {
			$this->log[$alert_name] = time();
			file_put_contents($this->log_file, serialize($this->log));
			return true;

		return false;

	public function run() {
		$markets = array();
		$lt_alerts = array();
		$gt_alerts = array();

		foreach($this->alerts as $market => $alert) {
			$markets[] = $market;
	    	$lt_alerts[$market] = $alert[0];
	    	$gt_alerts[$market] = $alert[1];

		$bittrex_summaries = json_decode(file_get_contents('')); // BITTREX API call

		foreach($bittrex_summaries->result as $summary) {
			// Check for new Markets
			$limit = time() - (60 * 60);
			if(strtotime($summary->Created) >= $limit) {
				echo $summary->Created . "
"; $subject = "NEW market!"; $message = $summary->MarketName; if($this->log_alert("NEW-".$summary->MarketName, false)) $this->send_alert($subject, $message); } if(in_array($summary->MarketName, $markets)) { // Check if markets have droppped below alert points if($summary->Last <= $lt_alerts[$summary->MarketName]) { $subject = "market LOW!"; $message = $summary->MarketName ." at " . number_format($summary->Last, 8); if($this->log_alert("LOW-".$summary->MarketName)) $this->send_alert($subject, $message); } // Check if markets have gone above alert points if($summary->Last >= $gt_alerts[$summary->MarketName]) { $subject = "market HI!"; $message = $summary->MarketName ." at " . number_format($summary->Last, 8); if($this->log_alert("HI-".$summary->MarketName)) $this->send_alert($subject, $message); } } } $ccex_summaries = json_decode(file_get_contents('')); // C-CEX API call foreach($ccex_summaries as $name => $summary) { if(in_array($name, $markets)) { // Check if markets have droppped below alert points if($summary->lastprice <= $lt_alerts[$name]) { $subject = "market LOW!"; $message = $name ." at " . number_format($summary->lastprice, 8); if($this->log_alert("LOW-".$name)) $this->send_alert($subject, $message); } // Check if markets have gone above alert points if($summary->lastprice >= $gt_alerts[$name]) { $subject = "market HI!"; $message = $name ." at " . number_format($summary->lastprice, 8); if($this->log_alert("HI-".$name)) $this->send_alert($subject, $message); } } } } }

$HYPER attack!

Unfortunately this is not a scenario from their upcoming online space strategy game, this one was on Bittrex, and not the first from what I can gather…

Yesterday I noticed there was an over 40% spread for BTC-HYPER (Hyper) and the price had gone very low, under 8200, well under the 10K floor I identified last week.  Upon analysis of the market history I found a series of small incremental sell orders that ramped the price down from about 14K to 8100 along with a few larger conditional and panic sells.  All those orders came in at 12:56 and it wasn’t until 13:17 that someone stepped in and cleaned up the low sells then I was able to pick up a few panic sells myself at 13:26 and later bought a little more at the ask price to try to make the market look normal again.

Who did this and why?  It doesn’t look like the attackers used the attack to get cheap HYPER.  I guess HyperCrypto has enemies and while it seems like all these alt coins have their fair share of haters it also seems like David Seaman‘s attempts to promote (not pump) this coin have annoyed some, maybe they don’t like the competition.

And where were the Hyper team and David Seaman during all this?  It was Labor Day but I’d have some alert bot setup to let me know when things like this happen. Or maybe they’re responsible for the buy back at 13:17?  No comment since either.  I suppose they feel like it would be counter productive to even acknowledge this kind of attack, that and the fact that many coins like Hyper are vulnerable when there just aren’t enough buy orders with enough volume to prevent an attack or spontaneous collapse like this.

I’m not dumping my HYPER yet, I love watching my wallet balance increase daily with their proof of stake mining.  I sure hope they come out with some Hyper coin games soon though, even just retrofitting existing games.  It’s cool that they’ve already revived the classic game “Zandagort” (I know nothing about computer games) but they announced on July 24 that the ETA for integrating Hyper Coin into it was just 2 weeks away.  It seems like you have to multiply any promised time line for altcoin implementations by a factor of 3 or more ;)

In any case this has been an incredible learning experience for a noob trader like me to see how markets are manipulated and how I can even manipulate them myself though I also see that it takes constant vigilance to keep propping up a coin like this.  Looking at other coins it seems that there are bots in place to help stabilize them, though I’m still not 100% sure about what I’m seeing.  I don’t know if you would call it disingenuous or just a wise move to give your team some breathing room, you can’t have spectacular new announcements every week just to keep interest alive.


Screen Shot 2014-09-02 at 1.17.56 PM


Disclaimer: I’m not an authority on any of this, I’ve just looked into certain coins and watched the markets closely for the last few days.

Dirac = Wow! Hyper++++ time to buy Razor?

So I’ve made my first big mistake as a noob alt coin investor: I had a sell order on BTC-XDQ (Dirac) for .00049 which made me something like 23% profit, not bad, right?  Well right after that it shot up to well over .0007 and continues at over .0006, apparently due to the announcement that Dirac will be integral to BlockTech‘s new exchange AltMarket.

Screen Shot 2014-08-26 at 1.58.08 PM


BTC-HYPER (Hyper) seems to be doing quite well also, hovering around .00014.  I had a sell order at that point but canceled it before it got there, instead my Hyper has gone into my Hyper wallet to earn interest.  I’ll get more if the price dips again.

After some gains last week, BTC-RZR (Razor) seems to be settling back into it’s floor level of around .0003 and I’ve already acquired more.

It seems like cryptic remarks by Bryce Weiner precede some spikes ;)

Are there any other coins I should be looking at besides these and Pink and Nautilus?  Let me know!


Disclaimer: I’m not an authority on any of this, I’ve just looked into certain coins and watched the markets closely for the last few days.


Alt coins finding their floors.

This past week on the Bittrex exchange it seems like BTC-HYPER (Hyper) has found it’s floor around .0001, with BTC-XDQ (Dirac) at around .0004 though both coins continue to exhibit higher spikes for day traders.

Screen Shot 2014-08-24 at 11.06.39 PM

BTC-RZR (Razor) had a very stable floor around .0003 with a much narrower spread though it has had some bumps which seem to be resulting in solid gains, only time will tell. I also looked at BTC-PINK (Pink) but am not so sure it looks to have an established floor yet.

On David Seaman’s podcast Bryce Weiner of BlockTech mentioned this kind of flooring with certain alt coins that have strong dev teams and plausible use case scenarios WATCH. This is in contrast to the “pump and dump” that had been seen with other alt coins that were hyped and then crashed because ultimately they have no reason to exist, unlike the coins mentioned above that are trying to do useful things that Bitcoin doesn’t do and doesn’t want to do. On the other hand no one knows yet if the teams behind these coins will actually realize their ambitions. Only Razor seems like it’s close with a new online marketplace which is supposed to launch any day now.

I highly recommend the 2 other recent interviews with Bryce also: WATCH WATCH.

Finally here’s a simple angular.js web app I created to show multiple Bittrex tickers on one page. My old Macbook Pro can’t handle all those Bittrex tabs at once and stream video at the same time ;)

Disclaimer: I’m not an authority on any of this, I’ve just researched some coins and watched the markets closely for the last few days.

PHP Projects…

Taken from PHP 5 Object, Patterns, and Practice by Matt Zandstra (Apress).

While there is a little technical jargon here I think that anybody who is at all involved with the development, or expansion of a web application needs to read this. I know exactly the kind of situation he is talking about…

“The problem is that PHP is just too easy. It tempts you to try out your ideas, and flatters you with good results. You write much of your code straight into your Web pages, because PHP is designed to support that. You add the heavier code to functions in library files, and before you know it you have a working Web application.

Continue reading