Skip to content

Instantly share code, notes, and snippets.

@MtkN1
Last active April 1, 2021 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MtkN1/39df93c1eed8773f18bb9c8674ec5e50 to your computer and use it in GitHub Desktop.
Save MtkN1/39df93c1eed8773f18bb9c8674ec5e50 to your computer and use it in GitHub Desktop.
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