Skip to content

Instantly share code, notes, and snippets.

@MtkN1
Last active Apr 1, 2021
Embed
What would you like to do?
import http.client
import json
import time
import urllib.request
def main() -> None:
print('絶対に負けないbotを起動しました...Ctrl+Cで終了')
while True:
print('売買判断...')
f: http.client.HTTPResponse
with urllib.request.urlopen('https://api.bybit.com/v2/public/trading-records?symbol=BTCUSD') as f:
data = json.loads(f.read().decode())
aggregate = {'Sell': [], 'Buy': []}
for item in data['result']:
side = item['side']
qty = item['qty']
aggregate[side].append(qty)
volume = {
'Sell': sum(aggregate['Sell']),
'Buy': sum(aggregate['Buy']),
}
if volume['Sell'] < volume['Buy']:
print(f"売りボリューム({volume['Sell']}USD) < 買いボリューム({volume['Buy']}USD)")
print('買い判定...しかしリスクがある為取引しません!')
elif volume['Sell'] > volume['Buy']:
print(f"売りボリューム({volume['Sell']}USD) > 買いボリューム({volume['Buy']}USD)")
print('売り判定...しかしリスクがある為取引しません!')
else:
print('同じなんてことある?')
print('60秒間待機...')
time.sleep(60.0)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment