An effective way to solve the problem of exchange timing inconsistency is to use ChatGPT for processing, avoiding the cumbersome matching using regular expressions. Handing announcements directly to ChatGPT, allowing it to identify and process the time format of various exchanges, is a convenient and efficient application scenario.
By passing the announcement text to the openaiCompletions function, you can take advantage of the powerful capabilities of ChatGPT to extract key information from the announcements on the shelves of various exchanges. This method not only improves processing efficiency, but also enhances compatibility with different time formats.
Before using this function, you need to set the policy parameter OPENAI_API_KEY, which is used to provide your OpenAI API key. You can use your own key to access the gpt-3.5-turbo API.
Function name: openaiCompletions
Functional description: This function determines whether the input announcement content is an announcement of a new trading pair on the exchange's spot by calling OpenAI's gpt-3.5-turbo model. If the announcement is eligible, the function returns a JSON object containing the success symbol, the trading pair, and Beijing time; if the announcement is not eligible, it returns only a failure symbol.
Input parameters are: Content: The content of the announcement that needs to be judged.
The output is: JSON object, containing the following key value pairs:
success: Boolean value, indicating whether the judgment was successful. pair: (exists only when success is true) string array, indicating transaction pair. time: (exists only when success is true) string, indicating the time of announcement release, has been converted to Beijing time ((UTC+8)). Function execution process:
Defines the request URL, request header and request data for the gpt-3.5-turbo API. Call the HttpQuery method to send the requested data in JSON format to the gpt-3.5-turbo API. It parses the JSON data returned by the gpt-3.5-turbo API and extracts the required information. Returns the processed JSON object.
Use examples:
var content = "某交易所宣布,将于2023年3月22日12:00(UTC+8)上线ID/USDT交易对。";
var result = openaiCompletions(content);
Log(result);
The output is:
{
"success": true,
"pair": ["ID_USDT"],
"time": "2023-03-22 12:00:00"
}
// 封装的函数 function openaiCompletions(content) { var url = 'https://api.openai.com/v1/chat/completions'; var headers = 'Content-Type: application/json\nAuthorization: Bearer ' + OPENAI_API_KEY; var data = { model: 'gpt-4',//如果api没有gpt-4的权限,这里可以修改为gpt-3.5-turbo messages: [ {role: "system", "content": '判断公告内容,是交易所现货上新交易对的公告吗?如果是你只需要以json的{"success":true,"pair":["ID_USDT"],"time":"2023-03-22 12:00:00"}格式,时间转换为北京时间utc+8,如果不是返回{"success":false}'}, {role: 'user', content: content} ] }; var response = HttpQuery(url, JSON.stringify(data),null,headers,false); response = JSON.parse(response) return JSON.parse(response.choices[0].message.content); } // 使用示例 function main() { let announcement = `Fellow Binancians, Binance will list Radiant Capital (RDNT) in the Innovation Zone and will open trading for these spot trading pairs at 2023-03-30 07:30 (UTC): New Spot Trading Pairs: RDNT/BTC, RDNT/USDT, RDNT/TUSD Users can now start depositing RDNT in preparation for trading Withdrawals for RDNT will open at 2023-03-31 07:30 (UTC) RDNT Listing Fee: 0 BNB Users will enjoy zero maker fees on the RDNT/TUSD trading pairs until further notice Note: The withdrawal open time is an estimated time for users’ reference. Users can view the actual status of withdrawals on the withdrawal page. In addition, Binance will add RDNT as a new borrowable asset with these new margin pairs on Isolated Margin, within 48 hours from 2023-03-30 07:30 (UTC): New Isolated Margin Pairs: RDNT/USDT Please refer to Margin Data for a list of the most updated marginable assets and further information on specific limits and rates. What is Radiant Capital (RDNT)? Radiant Capital is a decentralized omnichain money market protocol. Users can stake their collateral on one of the major chains and borrow from another chain. RDNT is the utility token for liquidity mining and governance. Reminder: The Innovation Zone is a dedicated trading zone where users are able to trade new, innovative tokens that are likely to have higher volatility and pose a higher risk than other tokens. Before being able to trade in the Innovation Zone, all users are required to visit the web version of the Innovation Zone trading page to carefully read the Binance Terms of Use and complete a questionnaire as part of the Initial Disclaimer. Please note that there will not be any trading restrictions on trading pairs in the Innovation Zone. RDNT is a relatively new token that poses a higher than normal risk, and as such will likely be subject to high price volatility. Please ensure that you exercise sufficient risk management, have done your own research in regards to RDNT’s fundamentals, and fully understand the project before opting to trade the token. Details: Radiant Capital Website RDNT Token Contract Addresses - Arbitrum, BNB Chain Fees Rules Thanks for your support! Binance Team 2023-03-30` Log(openaiCompletions(announcement)) }
xxs1xxs1Is it possible to innovate?
xunfeng91No, not at all.