slowly working on the endpoints
This commit is contained in:
@@ -1,2 +1,55 @@
|
||||
|
||||
|
||||
# defines the schema to submit a new strategy to the system
|
||||
__SUBMIT_STRATEGY_SCHEMA__ = {
|
||||
"$id": "http://example.com/example.json",
|
||||
"type": "object",
|
||||
"definitions": {},
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"properties": {
|
||||
"user": {
|
||||
"$id": "/properties/user",
|
||||
"type": "string",
|
||||
"title": "the associated Isaac user",
|
||||
"default": "",
|
||||
"examples": [
|
||||
"GCU4LW2XXZW3A3FM2XZJTEJHNWHTWDKY2DIJLCZJ5ULVZ4K7LZ7D23TG"
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"$id": "/properties/description",
|
||||
"type": "string",
|
||||
"title": "a brief description",
|
||||
"default": "",
|
||||
"examples": [
|
||||
"simple test strategy"
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"$id": "/properties/name",
|
||||
"type": "string",
|
||||
"title": "the name of your strategy",
|
||||
"default": "",
|
||||
"examples": [
|
||||
"TestStrategy"
|
||||
]
|
||||
},
|
||||
"public": {
|
||||
"$id": "/properties/public",
|
||||
"type": "boolean",
|
||||
"title": "Will this strategy be public",
|
||||
"default": "false",
|
||||
"examples": [
|
||||
"true",
|
||||
"false"
|
||||
]
|
||||
},
|
||||
"content": {
|
||||
"$id": "/properties/content",
|
||||
"type": "string",
|
||||
"title": "The Content Schema ",
|
||||
"default": "",
|
||||
"examples": [
|
||||
"IyAtLS0gRG8gbm90IHJlbW92ZSB0aGVzZSBsaWJzIC0tLQpmcm9tIGZyZXF0cmFkZS5zdHJhdGVneS5pbnRlcmZhY2UgaW1wb3J0IElTdHJhdGVneQpmcm9tIHR5cGluZyBpbXBvcnQgRGljdCwgTGlzdApmcm9tIGh5cGVyb3B0IGltcG9ydCBocApmcm9tIGZ1bmN0b29scyBpbXBvcnQgcmVkdWNlCmZyb20gcGFuZGFzIGltcG9ydCBEYXRhRnJhbWUKIyAtLS0tLS0tLS0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ICAgZGF0YWZyYW1lLmxvY1sKICAgICAgICAgICAgKAogICAgICAgICAgICAgICAgcXRweWxpYi5jcm9zc2VkX2Fib3ZlKGRhdGFmcmFtZVsnbWFNZWRpdW0nXSwgZGF0YWZyYW1lWydtYVNob3J0J10pCiAgICAgICAgICAgICksCiAgICAgICAgICAgICdzZWxsJ10gPSAxCiAgICAgICAgcmV0dXJuIGRhdGFmcmFtZQoKCiAgICAgICAg"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from freqtrade.strategy.resolver import StrategyResolver
|
||||
|
||||
import simplejson as json
|
||||
from jsonschema import validate
|
||||
from freqtrade.aws.schemas import __SUBMIT_STRATEGY_SCHEMA__
|
||||
from base64 import urlsafe_b64decode
|
||||
|
||||
def names(event, context):
|
||||
"""
|
||||
@@ -31,9 +37,23 @@ def code(event, context):
|
||||
|
||||
def submit(event, context):
|
||||
"""
|
||||
combiles the given strategy and stores it in the internal database
|
||||
compiles the given strategy and stores it in the internal database
|
||||
:param event:
|
||||
:param context:
|
||||
:return:
|
||||
"""
|
||||
|
||||
# get data
|
||||
data = json.loads(event['body'])
|
||||
|
||||
# validate against schema
|
||||
validate(data, __SUBMIT_STRATEGY_SCHEMA__)
|
||||
|
||||
strategy = urlsafe_b64decode(data['content']).decode('utf-8')
|
||||
|
||||
# try to load the strategy
|
||||
StrategyResolver().compile(data['name'], strategy)
|
||||
|
||||
# save to DB
|
||||
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user