After literally hundreds of test/debug revisions, the first PTL tradebot that has access to realtime exchange data:
Here is the tradebot JSON:
{'lang':'ptl','botname':'testbot3','outputs':[{'name':'test','type':'double'}],'picoc':
'double main(int argc,char **argv)
{
int ev,ch;
if ( init_PTL(&ev,&ch,0,''BTCD'',''BTC'') == 0 )
return(0.);
printf(''FROM TRADEBOT %s %s %s: highbid vol %.6f %.8f || %.8f vol %.6f lowask\n'',Exchange,Base,Rel,Bidvol(0),Bid(0), Ask(0),Askvol(0));
return(Bid(0));
}'
After I submit it, it returns the result of the "compilation":
json_handler returns.({"metalevel":0,"numinputs":0,"numoutputs":1,"IOsize":"8","codelen":"277"})
Now it is active in the system and it gets called for each price change. It is looking for BTCD/BTC trades and it will simply print the top of the orderbook. The lines with blue exchange are the new quote coming in and within a second or two, the TRADEBOT returns the right values.
cryptsy Jul_29_14 08:00:05 PM BTCD/BTC 0.00122272 0.00124613
FROM TRADEBOT cryptsy BTCD BTC: highbid vol 117.000000 0.00122272 || 0.00124613 vol 95.000000 lowask
cryptsy Jul_29_14 08:00:11 PM BTCD/BTC 0.00122273 0.00124613
FROM TRADEBOT cryptsy BTCD BTC: highbid vol 21.500000 0.00122273 || 0.00124613 vol 95.000000 lowask
So, still some cases to make sure it isnt flipped, but what this shows is that I am getting the data from the exchanges and making it available to the the picoc script inside the script, which means now scripts can look at the orderbooks and all the various timeframe bars to make decisions on what to do.
So, a bit more debugging and then adding action functions so the tradebots can do more than printouts and return values. For those of you not familiar with what this is all about,
http://www.metatrader4.com/ shows a similar system for forex, but that is only for users of a particular broker. With what I am making anybody can run tradebots that are making decisions from external API data, blockchain data, etc.
I am pretty sure that there is no other system like this and the rate I code, I doubt anybody will be able to catchup
So, I plan to make InstantDEX the most powerful automated trading platform in the decentralized arena
James