Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Getting last brought price and last sold price #798

Closed
foux opened this issue Dec 4, 2017 · 4 comments
Closed

Getting last brought price and last sold price #798

foux opened this issue Dec 4, 2017 · 4 comments
Labels

Comments

@foux
Copy link

foux commented Dec 4, 2017

Hi,

I'm trying to write a new strategy, and I can't seem to find if we can somewhere in the strategy the assets price when last bought and when last sold. Am I missing something?

Thanks in advance!

@foux
Copy link
Author

foux commented Dec 4, 2017

Oh, yeah, and the current asset price ;)

@KryptoNova
Copy link
Contributor

KryptoNova commented Dec 4, 2017

@foux, the current asset price can be found in the s.period.close.

The list of trades can be found in s.my_trades array. As long as it has a length that is greater than 0. The operation, price, and timestamp are all contained in the object stored in the array.
I recommend that you run a sim and use console.log(s) to see all the items that are in the "s" object in the "onPeriod" method and that will give you lots of new toys to play with for strategies. 😃

However, the my_trades array is only in the context of while the bot has been running, from my experience. If you stop the bot and start it again, the s.my_trades starts back as a fresh array. So take care in your strategy that it does not need to rely on persisted orders to be functional.

@foux
Copy link
Author

foux commented Dec 5, 2017

Thank you very much for your very detailed answer @KryptoNova ! I will try that tonight.

@foux
Copy link
Author

foux commented Dec 5, 2017

OK, so my strategy sucks, but at least now I have everything I need! Thanks a lot again for your quick and detailed help @KryptoNova !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants