-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Former-commit-id: acf7996
- Loading branch information
Showing
10 changed files
with
74 additions
and
41 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
from zvt.accounts.ccxt_account import CCXTAccount | ||
|
||
CCXTAccount.init() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
import json | ||
|
||
import ccxt | ||
|
||
from zvt.domain import COIN_EXCHANGES | ||
from zvt.settings import HTTP_PROXY, HTTPS_PROXY | ||
|
||
|
||
class CCXTAccount(object): | ||
def __init__(self, exchanges=COIN_EXCHANGES) -> None: | ||
self.exchange_conf = {} | ||
self.exchanges = exchanges | ||
|
||
self.init_exchange_conf() | ||
exchanges = COIN_EXCHANGES | ||
exchange_conf = {} | ||
|
||
def init_exchange_conf(self): | ||
for exchange in self.exchanges: | ||
@classmethod | ||
def init(cls): | ||
for exchange in cls.exchanges: | ||
import pkg_resources | ||
|
||
resource_package = 'zvt' | ||
resource_path = 'accounts/{}.json'.format(exchange) | ||
config_file = pkg_resources.resource_filename(resource_package, resource_path) | ||
|
||
with open(config_file) as f: | ||
self.exchange_conf[exchange] = json.load(f) | ||
cls.exchange_conf[exchange] = json.load(f) | ||
|
||
def get_tick_limit(self, exchange): | ||
return self.exchange_conf[exchange]['tick_limit'] | ||
@classmethod | ||
def get_tick_limit(cls, exchange): | ||
return cls.exchange_conf[exchange]['tick_limit'] | ||
|
||
def get_kdata_limit(self, exchange): | ||
return self.exchange_conf[exchange]['kdata_limit'] | ||
@classmethod | ||
def get_kdata_limit(cls, exchange): | ||
return cls.exchange_conf[exchange]['kdata_limit'] | ||
|
||
def get_safe_sleeping_time(self, exchange): | ||
return self.exchange_conf[exchange]['safe_sleeping_time'] | ||
@classmethod | ||
def get_safe_sleeping_time(cls, exchange): | ||
return cls.exchange_conf[exchange]['safe_sleeping_time'] | ||
|
||
def get_ccxt_exchange(self, exchange_str): | ||
@classmethod | ||
def get_ccxt_exchange(cls, exchange_str) -> ccxt.Exchange: | ||
exchange = eval("ccxt.{}()".format(exchange_str)) | ||
exchange.apiKey = self.exchange_conf[exchange_str]['apiKey'] | ||
exchange.secret = self.exchange_conf[exchange_str]['secret'] | ||
exchange.apiKey = cls.exchange_conf[exchange_str]['apiKey'] | ||
exchange.secret = cls.exchange_conf[exchange_str]['secret'] | ||
# set to your proxies if need | ||
exchange.proxies = {'http': 'http://127.0.0.1:10081', 'https': 'http://127.0.0.1:10081'} | ||
exchange.proxies = {'http': HTTP_PROXY, 'https': HTTPS_PROXY} | ||
return exchange |
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
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
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
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
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