-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugins): implemented mbp plugin
Implemented and tested mbp plugin. Pretty cool, the value is calculated after the order is applied. Fisrt time since the start of the project that this is possible.
- Loading branch information
1 parent
1590f1f
commit 0bf8431
Showing
21 changed files
with
310 additions
and
44 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Generated by Django 4.1.7 on 2023-08-13 18:39 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django_napse.utils.findable_class | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("django_napse_core", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Plugin", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("category", models.CharField(max_length=255)), | ||
( | ||
"strategy", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="plugins", | ||
to="django_napse_core.strategy", | ||
), | ||
), | ||
], | ||
bases=(models.Model, django_napse.utils.findable_class.FindableClass), | ||
), | ||
migrations.CreateModel( | ||
name="MBPPlugin", | ||
fields=[ | ||
( | ||
"plugin_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="django_napse_core.plugin", | ||
), | ||
), | ||
], | ||
bases=("django_napse_core.plugin",), | ||
), | ||
] |
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
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,11 +1,27 @@ | ||
from django_napse.core.models.bots.plugin import Plugin | ||
from django_napse.utils.constants import PLUGIN_CATEGORIES | ||
from django_napse.core.models.connections.connection import ConnectionSpecificArgs | ||
from django_napse.utils.constants import PLUGIN_CATEGORIES, SIDES | ||
|
||
|
||
class MBPPlugin(Plugin): | ||
@property | ||
def plugin_category(self): | ||
return PLUGIN_CATEGORIES.PRE_PROCESSING | ||
@classmethod | ||
def plugin_category(cls): | ||
return PLUGIN_CATEGORIES.POST_ORDER | ||
|
||
def _apply(self, data: dict) -> dict: | ||
return super()._apply(data) | ||
order = data["order"] | ||
if order["side"] == SIDES.BUY: | ||
new_mbp = f"{order['controller'].base}|($ * _ + #) / (# / {order['price']} + $)" | ||
order["ConnectionModifications"] += [ | ||
{ | ||
"key": "mbp", | ||
"value": new_mbp, | ||
"target_type": "plugin_mbp", | ||
"ignore_failed_order": False, | ||
"connection_specific_arg": data["connection_data"][data["connection"]]["connection_specific_args"]["mbp"], | ||
}, | ||
] | ||
return data | ||
|
||
def _connect(self, connection): | ||
ConnectionSpecificArgs.objects.create(connection=connection, key="mbp", value="0", target_type="float") |
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
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.