Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove limit of coin pairs #2

Merged
merged 1 commit into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions zvt_ccxt/accounts/ccxt_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


class CCXTAccount(object):
exchange_cache = {}
exchanges = COIN_EXCHANGES
exchange_conf = {}

Expand Down Expand Up @@ -37,9 +38,13 @@ def get_safe_sleeping_time(cls, exchange):

@classmethod
def get_ccxt_exchange(cls, exchange_str) -> ccxt.Exchange:
if cls.exchange_cache.get(exchange_str):
return cls.exchange_cache[exchange_str]

exchange = eval("ccxt.{}()".format(exchange_str))
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': zvt_env['http_proxy'], 'https': zvt_env['https_proxy']}
cls.exchange_cache[exchange_str] = exchange
return exchange
2 changes: 1 addition & 1 deletion zvt_ccxt/recorders/coin_kdata_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self,
codes=None,
batch_size=10,
force_update=True,
sleeping_time=10,
sleeping_time=1,
default_size=2000,
real_time=False,
fix_duplicate_way='ignore',
Expand Down
11 changes: 6 additions & 5 deletions zvt_ccxt/recorders/coin_recorder.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import pandas as pd

from zvt.contract.api import df_to_db
from zvt.contract.recorder import Recorder

from zvt_ccxt.accounts import CCXTAccount
from zvt_ccxt.domain import Coin
from zvt_ccxt.settings import COIN_EXCHANGES, COIN_PAIRS
from zvt_ccxt.settings import COIN_EXCHANGES


class CoinMetaRecorder(Recorder):
provider = 'ccxt'
data_schema = Coin

def __init__(self, batch_size=10, force_update=False, sleeping_time=10, exchanges=COIN_EXCHANGES) -> None:
def __init__(self, batch_size=10, force_update=False, sleeping_time=1, exchanges=COIN_EXCHANGES) -> None:
super().__init__(batch_size, force_update, sleeping_time)
self.exchanges = exchanges

Expand All @@ -30,6 +30,8 @@ def run(self):

aa = []
for market in markets:
if not market['active']:
continue
if markets_type == dict:
name = market
code = market
Expand All @@ -38,8 +40,7 @@ def run(self):
code = market['symbol']
name = market['symbol']

if name not in COIN_PAIRS:
continue

aa.append(market)

security_item = {
Expand Down