-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CTRL+C interrupt handling for a graceful shutdown attempt
- Loading branch information
Showing
14 changed files
with
515 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,65 @@ | ||
system: | ||
EventLoop: feed | ||
EventLoopThrottle: 0.16 # secs | ||
network: | ||
ssl: | ||
CertFile: dd | ||
EventLoop: <val> # the event loop configuration mode, "feed" or "timer" | ||
EventLoopThrottle: <val> # event loop rate limit in seconds | ||
network: # general network level configuration | ||
ssl: # SSL related configuration | ||
CertFile: <val> # [optional] path to the SSL certificate authority cert file | ||
|
||
# general order worker related configurations | ||
orders: | ||
ActiveDepth: 10 | ||
ActiveDepth: <val> # active depth on each side of book respectively (bid and ask) | ||
|
||
# set of configured venues (with their contextual configurations) to initialise for use with the order workers | ||
venues: | ||
cosine.venues.bem: | ||
Username: BEMUser123 | ||
Password: BEMUserPWD123! | ||
APIDomain: dd | ||
APIID: asdsdvsv | ||
ConnectSignalR: true | ||
cosine.venues.bem: # [optional] the fully qualified module path of the BlockExMarketsVenue (CosineBaseVenue derivative) class to load + configure | ||
Username: <val> # [venue-specific] the username of the trader account to authenticate against | ||
Password: <val> # [venue-specific] the password of the trader account to authenticate against | ||
APIDomain: <val> # [venue-specific] the top-level domain of the BEM venue | ||
APIID: <val> # [venue-specific] the dedicated APIID for the BEM venue | ||
ConnectSignalR: <val> # [venue-specific] tells BEM whether to subscribe to the async signalR feed or not, "true" or "false" | ||
|
||
# the set of configured instruments to work markets in. Order workers will be created against each of these on the relevant venue(s) | ||
instruments: | ||
- "XTN/EUR" | ||
- "RCC/Euro" | ||
- "RCC/EUR" | ||
- "ETH4/EUR" | ||
|
||
# the set of configured pricing feeds to connect and subscribe to for market data consumption | ||
feeds: | ||
cosine.pricing.cryptocompare: | ||
type: stream | ||
endpoint: https://streamer.cryptocompare.com | ||
port: 443 | ||
framework: socket.io | ||
triangulator: https://min-api.cryptocompare.com | ||
triangulator_throttle: 0.4 # secs | ||
instruments: | ||
cosine.pricing.cryptocompare: # [optional] the fully qualified module path of the CryptoCompareSocketIOFeed (CosineBaseFeed derivative) class to load + configure | ||
type: <val> # [feed-specific] the type of connection ("stream" only for this feed) | ||
endpoint: <val> # [feed-specific] the websockets/socket.io endpoint hostname to connect to | ||
port: <val> # [feed-specific] the port to connect to | ||
framework: <val> # [feed-specific] the framework for connectivity | ||
triangulator: <val> # [feed-specific] the REST endpoint to use to pull triangulation info for implying pricing for pairs with no direct subscription | ||
triangulator_throttle: <val> # [feed-specific] the rate limit for running triangulation queries in seconds | ||
instruments: # the set of instruments to subscribe to | ||
"XTN/EUR": | ||
Ticker: "BTC" | ||
"RCC/Euro": | ||
BaseCCY: "ETH" | ||
"ETH4/EUR": | ||
Ticker: "ETH" | ||
Ticker: <val> # ticker re-mapping for the base/top-level currency, e.g. "BTC" | ||
BaseCCY: <val> # [optional] forces the feed to e.g. if the value is "ETH" for an RCC/EUR pair, subscribe to RCC/ETH and then run triangulation on each price tick to calculate the RCC/EUR price | ||
"RCC/EUR": {} | ||
"ETH4/EUR": {} | ||
|
||
# [optional] the configured primary feed, such that when "system.EventLoop: feed", this CosineBaseFeed derivative will be configured to drive the main event loop | ||
feed: | ||
Primary: cosine.pricing.cryptocompare | ||
Primary: cosine.pricing.cryptocompare # primary feed to drive the main event loop | ||
|
||
# the set of configured pricers to pipeline for processing pricing data. Can be used to consume raw price feed data and generate theoretical pricing or other price-derived values | ||
pricers: | ||
Default: cosine.pricing.pricers.nullpricer | ||
settings: | ||
cosine.pricing.pricers.nullpricer: | ||
nop: nop | ||
Default: cosine.pricing.pricers.nullpricer # a comma-separated list of pricer modules to load and pipeline in-order for pricing generation | ||
settings: # the set of pricer-specific configurations | ||
cosine.pricing.pricers.nullpricer: {} # [pricer-specific] pricer configuration | ||
|
||
# the configuration for the configured strategy to run | ||
strategy: | ||
type: cosine.strategies.noddy_floater | ||
settings: | ||
cosine.strategies.noddy_floater: | ||
Spread: 0.20 | ||
MaxSpread: 0.5 | ||
instrument_settings: | ||
type: cosine.strategies.noddy_floater # the strategy module to load and run under the algo. This contains the core business logic of the algo | ||
settings: # the set of strategy-specific settings configurations | ||
cosine.strategies.noddy_floater: # [optional] the noddy_floater strategy settings | ||
Spread: <val> # [strategy-specific] the % spread to maintain around the spot mid-price, e.g. 0.20 | ||
MaxSpread: <val> # [strategy-specific] the maximum % spread based on dynamic widening of quotes, e.g. 0.50 | ||
instrument_settings: # [strategy-specific] instrument specific strategy settings | ||
"XTN/EUR": | ||
MinVol: 5 | ||
MaxVol: 10 | ||
"RCC/Euro": | ||
MinVol: 5 | ||
MaxVol: 10 | ||
"ETH4/EUR": | ||
MinVol: 5 | ||
MaxVol: 10 | ||
MinVol: <val> # [strategy-specific] minimum volume per quoted price step | ||
MaxVol: <val> # [strategy-specific] maximum volume per quoted price step | ||
"RCC/EUR": {} | ||
"ETH4/EUR": {} |
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,49 @@ | ||
""" | ||
# | ||
# 09/10/2018 | ||
# Oladotun Rominiyi - Copyright © 2018. all rights reserved. | ||
""" | ||
__author__ = 'dotun rominiyi' | ||
|
||
# IMPORTS | ||
import random | ||
from decimal import Decimal | ||
from cosine.core.order_worker import Pos | ||
from cosine.strategies import locate_strategy | ||
from .base_strategy import CosineBaseStrategy | ||
|
||
|
||
# MODULE CLASSES | ||
class CosineMultiStrategy(CosineBaseStrategy): | ||
|
||
def __init__(self, cfg, cxt, venues, pool, logger=None, **kwargs): | ||
super().__init__(cfg, cxt, venues, pool, logger=logger, **kwargs) | ||
self.strategies = map(lambda strat_name: self._create_strategy(strat_name), kwargs['strategies']) | ||
|
||
|
||
def setup(self): | ||
for strategy in self.strategies: | ||
strategy.setup() | ||
|
||
|
||
def teardown(self): | ||
for strategy in self.strategies: | ||
strategy.teardown() | ||
|
||
|
||
def update(self): | ||
self.logger.debug("MultiStrategy - ** update **") | ||
for strategy in self.strategies: | ||
strategy.update() | ||
self.logger.debug("MultiStrategy - ** update complete **") | ||
|
||
|
||
def _create_strategy(self, strat_name): | ||
strat = self._cfg.get("strategy", {}) | ||
strategy_def = strat.get("settings", {}).get(strat_name, {}, split=False) | ||
StrategyClass = locate_strategy(module_name=strat_name) | ||
if not StrategyClass: | ||
raise ValueError("MultiStrategy - Failed to identify a valid strategy") | ||
self.logger.info(f"MultiStrategy - Loading CosineStrategy: [{strat_name}]") | ||
strategy = StrategyClass(self._cfg, self._cxt, self._venues, self._pool, logger=self.logger, **strategy_def) | ||
return strategy |
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.