Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
factory_methof_design
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rakesh.pv
factory_methof_design
Commits
d6e401a1
Commit
d6e401a1
authored
Feb 20, 2023
by
rakesh.pv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factory
parents
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
test2.py
+51
-0
No files found.
test2.py
0 → 100644
View file @
d6e401a1
from
abc
import
ABC
,
abstractmethod
class
SellStrategy
(
ABC
):
@abstractmethod
def
sell_crypto
(
self
,
x
:
float
,
y
:
float
):
"""sells crypto and returns new x"""
class
SellAll
(
SellStrategy
):
def
sell_crypto
(
self
,
x
:
float
,
y
:
float
):
btc
=
0
usdt
=
x
*
y
return
{
"btc"
:
btc
,
"usdt"
:
usdt
}
class
SellHalf
(
SellStrategy
):
def
sell_crypto
(
self
,
x
:
float
,
y
:
float
):
btc
=
x
/
2
usdt
=
(
x
/
2
)
*
y
return
{
"btc"
:
btc
,
"usdt"
:
usdt
}
class
SellLittle
(
SellStrategy
):
def
sell_crypto
(
self
,
x
:
float
,
y
:
float
):
btc
=
x
*
0.9
usdt
=
(
x
*
0.1
)
*
y
return
{
"btc"
:
btc
,
"usdt"
:
usdt
}
class
TradingApp
:
assets
=
{
"btc"
:
100
,
"usdt"
:
0
}
y
=
30000
def
sell_order
(
self
,
sell_decision
:
SellStrategy
):
self
.
assets
=
sell_decision
.
sell_crypto
(
self
.
assets
[
"btc"
],
self
.
y
)
return
self
.
assets
A
=
TradingApp
()
assets
=
A
.
sell_order
(
SellAll
())
print
(
assets
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment