Some discoveries when using the _N function (API documentation Location shown below)
_N is used to handle floating-point numbers.
Let's start with a code example:
function main(){
var pi = 3.1415926535897; // 声明一个变量 储存 圆周率, 小数位数13位。
Log(_N(pi, 4) * 100); // 当我们使用 _N 函数 保留4位小数后 再 乘以 100 会是什么结果呢?
}
What happens when we use the _N function to keep the four decimal places and then multiply by 100?
I started by thinking that N (pi, 4) returns 3.1415, and then times 100 is equal to 314.15.
The actual results:
If you want to display 314.15, you can simply write:
function main(){
var pi = 3.1415926535897;
Log(_N(pi * 100, 2));
}
The test code is:
function main(){
var pi = "3.1415"; // 传入 字符串 3.1415 , 很多时候解析出来的数据没有检查类型,可能会误传入字符串。
_N(pi, 2);
}
I really stepped in the hole, the data was a string, and then I saw the following error message.
DEBUG took a while to figure out why, so you can get more out of it.
In the Safari browser, when the bot is running a page, if there is too much content in a single Log output, it can cause the entire Log information to be hidden and shown as a blank.
The status bar refreshes, i.e. every time the API function LogStatus is called, the function refreshes the display of the contents, if the current log page is not on the first page, the query mechanism is triggered, at which point the status bar of the bot page will no longer be updated. When the log page is selected as the first page, the status bar is restored.
For example, this user reported an error message:
Both of these errors are caused by using undefined variables.
The reason is to copy the code directly into the policy, and some of the policies are very simple.ParametersIt's in the strategy.Interface parametersI'm not sure what to do. Set a parameter on the policy interfaceParametric variablesThis is equivalent to declaring a strategy in code.Global variablesIf it's just copying code. The variables (parameters) of the ** policy interface that may be used in the code are in the undefined state. So it's a mistake, if you want to test someone else's strategy, it's best to copy the whole strategy.
Click on the button, click on the copy button, click on the copy button, click on the copy button, click on the copy button, click on the copy button, click on the copy button, click on the copy button, click on the copy button, click on the copy button, click on the copy button.
This type of error may be caused by not setting the Host IP address to the Exchange API KEY IP address whitelist. Adding IP addresses to the whitelist can solve this problem.
Futures floating profit or loss, also known as a single-penny float, for example, you buy 2480 1 hand screw steel, no matter how many trading days you have, the current price is 2520, the floating profit or loss is 400 yuan, the floating profit or loss indicates the current holding of your position relative to the opening price; Futures floating profit or loss, also called floating market, for example, you hold 1 hand screw steel orders, the settlement price of the last trading day is 2500, the price is 2520, the yuan market loss is 200 previously, the floating market loss represents the loss of your current position relative to the settlement price of the previous trading day.
The sum of the numeric and undefined variables returns Nan, and the sum of the objects and undefined objects returns undefined.
function main(){
var a = 11// {aa : "aa", bb : 12}
var b = {}
Log(a + b.c)
}
Weird Error: TypeError: cannot read property
var id2 = e.Sell(ticker.Sell + ticker.Sell * 0.05, 0.1)
var order2 = e.GetOrder(id2)
Log("order2:", order).
Sleep(2000) # 103 行, 这里报错。
After looking for half a day, he couldn't figure it out.
I finally read it carefully and found Log (
It's like a setup, no logs, and no way to restart.
Reason: Old DB3 files have reached 25G It's a big deal, but it's not a big deal.
>_< When encountering such problems, please check the host's location, computer or server, hard disk and system status.
Aaron muskThank you!