An error caused by an exchange network can cause a function call such as exchange.GetAccount to fail, at which point it is necessary to try again, but the code that appears once for each function is too annoying to lock.
This function is placed at the beginning.
function EnsureCall(method) {
var r;
while (!(r = method.apply(this, Array.prototype.slice.call(arguments).slice(1)))) {
Sleep(300);
}
return r;
}
And then, for example, you can access account information like this.var account = EnsureCall(exchange.GetAccount);
This is how you get depth.var depth = EnsureCall(exchange.GetDepth);
This is how you pass the parameters.var records = EnsureCall(exchange.GetRecords, PERIOD_M5);
In this way, no matter how unstable the exchange network, EnsureCall will retry all valid data, instead of using each function to pack once in order to tolerate errors.
Of course, you can also change the name of EnsureCall to a memorable and short name like EC or Call, which is more convenient.
simple-chunIs there a PY version of this?
solorezfunction EnsureCall ((method) { I'm not sure. while (!(r = method.apply(this, Array.prototype.slice.call ((arguments).slice))) { Sleep ((300); I'm not sure. and return r; I'm not sure. function main (() { InitAccount = EnsureCall ((exchange.GetAccount))); Log (InitAccount); I'm not sure. This is the first time I have ever seen an error like the one above.
solorezI think it's best to take this into consideration when you do the next API.
solorezDid God test it? Why did I get this error when I used it: This is a list of all the different ways Dn-filebox.qbox.me/bdfed9d5bfd320ceaa06732c84ef0dd1662dc3f8.png is credited in the database.
Zero```EnsureCall ((exchange.GetAccount) ``GetAccount does not need to be added after (((