Skip to content

Commit

Permalink
bugfix 20240805.1
Browse files Browse the repository at this point in the history
readme update
  • Loading branch information
Danaka-dev committed Aug 5, 2024
1 parent d3cb96d commit 45fed77
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 17 deletions.
20 changes: 17 additions & 3 deletions DONATION
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

DONATION FOR SOLOMINER 2
------------------------
Open source project for the improvement of decentralization and public awareness of cryptocurrency.
SOLOMINER 2
===========

Free and Open Source project for the improvement of public awareness and decentralization of digital currency.

DONATION
--------

If you wish to fuel development of SOLOMINER with a donation you are welcome to do so here :

Expand All @@ -15,6 +19,16 @@ Let us know if you wish to have your name/pseudo and a custom text appear in the

For donations related to feature request, drop us a note beforehand to avoid any disappointment.

REFERRAL
--------

Solominer2 trading features use Xeggex low fee exchange, if you don't have an account you may create one
using our referral link:

<https://xeggex.com?ref=658a9ac948bb17dc13997793&campaign=solominer2&source=github>



Thank you for your support!

Contact: [email protected]
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ for you automatically.*
and trading directly from the user interface.*
\
(WARNING: this is a non fully debugged BETA feature, only use for testing or development purpose at this time!)
\
Trading features use Xeggex low fee exchange, if you don't have an account you may create one using our referral link:
\
<https://xeggex.com?ref=658a9ac948bb17dc13997793&campaign=solominer2&source=github>

### ![text](https://cdn.jsdelivr.net/gh/Readme-Workflows/Readme-Icons@main/icons/octicons/ApprovedChanges.svg) *version*

Expand Down Expand Up @@ -227,7 +231,6 @@ Windows/MSVC port will follow right after.

### ***Stay tuned !***


Donation
--------

Expand Down
4 changes: 4 additions & 0 deletions depends/tiny/tiny-os.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ TINYFUN OsTimerTime OsTimerConvertToNanosec( OsTimerCycle cycles );
//! must call OsTimerGetResolution before calling this function
//TODO .. not

inline OsTimerTime OsTimerNow( void ) {
return OsTimerConvertToMs( OsTimerGetTimeNow() );
}

//////////////////////////////////////////////////////////////////////////
//! file (drive)

Expand Down
4 changes: 3 additions & 1 deletion src/interface/IMarket.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ struct MarketOrder {
//! <0 market rate ,else limit price
//! NB stop order handled using IBroker

enum Side { Sell=0 ,Buy } side;

TimeSec validity; //! time until order is valid

double quantityFilled; //! order quantity already filled
Expand All @@ -152,7 +154,7 @@ inline bool isSpotOrder( const MarketOrder &order ) {
}

template <> inline MarketOrder &Zero( MarketOrder &p ) {
p = { "" ,"" ,{ 0. ,"" } ,"" ,0. }; return p;
p = { "" ,"" ,{ 0. ,"" } ,"" ,0. ,MarketOrder::Sell ,0 ,0. }; return p;
}

//////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions src/markets/markets.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class CMarketService : public IMarket ,public CService

static const char *category() { return "market"; }

API_DECL(void) noCache() {}

public: ///-- IService
//...

Expand Down
12 changes: 8 additions & 4 deletions src/markets/xeggex/xeggex-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,18 +700,22 @@ bool CApi2::marketGetBySymbol( const char *symbol ,Market2 &market ) {
bool CApi2::marketGetOrderBookBySymbol( const char *symbol ,OrderBook &book ) {
String response; long status;

if( !HttpSend( "/market/getorderbookbysymbol/" ,symbol ,nullptr ,response ,status ,false ,false ) )
if( !HttpSend( "/market/getorderbookbysymbol/" ,symbol ,nullptr ,response ,status ,false ,m_noCache ) )
return( false );

m_noCache = false;

return parseResponseStruct_( response ,book );
}

bool CApi2::marketGetOrderBookByMarketId( const char *marketId ,OrderBook &book ) {
String response; long status;

if( !HttpSend( "/market/getorderbookbymarketid/" ,marketId ,nullptr ,response ,status ,false ,false ) )
if( !HttpSend( "/market/getorderbookbymarketid/" ,marketId ,nullptr ,response ,status ,false ,m_noCache ) )
return( false );

m_noCache = false;

return parseResponseStruct_( response ,book );
}

Expand Down Expand Up @@ -826,12 +830,12 @@ bool CApi2::getOrder( const char *orderId ,Order &order ) {
return parseResponseStruct_( response ,order );
}

bool CApi2::getOrders( const char *ticker ,const char *orderStatus ,ListOf<Order> &orders ,int limit ,int skip ) {
bool CApi2::getOrders( const char *marketPair ,const char *orderStatus ,ListOf<Order> &orders ,int limit ,int skip ) {
String response; long status;

std::stringstream ss;

ss << "?ticker=" << ticker << "&status=" << orderStatus << "&limit=" << limit << "&skip=" << skip;
ss << "?symbol=" << marketPair << "&status=" << orderStatus << "&limit=" << limit << "&skip=" << skip;

if( !HttpSend( "/getorders" ,ss.str().c_str() ,nullptr ,response ,status ,true ,true ) )
return( false );
Expand Down
8 changes: 6 additions & 2 deletions src/markets/xeggex/xeggex-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,18 @@ class CApi2 {

ApiConfig m_config;

bool m_noCache; //! cache use for next request only

public:
CApi2( IHttp &http ) : m_http(http)
CApi2( IHttp &http ) : m_http(http) ,m_noCache(false)
{}

const ApiConfig &config() const { return m_config; }

ApiConfig &config() { return m_config; }

void noCache() { m_noCache = true; }

//////////////////////////////////////////////////////////////////////////////
//! APIv2

Expand Down Expand Up @@ -511,7 +515,7 @@ class CApi2 {
bool getDeposits( const char *ticker ,ListOf<Deposit> &deposits ,int limit=0 ,int skip=500 );
bool getWithdrawals( const char *ticker ,ListOf<Withdrawal> &withdrawals ,int limit=0 ,int skip=500 );
bool getOrder( const char *orderId ,Order &order );
bool getOrders( const char *ticker ,const char *orderStatus ,ListOf<Order> &orders ,int limit=0 ,int skip=500 );
bool getOrders( const char *marketPair ,const char *orderStatus ,ListOf<Order> &orders ,int limit=100 ,int skip=0 );

bool getTrades( const char *symbol ,ListOf<Trade> &trades ,int limit=0 ,int skip=500 );
bool getTradesSince( const char *ticker ,ListOf<Trade> &trades ,const char *sinceTimestampMs ,int limit=0 ,int skip=500 );
Expand Down
22 changes: 18 additions & 4 deletions src/markets/xeggex/xeggex-market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ xeggex::OrderToCreate &toManifest( const MarketOrder &p ,xeggex::OrderToCreate &

manifest.userProvidedId = p.userId;
manifest.symbol = toMarketSymbol( symbol ,p.amount.value ,p.toValue );
manifest.side = "sell";
manifest.side = (p.side == MarketOrder::Sell) ? "sell" : "buy";
manifest.type = (p.price < 0.) ? "market" : "limit";
manifest.quantity = toString( p.amount.amount );
manifest.price = toString( MAX( p.price ,0. ) );
Expand Down Expand Up @@ -263,13 +263,15 @@ MarketOrder &fromManifest( MarketOrder &p ,const xeggex::Order &manifest ) {
swap( primaryAsset ,secondaryAsset );

p.id = manifest.id;
p.userId = manifest.userProvidedId;

p.amount.amount = fromString<double>( manifest.quantity );
p.amount.value = primaryAsset;
p.toValue = secondaryAsset;
p.price = fromString<double>( manifest.price );
// p.validity;
p.side = (manifest.side == "buy") ? MarketOrder::Buy : MarketOrder::Sell;

// p.validity; //TODO
p.quantityFilled = fromString<double>( manifest.executedQuantity );

p.status = manifest.status;
Expand Down Expand Up @@ -533,8 +535,20 @@ IAPI_DEF CMarketXeggex::listWithdrawals( const char *value ,std::vector<MarketWi
}

IAPI_DEF CMarketXeggex::listOrders( const char *pair ,std::vector<MarketOrder> &orders ,int from ,int count ) {
//TODO here ... and other IMarket to XeggeX
return INOEXEC;
ListOf<xeggex::Order> xorders;

if( !api().getOrders( pair ,"active" ,xorders ) ) //! TODO .. limit vs since ?
return IERROR;

MarketOrder order;

for( const auto &it : xorders ) {
fromManifest( order ,it );

orders.emplace_back( order );
}

return IOK;
}

//////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions src/markets/xeggex/xeggex-market.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class CMarketXeggex : public CMarketService ,public xeggex::IHttp {

xeggex::CApi2 &api() { return m_api; }

API_IMPL(void) noCache() IOVERRIDE { api().noCache(); }

public: ///-- IMarket
IAPI_IMPL getAssetList( ListOf<String> &assets ) IOVERRIDE;

Expand Down
7 changes: 5 additions & 2 deletions src/solominer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ void mainAppLoop() {
//! Main

// #include "test-graph.hpp"
#include "test-trade.hpp"

#define ERROR_OK 0
#define ERROR_ARGS -1
Expand All @@ -532,9 +533,11 @@ int main( int argc ,char *argv[] ) {
//////////////////////////////////////////////////////////////////////////////
//! TEST

/* OsTimerGetResolution();
test::test_trade();
return 0;

// algo::test_graph();
/*
algo::test_graph();
while( OsSystemDoEvents() == ENOERROR ) {
OsSleep(10);
Expand Down

0 comments on commit 45fed77

Please sign in to comment.