2024年4月
Short 紀錄
建倉止損判定
最近思考的問題為, 假定某商品 Tick 為 1
以 100 為基礎價格, 往上移動為 101 往下則是 99
某策略設定打穿 100 送入做空訂單, (暫不考慮搓合情形,假定能立刻成交)
止損或保本價位該如何設定 能達到最大效益?
下載 BTC Hist 的筆記
來源
https://www.binance.com/en/landing/data
DL URL
https://data.binance.vision/data/spot/daily/trades/BTCUSDT/BTCUSDT-trades-2024-04-01.zip
之前有寫過一個爬蟲一路抓回起始點, 但不知道塞去哪裡了
下載回來後的格式為
3523985836,71280.00000000,0.00141000,100.50480000,1711929600000,True,True
此時要注意雖然欄位有七欄位, 但官方實際給出的描述只有六欄
猜測可能是於交易所成交後的訂單系統標記為 True, 故沒特別說明
'id' => 交易ID
'price' => 價格
'qty' => 成交數量(BTC)
'base_qty' => 成交金額(USDT)
'time' => 時間
'is_buyer_maker' => 成交方向
'????' => 統一為 True
Typecho 結構筆記
前端發送
admin/login.php
處理請求
var/Widget/Login.php
替註冊頁面添加 reCAPTCHA 驗證
admin/register.php
在 Register 類 添加 send_post 功能
private function send_post($url, $post_data){
$postdata = http_build_query($post_data);
$options = a`請輸入代碼`rray(
'http' => array(
'method' => 'POST',
'header' => 'Content-type:application/x-www-form-urlencoded',
'content' => $postdata,
'timeout' => 10 // 超时时间(单位:s)
)
);
$context = stream_context_create($options);
$recaptcha_json_result = file_get_contents($url, false, $context);
$result = json_decode($recaptcha_json_result, true);
return $result;
}
在 action 添加解析參數以及判斷異常功能
/** 截获验证异常 */
if ($error = $validator->run($this->request->from('name', 'password', 'mail', 'confirm', 'g-recaptcha-response'))) {
Cookie::set('__typecho_remember_name', $this->request->name);
Cookie::set('__typecho_remember_mail', $this->request->mail);
/** 设置提示信息 */
Notice::alloc()->set($error);
$this->response->goBack();
}
/** Google reCaptcha v2 */
$post_data = [
'secret' => 'secret_key_here',
'response' => $_POST["g-recaptcha-response"]
];
$recaptcha_result = $this->send_post('https://www.google.com/recaptcha/api/siteverify', $post_data);
返回前端文件
admin/register.php
在 form 中添加 驗證欄位, 方便 recaptcha 傳入
<p>
<div class="g-recaptcha" data-sitekey="site_key_here"></div>
</p>
在底部 script 後面加上
引用來源
https://newabug.top/archives/67.html