Created
March 10, 2018 12:09
-
-
Save koheso/0c25a44efb95b6399476bb6213901a45 to your computer and use it in GitHub Desktop.
CoinExchageでTicker情報取得
This file contains 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
import requests | |
from pprint import pprint | |
def GetMarketAssetCode(marketID): | |
for data in coinIDInfoList: | |
if data["marketID"] == marketID: | |
return data["marketAssetCode"] | |
if __name__ == '__main__': | |
r = requests.get('https://www.coinexchange.io/api/v1/getmarkets') | |
json = r.json() | |
coinIDresults = json["result"] | |
coinIDInfoList = [] | |
for data in coinIDresults: | |
coinIDInfo = {"marketID":data['MarketID'],"marketAssetCode":data['MarketAssetCode']} | |
coinIDInfoList.append(coinIDInfo) | |
r = requests.get('https://www.coinexchange.io/api/v1/getmarketsummaries') | |
json = r.json() | |
coinexchangeList = json["result"] | |
for data in coinexchangeList: | |
marketID = data['MarketID'] | |
marketAssetCode = GetMarketAssetCode(marketID) | |
bidPrice = data['BidPrice'] | |
askPrice = data['AskPrice'] | |
print(marketAssetCode) | |
print("AskPrice:"+bidPrice) | |
print("BidPrice:"+askPrice) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment