2 registered members (AndrewAMD, juanex),
1,247
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Http function script for trading API
#463466
12/05/16 19:50
12/05/16 19:50
|
Joined: Dec 2016
Posts: 43
Fiber
OP
Newbie
|
OP
Newbie
Joined: Dec 2016
Posts: 43
|
I'm trying to sent http line to open position. API description and example - https://trade4.me/API/My Url: https://trade4.me/order.php?username=Fib...=1&amount=1It's demo account, you can test. If I insert it to the browser window it works fine and I get respond: Signal Successfully Traded : ID 11292781628, Open Price 0, Open Time 2016-12-05 19:36:36, Expiry Time 2016-12-05 19:37:36 I tried to use script from Zorro Manual example, but got message "Error during transfer!" Also I tried to use http_send, or remove all code and leave only http_post command, but without success. Any ideas to solve it?
void main()
{
char ip_str[200]; // just a long empty string
int id = http_post("https://trade4.me/order.php?username=Fiber100&password=Awainter1t&asset=EUR/USD&direction=UP&expiry=1&amount=1",0);
if(!id) return;
while(!http_status(id))
{
if(!wait(100)) return; // wait for the server to reply
printf(".");
}
if(http_status(id) > 0)
{ //transfer successful?
http_result(id,ip_str,200); //get the replied IP
printf("n%s",ip_str);
}
else printf("nError during transfer!");
http_free(id); //always clean up the id!}
}
|
|
|
Re: Http function script for trading API
[Re: jcl]
#463597
12/15/16 15:09
12/15/16 15:09
|
Joined: Dec 2016
Posts: 43
Fiber
OP
Newbie
|
OP
Newbie
Joined: Dec 2016
Posts: 43
|
I solved it by changing https to http. Also added string data "123" (any number), otherwise new position is not opened, server responds with confirmation of previously opened trade.
// ------------------------- Trade4me/binary.com API
function main()
{
char ip_str[100]; // just a long empty string
int id = http_post("http://trade4.me/order.php?username=Fiber100&password=Awainter1t&asset=EUR/USD&direction=UP&expiry=1&amount=10&rand=","123");
if(!id) return;
while(!http_status(id)) {
if(!wait(100)) return; // wait for the server to reply
printf(".");
} if(http_status(id) > 0) { //transfer successful?
http_result(id,ip_str,100); //get the replied IP
printf("n%s",ip_str);
} else
printf("nError during transfer!");
http_free(id); //always clean up the id!
}
Only thing I couldn't resolve how to insert variables into http for instrument, direction, duration and stake. Error in 'line 11: Can not convert '' to 'ARRAY'
// ------------------------- Trade4me/binary.com API
function main()
{
char ip_str[100]; // just a long empty string
string Instr = "EUR/USD";
string Direction = "UP";
string Exp = "1";
string Size = "10";
int id = http_post("http://trade4.me/order.php?username=Fiber100&password=Awainter1t&asset="+Instr+"&direction="+Direction+"&expiry="+Exp+"&amount="+Size+"&rand=","123");
if(!id) return;
while(!http_status(id)) {
if(!wait(100)) return; // wait for the server to reply
printf(".");
} if(http_status(id) > 0) { //transfer successful?
http_result(id,ip_str,100); //get the replied IP
printf("n%s",ip_str);
} else
printf("nError during transfer!");
http_free(id); //always clean up the id!
}
|
|
|
Re: Http function script for trading API
[Re: mayark]
#463710
12/22/16 12:03
12/22/16 12:03
|
Joined: Dec 2016
Posts: 43
Fiber
OP
Newbie
|
OP
Newbie
Joined: Dec 2016
Posts: 43
|
Without &rand= trade is executed only once and on next command instead of opening another trade server returns confirmation of previously executed trade. Zorro version 1.50, but https doesn't work. My last working version:
// ------------------------- Trade4me/binary.com API - 2
function Trade4me( string Instrument, string Direction, string Exp, string Size)
{
char ip_str[100]; // just a long empty string
string httpline[200];
sprintf(httpline,"http://trade4.me/order.php?username=Fiber100&password=Awainter1t&asset=%s&direction=%s&expiry=%s&amount=%s&rand=",Instrument,Direction,Exp,Size);
int id = http_post(httpline,"123");
if(!id) return;
while(!http_status(id)) {
if(!wait(100)) return; // wait for the server to reply
printf(".");
} if(http_status(id) > 0) { //transfer successful?
http_result(id,ip_str,100); //get the replied IP
printf("n%s",ip_str);
} else
printf("nError during transfer!");
http_free(id); //always clean up the id!
}
function main()
{
Trade4me ("EUR/USD","UP","5","10");
}
|
|
|
|