Skip to content

Instantly share code, notes, and snippets.

@Padilo300
Created September 6, 2021 18:17
Show Gist options
  • Save Padilo300/82d9386ee90f7354c3c5aaa3ba4a9995 to your computer and use it in GitHub Desktop.
Save Padilo300/82d9386ee90f7354c3c5aaa3ba4a9995 to your computer and use it in GitHub Desktop.
test
$klinesHour = json_decode(file_get_contents("https://fapi.binance.com/fapi/v1/klines?symbol=DOGEUSDT&interval=5m&limit=1500"),1);
$capital = 3000;
$dealList = [];
foreach ($klinesHour as $kline){
if ($capital > 200){
$dealList[] = [
'price_take' => $kline[1] + (($kline[1]/ 100) * 0.5),
'price_stop' => $kline[1] - (($kline[1]/ 100) * 10),
'type' => 'long',
];
$dealList[] = [
'price_take' => $kline[1] - (($kline[1]/ 100) * 0.16),
'price_stop' => $kline[1] + (($kline[1]/ 100) * 0.5),
'type' => 'short',
];
$capital = ($capital - 200);
}
if (count($dealList)){
foreach ($dealList as $key => $deal){
if ($deal['type'] === 'short'){
if ($kline[3] < $deal['price_take'] ){
$capital = ($capital + 110);
unset($dealList[$key]);
}
if ($kline[2] > $deal['price_stop'] ){
$capital = ($capital + 94.4);
unset($dealList[$key]);
}
}
if ($deal['type'] === 'long'){
if ($kline[2] > $deal['price_take'] ){
$capital = ($capital + 110);
unset($dealList[$key]);
}
if ($kline[3] < $deal['price_stop'] ){
$capital = ($capital + 94.4);
unset($dealList[$key]);
}
}
}
}
}
dd($capital);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment