-
Notifications
You must be signed in to change notification settings - Fork 425
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 #8 from nkaz001/partial_fill
Partial fill
- Loading branch information
Showing
9 changed files
with
631 additions
and
69 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,29 +1,34 @@ | ||
from numba import int64 | ||
from numba.experimental import jitclass | ||
|
||
|
||
@jitclass | ||
class _Linear: | ||
def __init__(self): | ||
pass | ||
class LinearAsset: | ||
contract_size: int64 | ||
|
||
def __init__(self, contract_size=1): | ||
self.contract_size = contract_size | ||
|
||
def amount(self, exec_price, qty): | ||
return exec_price * qty | ||
return self.contract_size * exec_price * qty | ||
|
||
def equity(self, price, balance, position, fee): | ||
return balance + position * price - fee | ||
return balance + self.contract_size * position * price - fee | ||
|
||
|
||
@jitclass | ||
class _Inverse: | ||
def __init__(self): | ||
pass | ||
class InverseAsset: | ||
contract_size: int64 | ||
|
||
def __init__(self, contract_size=1): | ||
self.contract_size = contract_size | ||
|
||
def amount(self, exec_price, qty): | ||
return qty / exec_price | ||
return self.contract_size * qty / exec_price | ||
|
||
def equity(self, price, balance, position, fee): | ||
return -balance - position / price - fee | ||
return -balance - self.contract_size * position / price - fee | ||
|
||
|
||
Linear = _Linear() | ||
Inverse = _Inverse() | ||
Linear = LinearAsset() | ||
Inverse = InverseAsset() |
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.