-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from FuturBroke/multiple_pairs
Multiple pairs support
- Loading branch information
Showing
16 changed files
with
1,122 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
from krakendca import Config, Pair, DCA | ||
from krakendca import Config, KrakenDCA | ||
from krakenapi import KrakenApi | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
# Get parameters form configuration file. | ||
config = Config("config.yaml") | ||
# Initialize the KrakenAPI object. | ||
ka = KrakenApi(config.api_public_key, config.api_private_key) | ||
# Initialize the Pair object from pair specified in | ||
# configuration file and data from Kraken. | ||
pair = Pair.get_pair_from_kraken(ka, config.pair) | ||
# Initialize the DCA object. | ||
dca = DCA(ka, config.delay, pair, config.amount) | ||
# Execute DCA logic. | ||
dca.handle_dca_logic() | ||
except Exception as e: | ||
print(e) | ||
# Get parameters from configuration file. | ||
config = Config("config.yaml") | ||
# Initialize the KrakenAPI object. | ||
ka = KrakenApi(config.api_public_key, config.api_private_key) | ||
# Initialize the KrakenDCA object and handle the DCA based on configuration. | ||
kdca = KrakenDCA(config, ka) | ||
kdca.initialize_pairs_dca() | ||
kdca.handle_pairs_dca() | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from typing import List | ||
|
||
from .config import Config | ||
from .dca import DCA | ||
from .pair import Pair | ||
from krakenapi import KrakenApi | ||
|
||
|
||
class KrakenDCA: | ||
""" | ||
KrakenDCA main loop encapsulation. | ||
""" | ||
|
||
config: Config | ||
ka: KrakenApi | ||
dcas_list: List[DCA] | ||
|
||
def __init__(self, config: Config, ka: KrakenApi): | ||
""" | ||
Instantiate the KrakenDCA object. | ||
:param config: Config object. | ||
:param ka: KrakenAPI object. | ||
""" | ||
self.config = config | ||
self.ka = ka | ||
self.dcas_list = [] | ||
|
||
def initialize_pairs_dca(self): | ||
""" | ||
Instantiate Pair and DCA objects from pairs specified in configuration file | ||
and data from Kraken. | ||
""" | ||
print("Hi, current DCA configuration:") | ||
asset_pairs = self.ka.get_asset_pairs() | ||
for dca_pair in self.config.dca_pairs: | ||
pair = Pair.get_pair_from_kraken(self.ka, asset_pairs, dca_pair.get("pair")) | ||
self.dcas_list.append(DCA( | ||
self.ka, dca_pair.get("delay"), pair, dca_pair.get("amount") | ||
)) | ||
|
||
def handle_pairs_dca(self): | ||
""" | ||
Iterate though DCA objects list and execute DCA logic.. | ||
Handle pairs Dollar Cost Averaging. | ||
""" | ||
for dca in self.dcas_list: | ||
dca.handle_dca_logic() |
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
Oops, something went wrong.