Created
November 18, 2025 14:18
-
-
Save berkorbay/0619fb00a17107ec95528e5ce5197ae6 to your computer and use it in GitHub Desktop.
gip2logger Örnekleri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from redis import Redis | |
| from dotenv import load_dotenv | |
| import os | |
| ### .env dosyasına Redis bağlantı bilgilerini ekleyebilirsiniz. | |
| load_dotenv() | |
| ## Redis bağlantısı kurun | |
| r = Redis( | |
| host=os.getenv("REDIS_HOST"), | |
| port=os.getenv("REDIS_PORT"), | |
| password=os.getenv("REDIS_PASSWORD"), | |
| db=0, | |
| ) | |
| ## Tahta bilgilerini Redis'ten alın | |
| board_d = r.json().get("board") | |
| print(board_d) | |
| # {'PH25111823': {'bestBuyPrice': 2319.8, 'bestSellPrice': 2319.9, 'bestBuyQuantity': 84, 'bestSellQuantity': 21, 'priceGap': 0.1, 'volume': 5329, 'total': 1207583.92, 'maxPrice': 2429.4, 'minPrice': 1900.8, 'maxQuantity': 416, 'minQuantity': 1, 'lastPrice': 2319.8, 'lastQuantity': 1, 'priceChangeRate': 0.0666, 'averagePrice': 2266.06, 'mcp': 2274.99, 'lastPriceStatus': 1, 'ts': 1763475433.253, 'e_id': '07c08277-06f1-4a43-9420-864d8fbdf411'}, 'PH25111822': {'bestBuyPrice': 2797.2, 'bestSellPrice': 2798.7, 'bestBuyQuantity': 62, 'bestSellQuantity': 12, 'priceGap': 1.5, 'volume': 5430, 'total': 1433885.94, 'maxPrice': 3276.4, 'minPrice': 2451.5, 'maxQuantity': 484, 'minQuantity': 1, 'lastPrice': 2797.2, 'lastQuantity': 7, 'priceChangeRate': 0.141, 'averagePrice': 2640.67, 'mcp': 2451.0, 'lastPriceStatus': 0, 'ts': 1763475433.238, 'e_id': '36cb4b21-b217-44ad-8371-5e44a71f925a'}, ...} | |
| ## Belirli bir kontrat için tahta bilgilerini alın | |
| contract_d = r.json().get("board", "PH25111819") | |
| print(contract_d) | |
| #{'bestBuyPrice': 3200.1, 'bestSellPrice': 3245.5, 'bestBuyQuantity': 10, 'bestSellQuantity': 8, 'priceGap': 45.4, 'volume': 8028, 'total': 2620548.3, 'maxPrice': 3414.7, 'minPrice': 3001.1, 'maxQuantity': 416, 'minQuantity': 1, 'lastPrice': 3245.5, 'lastQuantity': 2, 'priceChangeRate': -0.0078, 'averagePrice': 3264.26, 'mcp': 3371.11, 'lastPriceStatus': 0, 'ts': 1763475414.27, 'e_id': '625fad98-2383-448f-8f93-09113ffcc9a8'} | |
| print("Redis tahta verisi çekme örnek kodu") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment