Type/to search

NTPClient UDP && Exchange Server delay

Common strategy
Created: 2023-09-07 18:39:00
Last modified: 3 years ago
12
Follow
657
Followers

A function to obtain the time of the remote NTP server, which is more common in high-frequency trading or calculation delays

Source
JavaScript

function ntp_client() {
    // compatible with backtesting
    if (IsVirtual()) {
        return new Date().getTime()
    }
    let client = Dial("udp://time.windows.com:123")
    client.write('\x1b' + Array(47).fill('\0').join(''))
    let buf = client.read()
    client.close()
    if (buf && buf.byteLength == 48) {
        let dataView = new DataView(buf)
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)